summaryrefslogtreecommitdiff
path: root/src/input/inputmanager.cpp
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/inputmanager.cpp
parent0ff6869e745b4a0174ab1ee116ba5d6ad08e4812 (diff)
downloadmanaverse-842b7fd4db44d85308afbb401023429621d9c586.tar.gz
manaverse-842b7fd4db44d85308afbb401023429621d9c586.tar.bz2
manaverse-842b7fd4db44d85308afbb401023429621d9c586.tar.xz
manaverse-842b7fd4db44d85308afbb401023429621d9c586.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 ac5325e3b..fc2815b5e 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. must 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)))