summaryrefslogtreecommitdiff
path: root/src/input/joystick.h
diff options
context:
space:
mode:
authorewewukek <ewewukek@gmail.com>2024-01-11 12:53:19 +0300
committerewewukek <ewewukek@gmail.com>2024-03-27 13:18:30 +0300
commit9ccb4f7cc71443f9ed43171d4d825ba08b61943c (patch)
tree120af0adb3c483ca0fbaa6a6d2334ac8c45b4eaa /src/input/joystick.h
parent7c6feeb44a614985ea957c5ca431e331fd41d216 (diff)
downloadmanaplus-9ccb4f7cc71443f9ed43171d4d825ba08b61943c.tar.gz
manaplus-9ccb4f7cc71443f9ed43171d4d825ba08b61943c.tar.bz2
manaplus-9ccb4f7cc71443f9ed43171d4d825ba08b61943c.tar.xz
manaplus-9ccb4f7cc71443f9ed43171d4d825ba08b61943c.zip
Make D-Pad behave like regular buttons
Diffstat (limited to 'src/input/joystick.h')
-rw-r--r--src/input/joystick.h15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/input/joystick.h b/src/input/joystick.h
index 32fdddf2e..bddf520a2 100644
--- a/src/input/joystick.h
+++ b/src/input/joystick.h
@@ -52,6 +52,18 @@ class Joystick final
};
/**
+ * Additional "buttons" for hat 0 (d-pad).
+ */
+ enum
+ {
+ KEY_UP = MAX_BUTTONS,
+ KEY_DOWN,
+ KEY_LEFT,
+ KEY_RIGHT,
+ KEY_LAST = KEY_RIGHT
+ };
+
+ /**
* Directions, to be used as bitmask values.
*/
enum
@@ -107,7 +119,7 @@ class Joystick final
*/
void logic();
- bool buttonPressed(const unsigned char no) const A_WARN_UNUSED;
+ bool buttonPressed(const int no) const A_WARN_UNUSED;
bool isUp() const noexcept2 A_WARN_UNUSED
{ return mEnabled && ((mDirection & UP) != 0); }
@@ -149,6 +161,7 @@ class Joystick final
protected:
unsigned char mDirection;
+ unsigned char mHatPosition;
bool mActiveButtons[MAX_BUTTONS];
SDL_Joystick *mJoystick;