Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding hotkey options for l3, r3 and touchpad buttons #430

Merged
merged 3 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions proto/enums.proto
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ enum GamepadHotkey
HOTKEY_SOCD_BYPASS = 12;
HOTKEY_TOGGLE_4_WAY_MODE = 13;
HOTKEY_TOGGLE_DDI_4_WAY_MODE = 14;
HOTKEY_L3_BUTTON = 15;
HOTKEY_R3_BUTTON = 16;
HOTKEY_TOUCHPAD_BUTTON = 17;
}

// This has to be kept in sync with LEDFormat in NeoPico.hpp
Expand Down
6 changes: 6 additions & 0 deletions src/config_legacy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ namespace ConfigLegacy
HOTKEY_INVERT_Y_AXIS,
HOTKEY_SOCD_FIRST_INPUT,
HOTKEY_SOCD_BYPASS,
HOTKEY_L3_BUTTON,
HOTKEY_R3_BUTTON,
HOTKEY_TOUCHPAD_BUTTON,
};

enum OnBoardLedMode
Expand Down Expand Up @@ -525,6 +528,9 @@ static bool isValidGamepadHotkey(ConfigLegacy::GamepadHotkey hotkey)
case HOTKEY_INVERT_Y_AXIS:
case HOTKEY_SOCD_FIRST_INPUT:
case HOTKEY_SOCD_BYPASS:
case HOTKEY_L3_BUTTON:
case HOTKEY_R3_BUTTON:
case HOTKEY_TOUCHPAD_BUTTON:
return true;
}
return false;
Expand Down
9 changes: 9 additions & 0 deletions src/gamepad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ void Gamepad::processHotkeyIfNewAction(GamepadHotkey action)
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_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;
Expand All @@ -307,6 +309,13 @@ void Gamepad::processHotkeyIfNewAction(GamepadHotkey action)
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_INVERT_X_AXIS :
if (action != lastAction) {
options.invertXAxis = !options.invertXAxis;
Expand Down
3 changes: 3 additions & 0 deletions www/src/Locales/en/SettingsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ export default {
'invert-y': 'Invert Y Axis',
'toggle-4way-joystick-mode': 'Toggle 4-Way Joystick Mode',
'toggle-ddi-4way-joystick-mode': 'Toggle DDI 4-Way Joystick Mode',
'l3-button': 'L3 Button',
'r3-button': 'R3 Button',
'touchpad-button': 'Touchpad Button',
},
'forced-setup-mode-label': 'Forced Setup Mode',
'forced-setup-mode-options': {
Expand Down
3 changes: 3 additions & 0 deletions www/src/Pages/SettingsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ const HOTKEY_ACTIONS = [
{ labelKey: 'hotkey-actions.invert-y', value: 10 },
{ labelKey: 'hotkey-actions.toggle-4way-joystick-mode', value: 13 },
{ labelKey: 'hotkey-actions.toggle-ddi-4way-joystick-mode', value: 14 },
{ labelKey: 'hotkey-actions.l3-button', value: 15 },
{ labelKey: 'hotkey-actions.r3-button', value: 16 },
{ labelKey: 'hotkey-actions.touchpad-button', value: 17 },
];

const FORCED_SETUP_MODES = [
Expand Down