diff --git a/src/qt_gui/control_settings.cpp b/src/qt_gui/control_settings.cpp index 9f287ea60..34af98585 100644 --- a/src/qt_gui/control_settings.cpp +++ b/src/qt_gui/control_settings.cpp @@ -752,6 +752,8 @@ void ControlSettings::CheckMapping(QPushButton*& button) { button->setText(mapping); EnableButtonMapping = false; EnableAxisMapping = false; + L2Pressed = false; + R2Pressed = false; EnableMappingButtons(); timer->stop(); } @@ -844,20 +846,33 @@ void ControlSettings::processSDLEvents(int Type, int Input, int Value) { if (Type == SDL_EVENT_GAMEPAD_AXIS_MOTION) { // SDL trigger axis values range from 0 to 32000, set mapping on half movement // Set zone for trigger release signal arbitrarily at 5000 - if (Value > 16000) { - switch (Input) { - case SDL_GAMEPAD_AXIS_LEFT_TRIGGER: + switch (Input) { + case SDL_GAMEPAD_AXIS_LEFT_TRIGGER: + if (Value > 16000) { pressedButtons.insert("l2"); - break; - case SDL_GAMEPAD_AXIS_RIGHT_TRIGGER: - pressedButtons.insert("r2"); - break; - default: - break; + L2Pressed = true; + } else if (Value < 5000) { + if (L2Pressed) + emit PushGamepadEvent(); } + break; + case SDL_GAMEPAD_AXIS_RIGHT_TRIGGER: + if (Value > 16000) { + pressedButtons.insert("r2"); + R2Pressed = true; + } else if (Value < 5000) { + if (R2Pressed) + emit PushGamepadEvent(); + } + break; + default: + break; } } + if (Type == SDL_EVENT_GAMEPAD_BUTTON_UP) + emit PushGamepadEvent(); + } else if (EnableAxisMapping) { if (Type == SDL_EVENT_GAMEPAD_AXIS_MOTION) { // SDL stick axis values range from -32000 to 32000, set mapping on half movement diff --git a/src/qt_gui/control_settings.h b/src/qt_gui/control_settings.h index 925d12f62..c97a891a0 100644 --- a/src/qt_gui/control_settings.h +++ b/src/qt_gui/control_settings.h @@ -51,6 +51,8 @@ private: QSet pressedButtons; bool GameRunning; + bool L2Pressed = false; + bool R2Pressed = false; bool EnableButtonMapping = false; bool EnableAxisMapping = false; bool MappingCompleted = false;