From 2b815df3c19499f9fcf1575cfce1477876030e81 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sun, 8 Jan 2023 00:55:54 +0100 Subject: Use BitField<> in core type masks * All core types masks are now correctly marked as bitfields. * The enum hacks in MouseButtonMask and many other types are gone. This ensures that binders to other languages non C++ can actually implement type safe bitmasks. * Most bitmask operations replaced by functions in BitField<> * Key is still a problem because its enum and mask at the same time. While it kind of works in C++, this most likely can't be implemented safely in other languages and will have to be changed at some point. Mostly left as-is. * Documentation and API dump updated to reflect bitfields in core types. --- platform/android/android_input_handler.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'platform/android/android_input_handler.h') diff --git a/platform/android/android_input_handler.h b/platform/android/android_input_handler.h index 1b89096057..34259efd81 100644 --- a/platform/android/android_input_handler.h +++ b/platform/android/android_input_handler.h @@ -61,7 +61,7 @@ public: int index = 0; // Can be either JoyAxis or JoyButton. bool pressed = false; float value = 0; - HatMask hat = HatMask::CENTER; + BitField hat; }; private: @@ -70,7 +70,7 @@ private: bool control_mem = false; bool meta_mem = false; - MouseButton buttons_state = MouseButton::NONE; + BitField buttons_state; Vector touch; MouseEventInfo mouse_event_info; @@ -78,12 +78,12 @@ private: void _set_key_modifier_state(Ref ev); - static MouseButton _button_index_from_mask(MouseButton button_mask); - static MouseButton _android_button_mask_to_godot_button_mask(int android_button_mask); + static MouseButton _button_index_from_mask(BitField button_mask); + static BitField _android_button_mask_to_godot_button_mask(int android_button_mask); - void _wheel_button_click(MouseButton event_buttons_mask, const Ref &ev, MouseButton wheel_button, float factor); + void _wheel_button_click(BitField event_buttons_mask, const Ref &ev, MouseButton wheel_button, float factor); - void _parse_mouse_event_info(MouseButton event_buttons_mask, bool p_pressed, bool p_double_click, bool p_source_mouse_relative); + void _parse_mouse_event_info(BitField event_buttons_mask, bool p_pressed, bool p_double_click, bool p_source_mouse_relative); void _release_mouse_event_info(bool p_source_mouse_relative = false); -- cgit v1.2.3