Skip to content

Commit

Permalink
Fix button labels and hotkey when Touchpad Share are swapped (#317)
Browse files Browse the repository at this point in the history
* Fix Hotkey when Touchpad and Share are swapped in PS4 Mode

When the Touchpad and Share buttons are swapped in PS4 Mode, Hotkey F1 will be the Touchpad button, and Start will not be the Option button, but the Start button.

* Fix button label when touchpad and share swapped in ps4 mode

When selecting button label is not the PS4 button label, the button label may be different.

* Fix button label when touchpad and share swapped in ps4 mode

When selecting button label is not the PS4 button label, the button label may be different.

* Fix button label when touchpad and share swapped in ps4 mode

When selecting button label is not the PS4 button label, the button label may be different.

* Fix button label when touchpad and share swapped in ps4 mode

When selecting button label is not the PS4 button label, the button label may be different.

* Fix WebConfig button label when touchpad and share swapped in ps4 mode

When selecting button label is not the PS4 button label, the button label may be different.
  • Loading branch information
teikai1216 authored Jun 12, 2023
1 parent 8d04c77 commit 9bb4bca
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
5 changes: 4 additions & 1 deletion src/gamepad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ void Gamepad::setup()
mapButtonR3 = new GamepadButtonMapping(convertPin(pinMappings.pinButtonR3), GAMEPAD_MASK_R3);
mapButtonA1 = new GamepadButtonMapping(convertPin(pinMappings.pinButtonA1), GAMEPAD_MASK_A1);
mapButtonA2 = new GamepadButtonMapping(convertPin(pinMappings.pinButtonA2), GAMEPAD_MASK_A2);


if(options.inputMode == INPUT_MODE_PS4 && options.switchTpShareForDs4)
f1Mask = GAMEPAD_MASK_A2 | GAMEPAD_MASK_S2;

uint16_t maskS1 = options.inputMode == INPUT_MODE_PS4
&& options.switchTpShareForDs4 ? GAMEPAD_MASK_A2 : GAMEPAD_MASK_S1;
mapButtonS1 = new GamepadButtonMapping(pinMappings.pinButtonS1, maskS1);
Expand Down
4 changes: 2 additions & 2 deletions www/src/Pages/KeyboardMapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,10 @@ export default function KeyboardMappingPage() {
<tbody>
{Object.keys(BUTTONS[buttonLabelType])?.filter(p => p !== 'label' && p !== 'value').map((button, i) => {
let label = BUTTONS[buttonLabelType][button];
if (button === "S1" && swapTpShareLabels) {
if (button === "S1" && swapTpShareLabels && buttonLabelType === "ps4") {
label = BUTTONS[buttonLabelType]["A2"];
}
if (button === "A2" && swapTpShareLabels) {
if (button === "A2" && swapTpShareLabels && buttonLabelType === "ps4") {
label = BUTTONS[buttonLabelType]["S1"];
}
return <tr key={`button-map-${i}`} className={validated && !!keyMappings[button].error ? "table-danger" : ""}>
Expand Down
4 changes: 2 additions & 2 deletions www/src/Pages/LEDConfigPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ const getLedButtons = (buttonLabels, map, excludeNulls, swapTpShareLabels) => {
.filter(p => excludeNulls ? map[p] > -1 : true)
.map(p => {
let label = BUTTONS[buttonLabels][p];
if (p === "S1" && swapTpShareLabels) {
if (p === "S1" && swapTpShareLabels && buttonLabels === "ps4") {
label = BUTTONS[buttonLabels]["A2"];
}
if (p === "A2" && swapTpShareLabels) {
if (p === "A2" && swapTpShareLabels && buttonLabels === "ps4") {
label = BUTTONS[buttonLabels]["S1"];
}
return ({ id: p, label: BUTTONS[buttonLabels][p], value: map[p] });
Expand Down
4 changes: 2 additions & 2 deletions www/src/Pages/PinMapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@ export default function PinMappingPage() {
<tbody>
{Object.keys(BUTTONS[buttonLabelType])?.filter(p => p !== 'label' && p !== 'value').map((button, i) => {
let label = BUTTONS[buttonLabelType][button];
if (button === "S1" && swapTpShareLabels) {
if (button === "S1" && swapTpShareLabels && buttonLabelType === "ps4") {
label = BUTTONS[buttonLabelType]["A2"];
}
if (button === "A2" && swapTpShareLabels) {
if (button === "A2" && swapTpShareLabels && buttonLabelType === "ps4") {
label = BUTTONS[buttonLabelType]["S1"];
}
return <tr key={`button-map-${i}`} className={validated && !!buttonMappings[button].error ? "table-danger" : ""}>
Expand Down
2 changes: 1 addition & 1 deletion www/src/Pages/SettingsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export default function SettingsPage() {

const { buttonLabelType, swapTpShareLabels } = buttonLabels;

const buttonLabelS1 = BUTTONS[buttonLabelType][swapTpShareLabels ? "A2" : "S1"];
const buttonLabelS1 = BUTTONS[buttonLabelType][(swapTpShareLabels && buttonLabelType === "ps4") ? "A2" : "S1"];
const buttonLabelS2 = BUTTONS[buttonLabelType]["S2"];
const buttonLabelA1 = BUTTONS[buttonLabelType]["A1"];

Expand Down

0 comments on commit 9bb4bca

Please sign in to comment.