diff --git a/headers/gamepad/GamepadOptions.h b/headers/gamepad/GamepadOptions.h index c2d7d4a68..5749e7a96 100644 --- a/headers/gamepad/GamepadOptions.h +++ b/headers/gamepad/GamepadOptions.h @@ -50,5 +50,7 @@ struct GamepadOptions GamepadHotkeyEntry hotkeyF2Left; GamepadHotkeyEntry hotkeyF2Right; + bool switchTpShareForDs4; + uint32_t checksum; }; diff --git a/src/configs/webconfig.cpp b/src/configs/webconfig.cpp index f43c5b379..7cd4aa418 100644 --- a/src/configs/webconfig.cpp +++ b/src/configs/webconfig.cpp @@ -390,6 +390,7 @@ std::string setGamepadOptions() readDoc(gamepad->options.dpadMode, doc, "dpadMode"); readDoc(gamepad->options.inputMode, doc, "inputMode"); readDoc(gamepad->options.socdMode, doc, "socdMode"); + readDoc(gamepad->options.switchTpShareForDs4, doc, "switchTpShareForDs4"); readDoc(gamepad->options.hotkeyF1Up.action, doc, "hotkeyF1", 0, "action"); readDoc(gamepad->options.hotkeyF1Down.action, doc, "hotkeyF1", 1, "action"); @@ -413,6 +414,7 @@ std::string getGamepadOptions() writeDoc(doc, "dpadMode", options.dpadMode); writeDoc(doc, "inputMode", options.inputMode); writeDoc(doc, "socdMode", options.socdMode); + writeDoc(doc, "switchTpShareForDs4", options.switchTpShareForDs4); writeDoc(doc, "hotkeyF1", 0, "action", options.hotkeyF1Up.action); writeDoc(doc, "hotkeyF1", 0, "mask", options.hotkeyF1Up.dpadMask); diff --git a/src/gamepad.cpp b/src/gamepad.cpp index 579d12553..3588e231b 100644 --- a/src/gamepad.cpp +++ b/src/gamepad.cpp @@ -102,12 +102,18 @@ void Gamepad::setup() mapButtonR1 = new GamepadButtonMapping(boardOptions.pinButtonR1, GAMEPAD_MASK_R1); mapButtonL2 = new GamepadButtonMapping(boardOptions.pinButtonL2, GAMEPAD_MASK_L2); mapButtonR2 = new GamepadButtonMapping(boardOptions.pinButtonR2, GAMEPAD_MASK_R2); - mapButtonS1 = new GamepadButtonMapping(boardOptions.pinButtonS1, GAMEPAD_MASK_S1); mapButtonS2 = new GamepadButtonMapping(boardOptions.pinButtonS2, GAMEPAD_MASK_S2); mapButtonL3 = new GamepadButtonMapping(boardOptions.pinButtonL3, GAMEPAD_MASK_L3); mapButtonR3 = new GamepadButtonMapping(boardOptions.pinButtonR3, GAMEPAD_MASK_R3); mapButtonA1 = new GamepadButtonMapping(boardOptions.pinButtonA1, GAMEPAD_MASK_A1); - mapButtonA2 = new GamepadButtonMapping(boardOptions.pinButtonA2, GAMEPAD_MASK_A2); + + uint16_t maskS1 = options.inputMode == INPUT_MODE_PS4 + && options.switchTpShareForDs4 ? GAMEPAD_MASK_A2 : GAMEPAD_MASK_S1; + mapButtonS1 = new GamepadButtonMapping(boardOptions.pinButtonS1, maskS1); + + uint16_t maskA2 = options.inputMode == INPUT_MODE_PS4 + && options.switchTpShareForDs4 ? GAMEPAD_MASK_S1 : GAMEPAD_MASK_A2; + mapButtonA2 = new GamepadButtonMapping(boardOptions.pinButtonA2, maskA2); gamepadMappings = new GamepadButtonMapping *[GAMEPAD_DIGITAL_INPUT_COUNT] { diff --git a/www/server/app.js b/www/server/app.js index e24b6f37d..40985c20e 100644 --- a/www/server/app.js +++ b/www/server/app.js @@ -79,6 +79,7 @@ app.get("/api/getGamepadOptions", (req, res) => { dpadMode: 0, inputMode: 1, socdMode: 2, + switchTpShareForDs4: 0, hotkeyF1: [ { action: 1, mask: 1<<0 }, { action: 2, mask: 1<<1 }, diff --git a/www/src/Pages/SettingsPage.js b/www/src/Pages/SettingsPage.js index 557479e1c..8a691eb29 100644 --- a/www/src/Pages/SettingsPage.js +++ b/www/src/Pages/SettingsPage.js @@ -8,12 +8,13 @@ import Section from '../Components/Section'; import WebApi from '../Services/WebApi'; import BUTTONS from '../Data/Buttons.json'; +const PS4Mode = 4; const INPUT_MODES = [ { label: 'XInput', value: 0 }, { label: 'Nintendo Switch', value: 1 }, { label: 'PS3/DirectInput', value: 2 }, { label: 'Keyboard', value: 3 }, - { label: 'PS4', value: 4 } + { label: 'PS4', value: PS4Mode } ]; const DPAD_MODES = [ @@ -65,6 +66,7 @@ const schema = yup.object().shape({ })), inputMode: yup.number().required().oneOf(INPUT_MODES.map(o => o.value)).label('Input Mode'), socdMode : yup.number().required().oneOf(SOCD_MODES.map(o => o.value)).label('SOCD Cleaning Mode'), + switchTpShareForDs4: yup.number().required().label('Switch Touchpad and Share'), }); const FormContext = () => { @@ -84,6 +86,8 @@ const FormContext = () => { values.inputMode = parseInt(values.inputMode); if (!!values.socdMode) values.socdMode = parseInt(values.socdMode); + if (!!values.switchTpShareForDs4) + values.switchTpShareForDs4 = parseInt(values.switchTpShareForDs4); values.hotkeyF1 = values.hotkeyF1?.map( i => ({ action: parseInt(i.action), mask: parseInt(i.mask) @@ -113,6 +117,7 @@ export default function SettingsPage() { handleChange, values, errors, + setFieldValue }) => console.log('errors', errors) || (
@@ -125,6 +130,16 @@ export default function SettingsPage() { {errors.inputMode}
+
+ {values.inputMode === PS4Mode && { setFieldValue("switchTpShareForDs4", e.target.checked ? 1 : 0); }} + />} +
D-Pad Mode @@ -132,7 +147,7 @@ export default function SettingsPage() { {DPAD_MODES.map((o, i) => )} - {errors.dpadMode} + {errors.dpadMode}