summaryrefslogtreecommitdiff
path: root/src/input/joystick.cpp
diff options
context:
space:
mode:
authorewewukek <ewewukek@gmail.com>2024-01-11 13:50:03 +0300
committerFedja Beader <fedja@protonmail.ch>2024-05-15 00:11:38 +0200
commit1dc559144c8809e2d9ab91a5f90a2047fc0595bc (patch)
tree47fbac5776f2277df4a625cc5a8547c99d28589f /src/input/joystick.cpp
parent046ac8fceda89092f01325abbc8d2b5b8602719c (diff)
downloadplus-1dc559144c8809e2d9ab91a5f90a2047fc0595bc.tar.gz
plus-1dc559144c8809e2d9ab91a5f90a2047fc0595bc.tar.bz2
plus-1dc559144c8809e2d9ab91a5f90a2047fc0595bc.tar.xz
plus-1dc559144c8809e2d9ab91a5f90a2047fc0595bc.zip
Gui support for joystick buttons
Diffstat (limited to 'src/input/joystick.cpp')
-rw-r--r--src/input/joystick.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/input/joystick.cpp b/src/input/joystick.cpp
index 01414b4dc..3a4a47fb1 100644
--- a/src/input/joystick.cpp
+++ b/src/input/joystick.cpp
@@ -357,6 +357,16 @@ KeysVector *Joystick::getActionVectorByKey(const int i)
return nullptr;
}
+InputActionT Joystick::getActionId(const SDL_Event &event)
+{
+ const int i = getButtonFromEvent(event);
+ if (i < 0)
+ return InputAction::NO_VALUE;
+ if (mKeyToId.find(i) != mKeyToId.end())
+ return mKeyToId[i];
+ return InputAction::NO_VALUE;
+}
+
int Joystick::getButtonFromEvent(const SDL_Event &event) const
{
if (event.type == SDL_JOYBUTTONDOWN)