1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-27 22:49:25 +02:00

key name capture

This commit is contained in:
Laserlicht
2025-07-19 13:09:15 +02:00
parent 6e61cb0cf3
commit 21df285e5a
10 changed files with 67 additions and 10 deletions

View File

@@ -140,12 +140,13 @@ double InputSourceGameController::getRealAxisValue(int value) const
return clampedValue;
}
void InputSourceGameController::dispatchAxisShortcuts(const std::vector<EShortcut> & shortcutsVector, SDL_GameControllerAxis axisID, int axisValue)
void InputSourceGameController::dispatchAxisShortcuts(const std::vector<EShortcut> & shortcutsVector, SDL_GameControllerAxis axisID, int axisValue, std::string axisName)
{
if(getRealAxisValue(axisValue) > configTriggerThreshold)
{
if(!pressedAxes.count(axisID))
{
ENGINE->events().dispatchKeyPressed(axisName);
ENGINE->events().dispatchShortcutPressed(shortcutsVector);
pressedAxes.insert(axisID);
}
@@ -154,6 +155,7 @@ void InputSourceGameController::dispatchAxisShortcuts(const std::vector<EShortcu
{
if(pressedAxes.count(axisID))
{
ENGINE->events().dispatchKeyReleased(axisName);
ENGINE->events().dispatchShortcutReleased(shortcutsVector);
pressedAxes.erase(axisID);
}
@@ -189,7 +191,7 @@ void InputSourceGameController::handleEventAxisMotion(const SDL_ControllerAxisEv
}
}
dispatchAxisShortcuts(buttonActions, axisID, axis.value);
dispatchAxisShortcuts(buttonActions, axisID, axis.value, axisName);
}
void InputSourceGameController::tryToConvertCursor()
@@ -208,6 +210,8 @@ void InputSourceGameController::handleEventButtonDown(const SDL_ControllerButton
{
std::string buttonName = SDL_GameControllerGetStringForButton(static_cast<SDL_GameControllerButton>(button.button));
const auto & shortcutsVector = ENGINE->shortcuts().translateJoystickButton(buttonName);
ENGINE->events().dispatchKeyPressed(buttonName);
ENGINE->events().dispatchShortcutPressed(shortcutsVector);
}
@@ -215,6 +219,7 @@ void InputSourceGameController::handleEventButtonUp(const SDL_ControllerButtonEv
{
std::string buttonName = SDL_GameControllerGetStringForButton(static_cast<SDL_GameControllerButton>(button.button));
const auto & shortcutsVector = ENGINE->shortcuts().translateJoystickButton(buttonName);
ENGINE->events().dispatchKeyReleased(buttonName);
ENGINE->events().dispatchShortcutReleased(shortcutsVector);
}