Use signals on button/trigger to release to make GUI more responsive

This commit is contained in:
rainmakerv3 2025-06-24 22:54:03 +08:00
parent cd4931b16f
commit 86be802223
2 changed files with 26 additions and 9 deletions

View File

@ -752,6 +752,8 @@ void ControlSettings::CheckMapping(QPushButton*& button) {
button->setText(mapping);
EnableButtonMapping = false;
EnableAxisMapping = false;
L2Pressed = false;
R2Pressed = false;
EnableMappingButtons();
timer->stop();
}
@ -844,19 +846,32 @@ 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:
if (Value > 16000) {
pressedButtons.insert("l2");
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) {

View File

@ -51,6 +51,8 @@ private:
QSet<QString> pressedButtons;
bool GameRunning;
bool L2Pressed = false;
bool R2Pressed = false;
bool EnableButtonMapping = false;
bool EnableAxisMapping = false;
bool MappingCompleted = false;