diff options
Diffstat (limited to 'src/client/joystick_controller.h')
-rw-r--r-- | src/client/joystick_controller.h | 62 |
1 files changed, 24 insertions, 38 deletions
diff --git a/src/client/joystick_controller.h b/src/client/joystick_controller.h index 7baacd81b..ea0833561 100644 --- a/src/client/joystick_controller.h +++ b/src/client/joystick_controller.h @@ -24,7 +24,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #include <bitset> #include <vector> -enum JoystickAxis { +enum JoystickAxis +{ JA_SIDEWARD_MOVE, JA_FORWARD_MOVE, @@ -35,27 +36,28 @@ enum JoystickAxis { JA_COUNT, }; -struct JoystickAxisLayout { +struct JoystickAxisLayout +{ u16 axis_id; // -1 if to invert, 1 if to keep it. int invert; }; +struct JoystickCombination +{ -struct JoystickCombination { - - virtual bool isTriggered(const irr::SEvent::SJoystickEvent &ev) const=0; + virtual bool isTriggered(const irr::SEvent::SJoystickEvent &ev) const = 0; GameKeyType key; }; -struct JoystickButtonCmb : public JoystickCombination { +struct JoystickButtonCmb : public JoystickCombination +{ JoystickButtonCmb() = default; JoystickButtonCmb(GameKeyType key, u32 filter_mask, u32 compare_mask) : - filter_mask(filter_mask), - compare_mask(compare_mask) + filter_mask(filter_mask), compare_mask(compare_mask) { this->key = key; } @@ -68,14 +70,14 @@ struct JoystickButtonCmb : public JoystickCombination { u32 compare_mask; }; -struct JoystickAxisCmb : public JoystickCombination { +struct JoystickAxisCmb : public JoystickCombination +{ JoystickAxisCmb() = default; JoystickAxisCmb(GameKeyType key, u16 axis_to_compare, int direction, s16 thresh) : - axis_to_compare(axis_to_compare), - direction(direction), - thresh(thresh) + axis_to_compare(axis_to_compare), direction(direction), + thresh(thresh) { this->key = key; } @@ -92,14 +94,16 @@ struct JoystickAxisCmb : public JoystickCombination { s16 thresh; }; -struct JoystickLayout { +struct JoystickLayout +{ std::vector<JoystickButtonCmb> button_keys; std::vector<JoystickAxisCmb> axis_keys; JoystickAxisLayout axes[JA_COUNT]; s16 axes_dead_border; }; -class JoystickController { +class JoystickController +{ public: JoystickController(); @@ -115,14 +119,8 @@ public: m_past_pressed_keys[b] = false; return r; } - bool getWasKeyDown(GameKeyType b) - { - return m_past_pressed_keys[b]; - } - void clearWasKeyDown(GameKeyType b) - { - m_past_pressed_keys[b] = false; - } + bool getWasKeyDown(GameKeyType b) { return m_past_pressed_keys[b]; } + void clearWasKeyDown(GameKeyType b) { m_past_pressed_keys[b] = false; } bool wasKeyReleased(GameKeyType b) { @@ -130,24 +128,12 @@ public: m_past_released_keys[b] = false; return r; } - bool getWasKeyReleased(GameKeyType b) - { - return m_past_pressed_keys[b]; - } - void clearWasKeyReleased(GameKeyType b) - { - m_past_pressed_keys[b] = false; - } + bool getWasKeyReleased(GameKeyType b) { return m_past_pressed_keys[b]; } + void clearWasKeyReleased(GameKeyType b) { m_past_pressed_keys[b] = false; } - bool isKeyDown(GameKeyType b) - { - return m_pressed_keys[b]; - } + bool isKeyDown(GameKeyType b) { return m_pressed_keys[b]; } - s16 getAxis(JoystickAxis axis) - { - return m_axes_vals[axis]; - } + s16 getAxis(JoystickAxis axis) { return m_axes_vals[axis]; } s16 getAxisWithoutDead(JoystickAxis axis); |