Skip to content

Commit

Permalink
Fix issue 487 (OpenStickCommunity#658)
Browse files Browse the repository at this point in the history
* fix issue 487

Clean up some old code to get the hotkeys that were listed in issue 487 working correctly.

* Update gamepad.cpp
  • Loading branch information
NickGuyver authored Dec 9, 2023
1 parent 7072b7a commit 42012a3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 31 deletions.
4 changes: 2 additions & 2 deletions src/addons/keyboard_host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ void KeyboardHostAddon::process_kbd_report(uint8_t dev_addr, hid_keyboard_report
const GamepadOptions& gamepadOptions = Storage::getInstance().getGamepadOptions();

_keyboard_host_state.dpad |=
((keycode == _keyboard_host_mapDpadUp.key) ? (gamepadOptions.invertYAxis ? _keyboard_host_mapDpadDown.buttonMask : _keyboard_host_mapDpadUp.buttonMask) : _keyboard_host_state.dpad)
| ((keycode == _keyboard_host_mapDpadDown.key) ? (gamepadOptions.invertYAxis ? _keyboard_host_mapDpadUp.buttonMask : _keyboard_host_mapDpadDown.buttonMask) : _keyboard_host_state.dpad)
((keycode == _keyboard_host_mapDpadUp.key) ? _keyboard_host_mapDpadDown.buttonMask : _keyboard_host_state.dpad)
| ((keycode == _keyboard_host_mapDpadDown.key) ? _keyboard_host_mapDpadUp.buttonMask : _keyboard_host_state.dpad)
| ((keycode == _keyboard_host_mapDpadLeft.key) ? _keyboard_host_mapDpadLeft.buttonMask : _keyboard_host_state.dpad)
| ((keycode == _keyboard_host_mapDpadRight.key) ? _keyboard_host_mapDpadRight.buttonMask : _keyboard_host_state.dpad)
;
Expand Down
46 changes: 17 additions & 29 deletions src/gamepad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,41 +345,29 @@ void Gamepad::processHotkeyIfNewAction(GamepadHotkey action)
case HOTKEY_DPAD_DIGITAL : options.dpadMode = DPAD_MODE_DIGITAL; reqSave = true; break;
case HOTKEY_DPAD_LEFT_ANALOG : options.dpadMode = DPAD_MODE_LEFT_ANALOG; reqSave = true; break;
case HOTKEY_DPAD_RIGHT_ANALOG : options.dpadMode = DPAD_MODE_RIGHT_ANALOG; reqSave = true; break;
case HOTKEY_HOME_BUTTON : state.buttons |= GAMEPAD_MASK_A1; break; // Press the Home button
case HOTKEY_L3_BUTTON : state.buttons |= GAMEPAD_MASK_L3; break; // Press the L3 button
case HOTKEY_R3_BUTTON : state.buttons |= GAMEPAD_MASK_R3; break; // Press the R3 button
case HOTKEY_B1_BUTTON : state.buttons |= GAMEPAD_MASK_B1; break; // Press the L3 button
case HOTKEY_B2_BUTTON : state.buttons |= GAMEPAD_MASK_B2; break; // Press the R3 button
case HOTKEY_B3_BUTTON : state.buttons |= GAMEPAD_MASK_B3; break; // Press the L3 button
case HOTKEY_B4_BUTTON : state.buttons |= GAMEPAD_MASK_B4; break; // Press the R3 button
case HOTKEY_L1_BUTTON : state.buttons |= GAMEPAD_MASK_L1; break; // Press the L3 button
case HOTKEY_R1_BUTTON : state.buttons |= GAMEPAD_MASK_R1; break; // Press the L3 button
case HOTKEY_L2_BUTTON : state.buttons |= GAMEPAD_MASK_L2; break; // Press the R3 button
case HOTKEY_R2_BUTTON : state.buttons |= GAMEPAD_MASK_R2; break; // Press the R3 button
case HOTKEY_S1_BUTTON : state.buttons |= GAMEPAD_MASK_S1; break; // Press the L3 button
case HOTKEY_S2_BUTTON : state.buttons |= GAMEPAD_MASK_S2; break; // Press the R3 button
case HOTKEY_A1_BUTTON : state.buttons |= GAMEPAD_MASK_A1; break; // Press the L3 button
case HOTKEY_A2_BUTTON : state.buttons |= GAMEPAD_MASK_A2; break; // Press the R3 button
case HOTKEY_HOME_BUTTON : state.buttons |= GAMEPAD_MASK_A1; break;
case HOTKEY_L3_BUTTON : state.buttons |= GAMEPAD_MASK_L3; break;
case HOTKEY_R3_BUTTON : state.buttons |= GAMEPAD_MASK_R3; break;
case HOTKEY_B1_BUTTON : state.buttons |= GAMEPAD_MASK_B1; break;
case HOTKEY_B2_BUTTON : state.buttons |= GAMEPAD_MASK_B2; break;
case HOTKEY_B3_BUTTON : state.buttons |= GAMEPAD_MASK_B3; break;
case HOTKEY_B4_BUTTON : state.buttons |= GAMEPAD_MASK_B4; break;
case HOTKEY_L1_BUTTON : state.buttons |= GAMEPAD_MASK_L1; break;
case HOTKEY_R1_BUTTON : state.buttons |= GAMEPAD_MASK_R1; break;
case HOTKEY_L2_BUTTON : state.buttons |= GAMEPAD_MASK_L2; break;
case HOTKEY_R2_BUTTON : state.buttons |= GAMEPAD_MASK_R2; break;
case HOTKEY_S1_BUTTON : state.buttons |= GAMEPAD_MASK_S1; break;
case HOTKEY_S2_BUTTON : state.buttons |= GAMEPAD_MASK_S2; break;
case HOTKEY_A1_BUTTON : state.buttons |= GAMEPAD_MASK_A1; break;
case HOTKEY_A2_BUTTON : state.buttons |= GAMEPAD_MASK_A2; break;
case HOTKEY_SOCD_UP_PRIORITY : options.socdMode = SOCD_MODE_UP_PRIORITY; reqSave = true; break;
case HOTKEY_SOCD_NEUTRAL : options.socdMode = SOCD_MODE_NEUTRAL; reqSave = true; break;
case HOTKEY_SOCD_LAST_INPUT : options.socdMode = SOCD_MODE_SECOND_INPUT_PRIORITY; reqSave = true; break;
case HOTKEY_SOCD_FIRST_INPUT : options.socdMode = SOCD_MODE_FIRST_INPUT_PRIORITY; reqSave = true;break;
case HOTKEY_SOCD_BYPASS : options.socdMode = SOCD_MODE_BYPASS; reqSave = true; break;
case HOTKEY_REBOOT_DEFAULT : System::reboot(System::BootMode::DEFAULT); break;
case HOTKEY_CAPTURE_BUTTON :
if (options.inputMode == INPUT_MODE_PS4 && options.switchTpShareForDs4) {
state.buttons |= GAMEPAD_MASK_A2;
} else {
state.buttons |= GAMEPAD_MASK_S1;
}
break;
case HOTKEY_TOUCHPAD_BUTTON :
if (options.inputMode == INPUT_MODE_PS4) {
state.buttons |= GAMEPAD_MASK_A2;
} else {
state.buttons |= GAMEPAD_MASK_S1;
}
break;
case HOTKEY_CAPTURE_BUTTON : state.buttons |= GAMEPAD_MASK_A2; break;
case HOTKEY_TOUCHPAD_BUTTON : state.buttons |= GAMEPAD_MASK_A2; break;
case HOTKEY_INVERT_X_AXIS :
if (action != lastAction) {
options.invertXAxis = !options.invertXAxis;
Expand Down

0 comments on commit 42012a3

Please sign in to comment.