summaryrefslogtreecommitdiff
path: root/src/input/inputmanager.cpp
diff options
context:
space:
mode:
authorewewukek <ewewukek@gmail.com>2024-01-11 12:53:19 +0300
committerFedja Beader <fedja@protonmail.ch>2024-05-15 00:11:33 +0200
commita9b4edd10420fb35679ee9aac3caa9eb8f35e6dd (patch)
tree9cb3630b5514bda7c3cc83f2a1e6276e34b948b8 /src/input/inputmanager.cpp
parent84a11a02aad86d9388175c7fd0971accdb586473 (diff)
downloadManaVerse-a9b4edd10420fb35679ee9aac3caa9eb8f35e6dd.tar.gz
ManaVerse-a9b4edd10420fb35679ee9aac3caa9eb8f35e6dd.tar.bz2
ManaVerse-a9b4edd10420fb35679ee9aac3caa9eb8f35e6dd.tar.xz
ManaVerse-a9b4edd10420fb35679ee9aac3caa9eb8f35e6dd.zip
Make D-Pad behave like regular buttons
Diffstat (limited to 'src/input/inputmanager.cpp')
-rw-r--r--src/input/inputmanager.cpp56
1 files changed, 52 insertions, 4 deletions
diff --git a/src/input/inputmanager.cpp b/src/input/inputmanager.cpp
index a379e0e86..0a113bd76 100644
--- a/src/input/inputmanager.cpp
+++ b/src/input/inputmanager.cpp
@@ -416,8 +416,31 @@ std::string InputManager::getKeyStringLong(const InputActionT index) const
}
else if (key.type == InputType::JOYSTICK)
{
- // TRANSLATORS: long joystick button name. must be short.
- str = strprintf(_("JButton%d"), key.value + 1);
+ if (key.value < Joystick::MAX_BUTTONS)
+ {
+ // TRANSLATORS: joystick button name. must be short.
+ str = strprintf(_("JButton%d"), key.value + 1);
+ }
+ else if (key.value == Joystick::KEY_UP)
+ {
+ // TRANSLATORS: joystick up button. must be short.
+ str = _("JUp");
+ }
+ else if (key.value == Joystick::KEY_DOWN)
+ {
+ // TRANSLATORS: joystick down button. must be short.
+ str = _("JDown");
+ }
+ else if (key.value == Joystick::KEY_LEFT)
+ {
+ // TRANSLATORS: joystick left button. must be short.
+ str = _("JLeft");
+ }
+ else if (key.value == Joystick::KEY_RIGHT)
+ {
+ // TRANSLATORS: joystick right button. must be short.
+ str = _("JRight");
+ }
}
if (!str.empty())
{
@@ -459,8 +482,31 @@ void InputManager::updateKeyString(const InputFunction &ki,
}
else if (key.type == InputType::JOYSTICK)
{
- // TRANSLATORS: short joystick button name. muse be very short
- str = strprintf(_("JB%d"), key.value + 1);
+ if (key.value < Joystick::MAX_BUTTONS)
+ {
+ // TRANSLATORS: joystick button name. must be very short
+ str = strprintf(_("JB%d"), key.value + 1);
+ }
+ else if (key.value == Joystick::KEY_UP)
+ {
+ // TRANSLATORS: joystick up button. must be very short
+ str = _("JUp");
+ }
+ else if (key.value == Joystick::KEY_DOWN)
+ {
+ // TRANSLATORS: joystick down button. must be very short
+ str = _("JDn");
+ }
+ else if (key.value == Joystick::KEY_LEFT)
+ {
+ // TRANSLATORS: joystick left button. must be very short
+ str = _("JLt");
+ }
+ else if (key.value == Joystick::KEY_RIGHT)
+ {
+ // TRANSLATORS: joystick right button. must be very short
+ str = _("JRt");
+ }
}
if (!str.empty())
{
@@ -650,6 +696,7 @@ bool InputManager::handleEvent(const SDL_Event &restrict event) restrict2
break;
}
case SDL_JOYBUTTONDOWN:
+ case SDL_JOYHATMOTION:
{
updateConditionMask(true);
// joystick.handleActicateButton(event);
@@ -724,6 +771,7 @@ bool InputManager::handleEvent(const SDL_Event &restrict event) restrict2
// break;
case SDL_JOYBUTTONDOWN:
+ case SDL_JOYHATMOTION:
if ((joystick != nullptr) && joystick->validate())
{
if (triggerAction(joystick->getActionVector(event)))