summaryrefslogtreecommitdiff
path: root/src/input/inputmanager.cpp
diff options
context:
space:
mode:
authorewewukek <ewewukek@gmail.com>2024-01-11 15:04:28 +0300
committerewewukek <ewewukek@gmail.com>2024-03-27 13:18:30 +0300
commitbf75a839977e5c1a640fcbf40cfc3a8751a40404 (patch)
tree3b0d4e01edf555fbd1999d95cb43d9db5f38767d /src/input/inputmanager.cpp
parent8076db57ec709d76d0861e0fde0aa610d64fdf17 (diff)
downloadmanaplus-bf75a839977e5c1a640fcbf40cfc3a8751a40404.tar.gz
manaplus-bf75a839977e5c1a640fcbf40cfc3a8751a40404.tar.bz2
manaplus-bf75a839977e5c1a640fcbf40cfc3a8751a40404.tar.xz
manaplus-bf75a839977e5c1a640fcbf40cfc3a8751a40404.zip
Make sticks/triggers behave like regular buttons
Diffstat (limited to 'src/input/inputmanager.cpp')
-rw-r--r--src/input/inputmanager.cpp33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/input/inputmanager.cpp b/src/input/inputmanager.cpp
index 1db2fd07d..d1b2ae380 100644
--- a/src/input/inputmanager.cpp
+++ b/src/input/inputmanager.cpp
@@ -441,6 +441,20 @@ std::string InputManager::getKeyStringLong(const InputActionT index) const
// TRANSLATORS: joystick right button. must be short.
str = _("JRight");
}
+ else if (key.value >= Joystick::KEY_NEGATIVE_AXIS_FIRST
+ && key.value < Joystick::KEY_POSITIVE_AXIS_FIRST)
+ {
+ // TRANSLATORS: joystick negative axis. must be short.
+ str = strprintf(_("JAxis%dMinus"),
+ key.value - Joystick::KEY_NEGATIVE_AXIS_FIRST);
+ }
+ else if (key.value >= Joystick::KEY_POSITIVE_AXIS_FIRST
+ && key.value < Joystick::KEY_END)
+ {
+ // TRANSLATORS: joystick positive axis. must be short.
+ str = strprintf(_("JAxis%dPlus"),
+ key.value - Joystick::KEY_POSITIVE_AXIS_FIRST);
+ }
}
if (!str.empty())
{
@@ -507,6 +521,20 @@ void InputManager::updateKeyString(const InputFunction &ki,
// TRANSLATORS: joystick right button. muse be very short
str = _("JRt");
}
+ else if (key.value >= Joystick::KEY_NEGATIVE_AXIS_FIRST
+ && key.value < Joystick::KEY_POSITIVE_AXIS_FIRST)
+ {
+ // TRANSLATORS: joystick negative axis. must be very short.
+ str = strprintf(_("JA%d-"),
+ key.value - Joystick::KEY_NEGATIVE_AXIS_FIRST);
+ }
+ else if (key.value >= Joystick::KEY_POSITIVE_AXIS_FIRST
+ && key.value < Joystick::KEY_END)
+ {
+ // TRANSLATORS: joystick positive axis. must be very short.
+ str = strprintf(_("JA%d+"),
+ key.value - Joystick::KEY_POSITIVE_AXIS_FIRST);
+ }
}
if (!str.empty())
{
@@ -697,10 +725,12 @@ bool InputManager::handleEvent(const SDL_Event &restrict event) restrict2
}
case SDL_JOYBUTTONDOWN:
case SDL_JOYHATMOTION:
+ case SDL_JOYAXISMOTION:
{
updateConditionMask(true);
// joystick.handleActicateButton(event);
- if (handleAssignKey(event, InputType::JOYSTICK))
+ if (joystick != nullptr && joystick->isActionEvent(event)
+ && handleAssignKey(event, InputType::JOYSTICK))
{
BLOCK_END("InputManager::handleEvent")
return true;
@@ -774,6 +804,7 @@ bool InputManager::handleEvent(const SDL_Event &restrict event) restrict2
case SDL_JOYBUTTONDOWN:
case SDL_JOYHATMOTION:
+ case SDL_JOYAXISMOTION:
if ((joystick != nullptr) && joystick->validate())
{
if (triggerAction(joystick->getActionVector(event)))