aboutsummaryrefslogtreecommitdiff
path: root/src/client/joystick_controller.h
diff options
context:
space:
mode:
authorElias Fleckenstein <54945686+EliasFleckenstein03@users.noreply.github.com>2020-11-04 16:57:47 +0100
committerGitHub <noreply@github.com>2020-11-04 16:57:47 +0100
commit3e16c3a78fff61c20e63ba730d15e94e3bb877b4 (patch)
treec070350db219f2c4241d22bc31949685c7b42fe9 /src/client/joystick_controller.h
parent5d9ae5a91c544fc7fbd475decf47cef7e09ef8fc (diff)
parent6ccb5835ff55d85156be91473c598eca9d6cb9a6 (diff)
downloaddragonfireclient-3e16c3a78fff61c20e63ba730d15e94e3bb877b4.tar.xz
Merge branch 'master' into master
Diffstat (limited to 'src/client/joystick_controller.h')
-rw-r--r--src/client/joystick_controller.h62
1 files changed, 38 insertions, 24 deletions
diff --git a/src/client/joystick_controller.h b/src/client/joystick_controller.h
index ea0833561..7baacd81b 100644
--- a/src/client/joystick_controller.h
+++ b/src/client/joystick_controller.h
@@ -24,8 +24,7 @@ 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,
@@ -36,28 +35,27 @@ enum JoystickAxis
JA_COUNT,
};
-struct JoystickAxisLayout
-{
+struct JoystickAxisLayout {
u16 axis_id;
// -1 if to invert, 1 if to keep it.
int invert;
};
-struct JoystickCombination
-{
- virtual bool isTriggered(const irr::SEvent::SJoystickEvent &ev) const = 0;
+struct JoystickCombination {
+
+ 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;
}
@@ -70,14 +68,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;
}
@@ -94,16 +92,14 @@ 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();
@@ -119,8 +115,14 @@ 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)
{
@@ -128,12 +130,24 @@ 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);