diff --git a/configs/BentoBox/BoardConfig.h b/configs/BentoBox/BoardConfig.h index 8d62ed33e..1dbee82bc 100644 --- a/configs/BentoBox/BoardConfig.h +++ b/configs/BentoBox/BoardConfig.h @@ -56,6 +56,8 @@ #define SLIDER_SOCD_SLOT_TWO SOCD_MODE_SECOND_INPUT_PRIORITY #define SLIDER_SOCD_SLOT_DEFAULT SOCD_MODE_NEUTRAL +#define DEFAULT_FORCED_SETUP_MODE FORCED_SETUP_MODE_OFF // FORCED_SETUP_MODE_OFF, FORCED_SETUP_MODE_LOCK_MODE_SWITCH, FORCED_SETUP_MODE_LOCK_WEB_CONFIG, FORCED_SETUP_MODE_LOCK_BOTH +#define DEFAULT_LOCK_HOTKEYS false // or true // This is the LEDs section. // The default `TURBO_LED_PIN` pin is set to `15` ( it is recommended to run through 3V3(OUT) with a resistor) diff --git a/configs/DURAL/BoardConfig.h b/configs/DURAL/BoardConfig.h index 64ec68898..62e4b701c 100644 --- a/configs/DURAL/BoardConfig.h +++ b/configs/DURAL/BoardConfig.h @@ -56,6 +56,8 @@ #define SLIDER_SOCD_SLOT_TWO SOCD_MODE_SECOND_INPUT_PRIORITY #define SLIDER_SOCD_SLOT_DEFAULT SOCD_MODE_NEUTRAL +#define DEFAULT_FORCED_SETUP_MODE FORCED_SETUP_MODE_OFF // FORCED_SETUP_MODE_OFF, FORCED_SETUP_MODE_LOCK_MODE_SWITCH, FORCED_SETUP_MODE_LOCK_WEB_CONFIG, FORCED_SETUP_MODE_LOCK_BOTH +#define DEFAULT_LOCK_HOTKEYS false // or true // This is the LEDs section. // The default `TURBO_LED_PIN` pin is set to `15` ( it is recommended to run through 3V3(OUT) with a resistor) diff --git a/configs/FightboardV3/BoardConfig.h b/configs/FightboardV3/BoardConfig.h index f76f06d1c..f4f53418b 100644 --- a/configs/FightboardV3/BoardConfig.h +++ b/configs/FightboardV3/BoardConfig.h @@ -57,6 +57,8 @@ #define SLIDER_SOCD_SLOT_TWO SOCD_MODE_SECOND_INPUT_PRIORITY #define SLIDER_SOCD_SLOT_DEFAULT SOCD_MODE_NEUTRAL +#define DEFAULT_FORCED_SETUP_MODE FORCED_SETUP_MODE_OFF // FORCED_SETUP_MODE_OFF, FORCED_SETUP_MODE_LOCK_MODE_SWITCH, FORCED_SETUP_MODE_LOCK_WEB_CONFIG, FORCED_SETUP_MODE_LOCK_BOTH +#define DEFAULT_LOCK_HOTKEYS false // or true // This is the LEDs section. // The default `TURBO_LED_PIN` pin is set to `15` ( it is recommended to run through 3V3(OUT) with a resistor) diff --git a/configs/FightboardV3Mirrored/BoardConfig.h b/configs/FightboardV3Mirrored/BoardConfig.h index f9dd3c3aa..f0c88a195 100644 --- a/configs/FightboardV3Mirrored/BoardConfig.h +++ b/configs/FightboardV3Mirrored/BoardConfig.h @@ -57,6 +57,8 @@ #define SLIDER_SOCD_SLOT_TWO SOCD_MODE_SECOND_INPUT_PRIORITY #define SLIDER_SOCD_SLOT_DEFAULT SOCD_MODE_NEUTRAL +#define DEFAULT_FORCED_SETUP_MODE FORCED_SETUP_MODE_OFF // FORCED_SETUP_MODE_OFF, FORCED_SETUP_MODE_LOCK_MODE_SWITCH, FORCED_SETUP_MODE_LOCK_WEB_CONFIG, FORCED_SETUP_MODE_LOCK_BOTH +#define DEFAULT_LOCK_HOTKEYS false // or true // This is the LEDs section. // The default `TURBO_LED_PIN` pin is set to `15` ( it is recommended to run through 3V3(OUT) with a resistor) diff --git a/configs/FlatboxRev4/BoardConfig.h b/configs/FlatboxRev4/BoardConfig.h index 9184db6b2..1177d4e5e 100644 --- a/configs/FlatboxRev4/BoardConfig.h +++ b/configs/FlatboxRev4/BoardConfig.h @@ -78,6 +78,8 @@ #define SLIDER_SOCD_SLOT_TWO SOCD_MODE_SECOND_INPUT_PRIORITY #define SLIDER_SOCD_SLOT_DEFAULT SOCD_MODE_NEUTRAL +#define DEFAULT_FORCED_SETUP_MODE FORCED_SETUP_MODE_OFF // FORCED_SETUP_MODE_OFF, FORCED_SETUP_MODE_LOCK_MODE_SWITCH, FORCED_SETUP_MODE_LOCK_WEB_CONFIG, FORCED_SETUP_MODE_LOCK_BOTH +#define DEFAULT_LOCK_HOTKEYS false // or true // This is the LEDs section. // The default `TURBO_LED_PIN` pin is set to `15` ( it is recommended to run through 3V3(OUT) with a resistor) diff --git a/configs/FlatboxRev5/BoardConfig.h b/configs/FlatboxRev5/BoardConfig.h index 71b10c2d0..49c08faa7 100644 --- a/configs/FlatboxRev5/BoardConfig.h +++ b/configs/FlatboxRev5/BoardConfig.h @@ -78,6 +78,8 @@ #define SLIDER_SOCD_SLOT_TWO SOCD_MODE_SECOND_INPUT_PRIORITY #define SLIDER_SOCD_SLOT_DEFAULT SOCD_MODE_NEUTRAL +#define DEFAULT_FORCED_SETUP_MODE FORCED_SETUP_MODE_OFF // FORCED_SETUP_MODE_OFF, FORCED_SETUP_MODE_LOCK_MODE_SWITCH, FORCED_SETUP_MODE_LOCK_WEB_CONFIG, FORCED_SETUP_MODE_LOCK_BOTH +#define DEFAULT_LOCK_HOTKEYS false // or true // This is the LEDs section. // The default `TURBO_LED_PIN` pin is set to `15` ( it is recommended to run through 3V3(OUT) with a resistor) diff --git a/configs/KB2040/BoardConfig.h b/configs/KB2040/BoardConfig.h index 3590520c7..0209bc9e4 100644 --- a/configs/KB2040/BoardConfig.h +++ b/configs/KB2040/BoardConfig.h @@ -55,10 +55,13 @@ #define SLIDER_SOCD_SLOT_TWO SOCD_MODE_SECOND_INPUT_PRIORITY #define SLIDER_SOCD_SLOT_DEFAULT SOCD_MODE_NEUTRAL +#define DEFAULT_FORCED_SETUP_MODE FORCED_SETUP_MODE_OFF // FORCED_SETUP_MODE_OFF, FORCED_SETUP_MODE_LOCK_MODE_SWITCH, FORCED_SETUP_MODE_LOCK_WEB_CONFIG, FORCED_SETUP_MODE_LOCK_BOTH +#define DEFAULT_LOCK_HOTKEYS false // or true #define DEFAULT_INPUT_MODE INPUT_MODE_XINPUT //INPUT_MODE_XINPUT (XInput), INPUT_MODE_SWITCH (Nintendo Switch), INPUT_MODE_HID (D-Input), INPUT_MODE_KEYBOARD (Keyboard) #define DEFAULT_DPAD_MODE DPAD_MODE_DIGITAL //DPAD_MODE_DIGITAL, DPAD_MODE_LEFT_ANALOG, DPAD_MODE_RIGHT_ANALOG, -// This is the LEDs section. +#define DEFAULT_FORCED_SETUP_MODE FORCED_SETUP_MODE_OFF +#define DEFAULT_LOCK_HOTKEYS false// This is the LEDs section. // The default `TURBO_LED_PIN` pin is set to `15` ( it is recommended to run through 3V3(OUT) with a resistor) // The Turbo LED will flash at a speed consistant with the set speed of the Turbo when a Turbo button is active. // It is recommended to disable the `TURBO_LED_PIN` by setting it to `-1` if you are sensitive of flashing lights. diff --git a/configs/MavercadeKeebfighter/BoardConfig.h b/configs/MavercadeKeebfighter/BoardConfig.h index 534851b24..a0caaed27 100644 --- a/configs/MavercadeKeebfighter/BoardConfig.h +++ b/configs/MavercadeKeebfighter/BoardConfig.h @@ -78,6 +78,8 @@ #define SLIDER_SOCD_SLOT_TWO SOCD_MODE_SECOND_INPUT_PRIORITY #define SLIDER_SOCD_SLOT_DEFAULT SOCD_MODE_NEUTRAL +#define DEFAULT_FORCED_SETUP_MODE FORCED_SETUP_MODE_OFF // FORCED_SETUP_MODE_OFF, FORCED_SETUP_MODE_LOCK_MODE_SWITCH, FORCED_SETUP_MODE_LOCK_WEB_CONFIG, FORCED_SETUP_MODE_LOCK_BOTH +#define DEFAULT_LOCK_HOTKEYS false // or true // This is the LEDs section. // The default `TURBO_LED_PIN` pin is set to `15` ( it is recommended to run through 3V3(OUT) with a resistor) diff --git a/configs/Pico/BoardConfig.h b/configs/Pico/BoardConfig.h index d5dbb641a..698b20bee 100644 --- a/configs/Pico/BoardConfig.h +++ b/configs/Pico/BoardConfig.h @@ -55,6 +55,9 @@ #define SLIDER_SOCD_SLOT_TWO SOCD_MODE_SECOND_INPUT_PRIORITY #define SLIDER_SOCD_SLOT_DEFAULT SOCD_MODE_NEUTRAL +#define DEFAULT_FORCED_SETUP_MODE FORCED_SETUP_MODE_OFF // FORCED_SETUP_MODE_OFF, FORCED_SETUP_MODE_LOCK_MODE_SWITCH, FORCED_SETUP_MODE_LOCK_WEB_CONFIG, FORCED_SETUP_MODE_LOCK_BOTH +#define DEFAULT_LOCK_HOTKEYS false // or true + #define DEFAULT_INPUT_MODE INPUT_MODE_XINPUT //INPUT_MODE_XINPUT (XInput), INPUT_MODE_SWITCH (Nintendo Switch), INPUT_MODE_HID (D-Input), INPUT_MODE_KEYBOARD (Keyboard) #define DEFAULT_DPAD_MODE DPAD_MODE_DIGITAL //DPAD_MODE_DIGITAL, DPAD_MODE_LEFT_ANALOG, DPAD_MODE_RIGHT_ANALOG, diff --git a/configs/PicoAnn/BoardConfig.h b/configs/PicoAnn/BoardConfig.h index 248da6c8d..19770c1f0 100644 --- a/configs/PicoAnn/BoardConfig.h +++ b/configs/PicoAnn/BoardConfig.h @@ -56,6 +56,8 @@ #define SLIDER_SOCD_SLOT_TWO SOCD_MODE_SECOND_INPUT_PRIORITY #define SLIDER_SOCD_SLOT_DEFAULT SOCD_MODE_NEUTRAL +#define DEFAULT_FORCED_SETUP_MODE FORCED_SETUP_MODE_OFF // FORCED_SETUP_MODE_OFF, FORCED_SETUP_MODE_LOCK_MODE_SWITCH, FORCED_SETUP_MODE_LOCK_WEB_CONFIG, FORCED_SETUP_MODE_LOCK_BOTH +#define DEFAULT_LOCK_HOTKEYS false // or true // This is the LEDs section. // The default `TURBO_LED_PIN` pin is set to `15` ( it is recommended to run through 3V3(OUT) with a resistor) diff --git a/configs/PicoFightingBoard/BoardConfig.h b/configs/PicoFightingBoard/BoardConfig.h index 9e2212826..35c0ebb99 100644 --- a/configs/PicoFightingBoard/BoardConfig.h +++ b/configs/PicoFightingBoard/BoardConfig.h @@ -56,6 +56,8 @@ #define SLIDER_SOCD_SLOT_TWO SOCD_MODE_SECOND_INPUT_PRIORITY #define SLIDER_SOCD_SLOT_DEFAULT SOCD_MODE_NEUTRAL +#define DEFAULT_FORCED_SETUP_MODE FORCED_SETUP_MODE_OFF // FORCED_SETUP_MODE_OFF, FORCED_SETUP_MODE_LOCK_MODE_SWITCH, FORCED_SETUP_MODE_LOCK_WEB_CONFIG, FORCED_SETUP_MODE_LOCK_BOTH +#define DEFAULT_LOCK_HOTKEYS false // or true // This is the LEDs section. // The default `TURBO_LED_PIN` pin is set to `15` ( it is recommended to run through 3V3(OUT) with a resistor) diff --git a/configs/RP2040AdvancedBreakoutBoard/BoardConfig.h b/configs/RP2040AdvancedBreakoutBoard/BoardConfig.h index 9c21c2dc4..daac2af93 100644 --- a/configs/RP2040AdvancedBreakoutBoard/BoardConfig.h +++ b/configs/RP2040AdvancedBreakoutBoard/BoardConfig.h @@ -56,6 +56,8 @@ #define SLIDER_SOCD_SLOT_TWO SOCD_MODE_SECOND_INPUT_PRIORITY #define SLIDER_SOCD_SLOT_DEFAULT SOCD_MODE_NEUTRAL +#define DEFAULT_FORCED_SETUP_MODE FORCED_SETUP_MODE_OFF // FORCED_SETUP_MODE_OFF, FORCED_SETUP_MODE_LOCK_MODE_SWITCH, FORCED_SETUP_MODE_LOCK_WEB_CONFIG, FORCED_SETUP_MODE_LOCK_BOTH +#define DEFAULT_LOCK_HOTKEYS false // or true // This is the LEDs section. // The default `TURBO_LED_PIN` pin is set to `15` ( it is recommended to run through 3V3(OUT) with a resistor) diff --git a/configs/ReflexEncoder/BoardConfig.h b/configs/ReflexEncoder/BoardConfig.h index 2ff65116e..e652acef3 100644 --- a/configs/ReflexEncoder/BoardConfig.h +++ b/configs/ReflexEncoder/BoardConfig.h @@ -56,6 +56,8 @@ #define SLIDER_SOCD_SLOT_TWO SOCD_MODE_SECOND_INPUT_PRIORITY #define SLIDER_SOCD_SLOT_DEFAULT SOCD_MODE_NEUTRAL +#define DEFAULT_FORCED_SETUP_MODE FORCED_SETUP_MODE_OFF // FORCED_SETUP_MODE_OFF, FORCED_SETUP_MODE_LOCK_MODE_SWITCH, FORCED_SETUP_MODE_LOCK_WEB_CONFIG, FORCED_SETUP_MODE_LOCK_BOTH +#define DEFAULT_LOCK_HOTKEYS false // or true // This is the LEDs section. // The default `TURBO_LED_PIN` pin is set to `15` ( it is recommended to run through 3V3(OUT) with a resistor) diff --git a/configs/SparkFunProMicro/BoardConfig.h b/configs/SparkFunProMicro/BoardConfig.h index 794ef8db5..e888fda51 100644 --- a/configs/SparkFunProMicro/BoardConfig.h +++ b/configs/SparkFunProMicro/BoardConfig.h @@ -49,6 +49,8 @@ #define SLIDER_SOCD_SLOT_TWO SOCD_MODE_SECOND_INPUT_PRIORITY #define SLIDER_SOCD_SLOT_DEFAULT SOCD_MODE_NEUTRAL +#define DEFAULT_FORCED_SETUP_MODE FORCED_SETUP_MODE_OFF // FORCED_SETUP_MODE_OFF, FORCED_SETUP_MODE_LOCK_MODE_SWITCH, FORCED_SETUP_MODE_LOCK_WEB_CONFIG, FORCED_SETUP_MODE_LOCK_BOTH +#define DEFAULT_LOCK_HOTKEYS false // or true // This is the LEDs section. // The default `TURBO_LED_PIN` pin is set to `15` ( it is recommended to run through 3V3(OUT) with a resistor) // The Turbo LED will flash at a speed consistant with the set speed of the Turbo when a Turbo button is active. diff --git a/configs/WaveshareZero/BoardConfig.h b/configs/WaveshareZero/BoardConfig.h index 47897358d..b6bb82809 100644 --- a/configs/WaveshareZero/BoardConfig.h +++ b/configs/WaveshareZero/BoardConfig.h @@ -56,6 +56,8 @@ #define SLIDER_SOCD_SLOT_TWO SOCD_MODE_SECOND_INPUT_PRIORITY #define SLIDER_SOCD_SLOT_DEFAULT SOCD_MODE_NEUTRAL +#define DEFAULT_FORCED_SETUP_MODE FORCED_SETUP_MODE_OFF // FORCED_SETUP_MODE_OFF, FORCED_SETUP_MODE_LOCK_MODE_SWITCH, FORCED_SETUP_MODE_LOCK_WEB_CONFIG, FORCED_SETUP_MODE_LOCK_BOTH +#define DEFAULT_LOCK_HOTKEYS false // or true // This is the LEDs section. // The default `TURBO_LED_PIN` pin is set to `15` ( it is recommended to run through 3V3(OUT) with a resistor) diff --git a/headers/gamepad/GamepadOptions.h b/headers/gamepad/GamepadOptions.h new file mode 100644 index 000000000..e69de29bb diff --git a/headers/storagemanager.h b/headers/storagemanager.h index 3feba080e..39c6639df 100644 --- a/headers/storagemanager.h +++ b/headers/storagemanager.h @@ -36,6 +36,7 @@ class Storage { Config& getConfig() { return config; } GamepadOptions& getGamepadOptions() { return config.gamepadOptions; } HotkeyOptions& getHotkeyOptions() { return config.hotkeyOptions; } + ForcedSetupOptions& getForcedSetupOptions() { return config.forcedSetupOptions; } PinMappings& getPinMappings() { return config.pinMappings; } KeyboardMapping& getKeyboardMapping() { return config.keyboardMapping; } DisplayOptions& getDisplayOptions() { return config.displayOptions; } diff --git a/proto/config.proto b/proto/config.proto index a032000d1..86b56f101 100644 --- a/proto/config.proto +++ b/proto/config.proto @@ -11,6 +11,7 @@ message GamepadOptions optional bool invertXAxis = 4; optional bool invertYAxis = 5; optional bool switchTpShareForDs4 = 6; + optional bool lockHotkeys = 7; } message KeyboardMapping @@ -53,6 +54,11 @@ message HotkeyOptions optional HotkeyEntry hotkeyF2Right = 8; } +message ForcedSetupOptions +{ + optional ForcedSetupMode mode = 1; +}; + message ButtonLayoutParamsCommon { optional int32 startX = 1; @@ -401,4 +407,5 @@ message Config optional LEDOptions ledOptions = 7; optional AnimationOptions_Proto animationOptions = 8; optional AddonOptions addonOptions = 9; + optional ForcedSetupOptions forcedSetupOptions = 10; } diff --git a/proto/enums.proto b/proto/enums.proto index af6629285..619228c3a 100644 --- a/proto/enums.proto +++ b/proto/enums.proto @@ -151,3 +151,13 @@ enum PLEDType PLED_TYPE_PWM = 0; PLED_TYPE_RGB = 1; }; + +enum ForcedSetupMode +{ + option (nanopb_enumopt).long_names = false; + + FORCED_SETUP_MODE_OFF = 0; + FORCED_SETUP_MODE_LOCK_MODE_SWITCH = 1; + FORCED_SETUP_MODE_LOCK_WEB_CONFIG = 2; + FORCED_SETUP_MODE_LOCK_BOTH = 3; +}; \ No newline at end of file diff --git a/src/config_utils.cpp b/src/config_utils.cpp index d90961a9f..60cf33153 100644 --- a/src/config_utils.cpp +++ b/src/config_utils.cpp @@ -90,6 +90,7 @@ void ConfigUtils::initUnsetPropertiesWithDefaults(Config& config) INIT_UNSET_PROPERTY(config.gamepadOptions, socdMode, DEFAULT_SOCD_MODE); INIT_UNSET_PROPERTY(config.gamepadOptions, invertXAxis, false); INIT_UNSET_PROPERTY(config.gamepadOptions, switchTpShareForDs4, false); + INIT_UNSET_PROPERTY(config.gamepadOptions, lockHotkeys, DEFAULT_LOCK_HOTKEYS); // hotkeyOptions HotkeyOptions& hotkeyOptions = config.hotkeyOptions; @@ -110,6 +111,9 @@ void ConfigUtils::initUnsetPropertiesWithDefaults(Config& config) INIT_UNSET_PROPERTY(hotkeyOptions.hotkeyF2Right, dpadMask, HOTKEY_F2_RIGHT_MASK); INIT_UNSET_PROPERTY(hotkeyOptions.hotkeyF2Right, action, HOTKEY_F2_RIGHT_ACTION); + // forcedSetupMode + INIT_UNSET_PROPERTY(config.forcedSetupOptions, mode, DEFAULT_FORCED_SETUP_MODE); + // pinMappings INIT_UNSET_PROPERTY(config.pinMappings, pinDpadUp, PIN_DPAD_UP); INIT_UNSET_PROPERTY(config.pinMappings, pinDpadDown, PIN_DPAD_DOWN); diff --git a/src/configs/webconfig.cpp b/src/configs/webconfig.cpp index a8112bfc4..a258853b7 100644 --- a/src/configs/webconfig.cpp +++ b/src/configs/webconfig.cpp @@ -455,6 +455,7 @@ std::string setGamepadOptions() readDoc(gamepadOptions.inputMode, doc, "inputMode"); readDoc(gamepadOptions.socdMode, doc, "socdMode"); readDoc(gamepadOptions.switchTpShareForDs4, doc, "switchTpShareForDs4"); + readDoc(gamepadOptions.lockHotkeys, doc, "lockHotkeys"); HotkeyOptions& hotkeyOptions = Storage::getInstance().getHotkeyOptions(); readDoc(hotkeyOptions.hotkeyF1Up.action, doc, "hotkeyF1", 0, "action"); @@ -467,6 +468,9 @@ std::string setGamepadOptions() readDoc(hotkeyOptions.hotkeyF2Left.action, doc, "hotkeyF2", 2, "action"); readDoc(hotkeyOptions.hotkeyF2Right.action, doc, "hotkeyF2", 3, "action"); + ForcedSetupOptions& forcedSetupOptions = Storage::getInstance().getForcedSetupOptions(); + readDoc(forcedSetupOptions.mode, doc, "forcedSetupMode"); + Storage::getInstance().save(); return serialize_json(doc); @@ -481,6 +485,7 @@ std::string getGamepadOptions() writeDoc(doc, "inputMode", gamepadOptions.inputMode); writeDoc(doc, "socdMode", gamepadOptions.socdMode); writeDoc(doc, "switchTpShareForDs4", gamepadOptions.switchTpShareForDs4 ? 1 : 0); + writeDoc(doc, "lockHotkeys", gamepadOptions.lockHotkeys ? 1 : 0); HotkeyOptions& hotkeyOptions = Storage::getInstance().getHotkeyOptions(); writeDoc(doc, "hotkeyF1", 0, "action", hotkeyOptions.hotkeyF1Up.action); @@ -501,6 +506,8 @@ std::string getGamepadOptions() writeDoc(doc, "hotkeyF2", 3, "action", hotkeyOptions.hotkeyF2Right.action); writeDoc(doc, "hotkeyF2", 3, "mask", hotkeyOptions.hotkeyF2Right.dpadMask); + ForcedSetupOptions& forcedSetupOptions = Storage::getInstance().getForcedSetupOptions(); + writeDoc(doc, "forcedSetupMode", forcedSetupOptions.mode); return serialize_json(doc); } diff --git a/src/gamepad.cpp b/src/gamepad.cpp index 2aee1c429..edba05830 100644 --- a/src/gamepad.cpp +++ b/src/gamepad.cpp @@ -257,6 +257,8 @@ void Gamepad::save() GamepadHotkey Gamepad::hotkey() { + if (options.lockHotkeys) return HOTKEY_NONE; + static GamepadHotkey lastAction = HOTKEY_NONE; GamepadHotkey action = HOTKEY_NONE; if (pressedF1()) diff --git a/src/gp2040.cpp b/src/gp2040.cpp index 54fbc3469..702d3cff6 100644 --- a/src/gp2040.cpp +++ b/src/gp2040.cpp @@ -2,6 +2,7 @@ #include "gp2040.h" #include "helper.h" #include "system.h" +#include "enums.pb.h" #include "configmanager.h" // Global Managers #include "storagemanager.h" @@ -178,19 +179,26 @@ GP2040::BootAction GP2040::getBootAction() { Gamepad * gamepad = Storage::getInstance().GetGamepad(); gamepad->read(); + ForcedSetupOptions& forcedSetupOptions = Storage::getInstance().getForcedSetupOptions(); + bool modeSwitchLocked = forcedSetupOptions.mode == FORCED_SETUP_MODE_LOCK_MODE_SWITCH || + forcedSetupOptions.mode == FORCED_SETUP_MODE_LOCK_BOTH; + + bool webConfigLocked = forcedSetupOptions.mode == FORCED_SETUP_MODE_LOCK_WEB_CONFIG || + forcedSetupOptions.mode == FORCED_SETUP_MODE_LOCK_BOTH; + if (gamepad->pressedF1() && gamepad->pressedUp()) { return BootAction::ENTER_USB_MODE; - } else if (gamepad->pressedS2()) { + } else if (!webConfigLocked && gamepad->pressedS2()) { return BootAction::ENTER_WEBCONFIG_MODE; - } else if (gamepad->pressedB3()) { // P1 + } else if (!modeSwitchLocked && gamepad->pressedB3()) { // P1 return BootAction::SET_INPUT_MODE_HID; - } else if (gamepad->pressedB4()) { // P2 + } else if (!modeSwitchLocked && gamepad->pressedB4()) { // P2 return BootAction::SET_INPUT_MODE_PS4; - } else if (gamepad->pressedB1()) { // K1 + } else if (!modeSwitchLocked && gamepad->pressedB1()) { // K1 return BootAction::SET_INPUT_MODE_SWITCH; - } else if (gamepad->pressedB2()) { // K2 + } else if (!modeSwitchLocked && gamepad->pressedB2()) { // K2 return BootAction::SET_INPUT_MODE_XINPUT; - } else if (gamepad->pressedR2()) { // K3 + } else if (!modeSwitchLocked && gamepad->pressedR2()) { // K3 return BootAction::SET_INPUT_MODE_KEYBOARD; } else { return BootAction::NONE; diff --git a/www/server/app.js b/www/server/app.js index 37033a953..d8fedc508 100644 --- a/www/server/app.js +++ b/www/server/app.js @@ -80,6 +80,8 @@ app.get("/api/getGamepadOptions", (req, res) => { inputMode: 4, socdMode: 2, switchTpShareForDs4: 0, + forcedSetupMode: 0, + lockHotkeys: 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 fe06879c5..03d5b4d8a 100644 --- a/www/src/Pages/SettingsPage.js +++ b/www/src/Pages/SettingsPage.js @@ -1,6 +1,6 @@ import React, { useContext, useEffect, useState } from 'react'; import { AppContext } from '../Contexts/AppContext'; -import { Button, Form } from 'react-bootstrap'; +import { Button, Form, Modal } from 'react-bootstrap'; import { Formik, useFormikContext } from 'formik'; import * as yup from 'yup'; @@ -54,6 +54,13 @@ const HOTKEY_ACTIONS = [ { label: 'Invert Y Axis', value: 10 }, ]; +const FORCED_SETUP_MODES = [ + { label: 'Off', value: 0 }, + { label: 'Disable Input-Mode Switch', value: 1 }, + { label: 'Disable Web-Config', value: 2 }, + { label: 'Disable Input-Mode Switch and Web-Config', value: 3 }, +]; + const schema = yup.object().shape({ dpadMode : yup.number().required().oneOf(DPAD_MODES.map(o => o.value)).label('D-Pad Mode'), hotkeyF1 : yup.array().of(yup.object({ @@ -67,6 +74,8 @@ 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'), + forcedSetupMode : yup.number().required().oneOf(FORCED_SETUP_MODES.map(o => o.value)).label('SOCD Cleaning Mode'), + lockHotkeys: yup.number().required().label('Lock Hotkeys'), }); const FormContext = ({ setButtonLabels }) => { @@ -90,6 +99,10 @@ const FormContext = ({ setButtonLabels }) => { values.socdMode = parseInt(values.socdMode); if (!!values.switchTpShareForDs4) values.switchTpShareForDs4 = parseInt(values.switchTpShareForDs4); + if (!!values.forcedSetupMode) + values.forcedSetupMode = parseInt(values.forcedSetupMode); + if (!!values.lockHotkeys) + values.lockHotkeys = parseInt(values.lockHotkeys); setButtonLabels({ swapTpShareLabels: (values.switchTpShareForDs4 === 1) && (values.inputMode === 4) }); @@ -109,12 +122,30 @@ const FormContext = ({ setButtonLabels }) => { export default function SettingsPage() { const { buttonLabels, setButtonLabels } = useContext(AppContext); const [saveMessage, setSaveMessage] = useState(''); + const [warning, setWarning] = useState({ show: false, acceptText: ''}); - const onSuccess = async (values) => { + const WARNING_CHECK_TEXT = "GP2040-CE"; + + const handleWarningClose = async (accepted, values, setFieldValue) => { + setWarning({ show: false, acceptText: ''}); + if (accepted) await saveSettings(values); + else setFieldValue('forcedSetupMode', 0); + }; + + const setWarningAcceptText = (e) => { + setWarning({ ...warning, acceptText: e.target.value }); + }; + + const saveSettings = async (values) => { const success = await WebApi.setGamepadOptions(values); setSaveMessage(success ? 'Saved! Please Restart Your Device' : 'Unable to Save'); }; + const onSuccess = async (values) => { + if (values.forcedSetupMode > 1) { setWarning({ show: true, acceptText: ''}); } + else { await saveSettings(values); } + }; + const { buttonLabelType, swapTpShareLabels } = buttonLabels; const buttonLabelS1 = BUTTONS[buttonLabelType][swapTpShareLabels ? "A2" : "S1"]; @@ -171,41 +202,83 @@ export default function SettingsPage() {
Note: PS4, PS3 and Nintendo Switch modes do not support setting SOCD Cleaning to Off and will default to Neutral SOCD Cleaning mode.
+