summaryrefslogtreecommitdiff
path: root/src/input/joystick.h
diff options
context:
space:
mode:
authorewewukek <ewewukek@gmail.com>2024-01-11 15:04:28 +0300
committerFedja Beader <fedja@protonmail.ch>2024-05-15 00:11:38 +0200
commit842b7fd4db44d85308afbb401023429621d9c586 (patch)
treec7d815e9074e8bf1c074937b83808cc34e4c6258 /src/input/joystick.h
parent0ff6869e745b4a0174ab1ee116ba5d6ad08e4812 (diff)
downloadplus-842b7fd4db44d85308afbb401023429621d9c586.tar.gz
plus-842b7fd4db44d85308afbb401023429621d9c586.tar.bz2
plus-842b7fd4db44d85308afbb401023429621d9c586.tar.xz
plus-842b7fd4db44d85308afbb401023429621d9c586.zip
Make sticks/triggers behave like regular buttons
Diffstat (limited to 'src/input/joystick.h')
-rw-r--r--src/input/joystick.h15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/input/joystick.h b/src/input/joystick.h
index 293e75a22..2a7e0f638 100644
--- a/src/input/joystick.h
+++ b/src/input/joystick.h
@@ -51,8 +51,15 @@ class Joystick final
MAX_BUTTONS = 64
};
+ enum
+ {
+ RESERVED_AXES = 2, // reserved for movement
+ MAX_AXES = 8 // number of axes we can handle
+ };
+
/**
- * Additional "buttons" for hat 0 (d-pad).
+ * Additional "buttons" for hat 0 (d-pad),
+ * sticks and triggers.
*/
enum
{
@@ -60,7 +67,9 @@ class Joystick final
KEY_DOWN,
KEY_LEFT,
KEY_RIGHT,
- KEY_LAST = KEY_RIGHT
+ KEY_NEGATIVE_AXIS_FIRST,
+ KEY_POSITIVE_AXIS_FIRST = KEY_NEGATIVE_AXIS_FIRST + MAX_AXES,
+ KEY_END = KEY_POSITIVE_AXIS_FIRST + MAX_AXES
};
/**
@@ -169,12 +178,14 @@ class Joystick final
unsigned char mDirection;
unsigned char mHatPosition;
+ int mAxesPositions[MAX_AXES];
bool mActiveButtons[MAX_BUTTONS];
SDL_Joystick *mJoystick;
float mTolerance;
int mNumber;
+ int mAxesNumber;
int mButtonsNumber;
bool mUseHatForMovement;
bool mUseInactive;