diff options
Diffstat (limited to 'core/input/input.h')
-rw-r--r-- | core/input/input.h | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/core/input/input.h b/core/input/input.h index f63138a875..faec654a3c 100644 --- a/core/input/input.h +++ b/core/input/input.h @@ -85,11 +85,12 @@ public: typedef void (*EventDispatchFunc)(const Ref<InputEvent> &p_event); private: - int mouse_button_mask = 0; + MouseButton mouse_button_mask = MouseButton::NONE; - Set<int> keys_pressed; - Set<int> joy_buttons_pressed; - Map<int, float> _joy_axis; + Set<Key> physical_keys_pressed; + Set<Key> keys_pressed; + Set<JoyButton> joy_buttons_pressed; + Map<JoyAxis, float> _joy_axis; //Map<StringName,int> custom_action_press; Vector3 gravity; Vector3 accelerometer; @@ -133,9 +134,9 @@ private: StringName name; StringName uid; bool connected = false; - bool last_buttons[JOY_BUTTON_MAX] = { false }; - float last_axis[JOY_AXIS_MAX] = { 0.0f }; - int last_hat = HatMask::HAT_MASK_CENTER; + bool last_buttons[(size_t)JoyButton::MAX] = { false }; + float last_axis[(size_t)JoyAxis::MAX] = { 0.0f }; + HatMask last_hat = HatMask::CENTER; int mapping = -1; int hat_current = 0; }; @@ -162,7 +163,7 @@ private: struct JoyEvent { int type; - int index; + int index; // Can be either JoyAxis or JoyButton. float value; }; @@ -206,7 +207,7 @@ private: JoyEvent _get_mapped_button_event(const JoyDeviceMapping &mapping, JoyButton p_button); JoyEvent _get_mapped_axis_event(const JoyDeviceMapping &mapping, JoyAxis p_axis, float p_value); - void _get_mapped_hat_events(const JoyDeviceMapping &mapping, HatDir p_hat, JoyEvent r_events[HAT_MAX]); + void _get_mapped_hat_events(const JoyDeviceMapping &mapping, HatDir p_hat, JoyEvent r_events[(size_t)HatDir::MAX]); JoyButton _get_output_button(String output); JoyAxis _get_output_axis(String output); void _button_event(int p_device, JoyButton p_index, bool p_pressed); @@ -247,6 +248,7 @@ public: static Input *get_singleton(); bool is_key_pressed(Key p_keycode) const; + bool is_physical_key_pressed(Key p_keycode) const; bool is_mouse_button_pressed(MouseButton p_button) const; bool is_joy_button_pressed(int p_device, JoyButton p_button) const; bool is_action_pressed(const StringName &p_action, bool p_exact = false) const; @@ -273,7 +275,7 @@ public: Point2 get_mouse_position() const; Point2 get_last_mouse_speed() const; - int get_mouse_button_mask() const; + MouseButton get_mouse_button_mask() const; void warp_mouse_position(const Vector2 &p_to); Point2i warp_mouse_motion(const Ref<InputEventMouseMotion> &p_motion, const Rect2 &p_rect); @@ -312,7 +314,7 @@ public: void parse_mapping(String p_mapping); void joy_button(int p_device, JoyButton p_button, bool p_pressed); void joy_axis(int p_device, JoyAxis p_axis, const JoyAxisValue &p_value); - void joy_hat(int p_device, int p_val); + void joy_hat(int p_device, HatMask p_val); void add_joy_mapping(String p_mapping, bool p_update_existing = false); void remove_joy_mapping(String p_guid); |