Skip to content

Commit

Permalink
add more hotkeys (#661)
Browse files Browse the repository at this point in the history
Add more hotkeys as requested in issue 503.
  • Loading branch information
NickGuyver authored Dec 11, 2023
1 parent 42012a3 commit cf1bef2
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 1 deletion.
52 changes: 52 additions & 0 deletions headers/gamepad/GamepadConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,55 @@
#ifndef HOTKEY_12_ACTION
#define HOTKEY_12_ACTION 0
#endif

#ifndef HOTKEY_13_AUX_MASK
#define HOTKEY_13_AUX_MASK 0
#endif
#ifndef HOTKEY_13_BUTTONS_MASK
#define HOTKEY_13_BUTTONS_MASK 0
#endif
#ifndef HOTKEY_13_DPAD_MASK
#define HOTKEY_13_DPAD_MASK 0
#endif
#ifndef HOTKEY_13_ACTION
#define HOTKEY_13_ACTION 0
#endif

#ifndef HOTKEY_14_AUX_MASK
#define HOTKEY_14_AUX_MASK 0
#endif
#ifndef HOTKEY_14_BUTTONS_MASK
#define HOTKEY_14_BUTTONS_MASK 0
#endif
#ifndef HOTKEY_14_DPAD_MASK
#define HOTKEY_14_DPAD_MASK 0
#endif
#ifndef HOTKEY_14_ACTION
#define HOTKEY_14_ACTION 0
#endif

#ifndef HOTKEY_15_AUX_MASK
#define HOTKEY_15_AUX_MASK 0
#endif
#ifndef HOTKEY_15_BUTTONS_MASK
#define HOTKEY_15_BUTTONS_MASK 0
#endif
#ifndef HOTKEY_15_DPAD_MASK
#define HOTKEY_15_DPAD_MASK 0
#endif
#ifndef HOTKEY_15_ACTION
#define HOTKEY_15_ACTION 0
#endif

#ifndef HOTKEY_16_AUX_MASK
#define HOTKEY_16_AUX_MASK 0
#endif
#ifndef HOTKEY_16_BUTTONS_MASK
#define HOTKEY_16_BUTTONS_MASK 0
#endif
#ifndef HOTKEY_16_DPAD_MASK
#define HOTKEY_16_DPAD_MASK 0
#endif
#ifndef HOTKEY_16_ACTION
#define HOTKEY_16_ACTION 0
#endif
4 changes: 4 additions & 0 deletions proto/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ message HotkeyOptions
optional HotkeyEntry hotkey10 = 10;
optional HotkeyEntry hotkey11 = 11;
optional HotkeyEntry hotkey12 = 12;
optional HotkeyEntry hotkey13 = 13;
optional HotkeyEntry hotkey14 = 14;
optional HotkeyEntry hotkey15 = 15;
optional HotkeyEntry hotkey16 = 16;
}

message PeripheralOptions
Expand Down
16 changes: 16 additions & 0 deletions src/config_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,22 @@ void ConfigUtils::initUnsetPropertiesWithDefaults(Config& config)
INIT_UNSET_PROPERTY(hotkeyOptions.hotkey12, buttonsMask, HOTKEY_12_BUTTONS_MASK);
INIT_UNSET_PROPERTY(hotkeyOptions.hotkey12, dpadMask, HOTKEY_12_DPAD_MASK);
INIT_UNSET_PROPERTY(hotkeyOptions.hotkey12, action, GamepadHotkey(HOTKEY_12_ACTION));
INIT_UNSET_PROPERTY(hotkeyOptions.hotkey13, auxMask, HOTKEY_13_AUX_MASK);
INIT_UNSET_PROPERTY(hotkeyOptions.hotkey13, buttonsMask, HOTKEY_13_BUTTONS_MASK);
INIT_UNSET_PROPERTY(hotkeyOptions.hotkey13, dpadMask, HOTKEY_13_DPAD_MASK);
INIT_UNSET_PROPERTY(hotkeyOptions.hotkey13, action, GamepadHotkey(HOTKEY_13_ACTION));
INIT_UNSET_PROPERTY(hotkeyOptions.hotkey14, auxMask, HOTKEY_14_AUX_MASK);
INIT_UNSET_PROPERTY(hotkeyOptions.hotkey14, buttonsMask, HOTKEY_14_BUTTONS_MASK);
INIT_UNSET_PROPERTY(hotkeyOptions.hotkey14, dpadMask, HOTKEY_14_DPAD_MASK);
INIT_UNSET_PROPERTY(hotkeyOptions.hotkey14, action, GamepadHotkey(HOTKEY_14_ACTION));
INIT_UNSET_PROPERTY(hotkeyOptions.hotkey15, auxMask, HOTKEY_15_AUX_MASK);
INIT_UNSET_PROPERTY(hotkeyOptions.hotkey15, buttonsMask, HOTKEY_15_BUTTONS_MASK);
INIT_UNSET_PROPERTY(hotkeyOptions.hotkey15, dpadMask, HOTKEY_15_DPAD_MASK);
INIT_UNSET_PROPERTY(hotkeyOptions.hotkey15, action, GamepadHotkey(HOTKEY_15_ACTION));
INIT_UNSET_PROPERTY(hotkeyOptions.hotkey16, auxMask, HOTKEY_16_AUX_MASK);
INIT_UNSET_PROPERTY(hotkeyOptions.hotkey16, buttonsMask, HOTKEY_16_BUTTONS_MASK);
INIT_UNSET_PROPERTY(hotkeyOptions.hotkey16, dpadMask, HOTKEY_16_DPAD_MASK);
INIT_UNSET_PROPERTY(hotkeyOptions.hotkey16, action, GamepadHotkey(HOTKEY_16_ACTION));

// forcedSetupMode
INIT_UNSET_PROPERTY(config.forcedSetupOptions, mode, DEFAULT_FORCED_SETUP_MODE);
Expand Down
8 changes: 8 additions & 0 deletions src/configs/webconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,10 @@ std::string setGamepadOptions()
save_hotkey(&hotkeyOptions.hotkey10, doc, "hotkey10");
save_hotkey(&hotkeyOptions.hotkey11, doc, "hotkey11");
save_hotkey(&hotkeyOptions.hotkey12, doc, "hotkey12");
save_hotkey(&hotkeyOptions.hotkey13, doc, "hotkey13");
save_hotkey(&hotkeyOptions.hotkey14, doc, "hotkey14");
save_hotkey(&hotkeyOptions.hotkey15, doc, "hotkey15");
save_hotkey(&hotkeyOptions.hotkey16, doc, "hotkey16");

ForcedSetupOptions& forcedSetupOptions = Storage::getInstance().getForcedSetupOptions();
readDoc(forcedSetupOptions.mode, doc, "forcedSetupMode");
Expand Down Expand Up @@ -718,6 +722,10 @@ std::string getGamepadOptions()
load_hotkey(&hotkeyOptions.hotkey10, doc, "hotkey10");
load_hotkey(&hotkeyOptions.hotkey11, doc, "hotkey11");
load_hotkey(&hotkeyOptions.hotkey12, doc, "hotkey12");
load_hotkey(&hotkeyOptions.hotkey13, doc, "hotkey13");
load_hotkey(&hotkeyOptions.hotkey14, doc, "hotkey14");
load_hotkey(&hotkeyOptions.hotkey15, doc, "hotkey15");
load_hotkey(&hotkeyOptions.hotkey16, doc, "hotkey16");

ForcedSetupOptions& forcedSetupOptions = Storage::getInstance().getForcedSetupOptions();
writeDoc(doc, "forcedSetupMode", forcedSetupOptions.mode);
Expand Down
4 changes: 4 additions & 0 deletions src/gamepad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,10 @@ void Gamepad::hotkey()
else if (pressedHotkey(hotkeyOptions.hotkey10)) action = selectHotkey(hotkeyOptions.hotkey10);
else if (pressedHotkey(hotkeyOptions.hotkey11)) action = selectHotkey(hotkeyOptions.hotkey11);
else if (pressedHotkey(hotkeyOptions.hotkey12)) action = selectHotkey(hotkeyOptions.hotkey12);
else if (pressedHotkey(hotkeyOptions.hotkey13)) action = selectHotkey(hotkeyOptions.hotkey13);
else if (pressedHotkey(hotkeyOptions.hotkey14)) action = selectHotkey(hotkeyOptions.hotkey14);
else if (pressedHotkey(hotkeyOptions.hotkey15)) action = selectHotkey(hotkeyOptions.hotkey15);
else if (pressedHotkey(hotkeyOptions.hotkey16)) action = selectHotkey(hotkeyOptions.hotkey16);
else lastAction = HOTKEY_NONE;
processHotkeyIfNewAction(action);
}
Expand Down
20 changes: 20 additions & 0 deletions www/server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,26 @@ app.get('/api/getGamepadOptions', (req, res) => {
buttonsMask: 0,
action: 0,
},
hotkey13: {
auxMask: 0,
buttonsMask: 0,
action: 0,
},
hotkey14: {
auxMask: 0,
buttonsMask: 0,
action: 0,
},
hotkey15: {
auxMask: 0,
buttonsMask: 0,
action: 0,
},
hotkey16: {
auxMask: 0,
buttonsMask: 0,
action: 0,
},
});
});

Expand Down
2 changes: 1 addition & 1 deletion www/src/Pages/SettingsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const hotkeySchema = {
auxMask: yup.number().required().label('Function Key'),
};

const hotkeyFields = Array(12)
const hotkeyFields = Array(16)
.fill(0)
.reduce((acc, a, i) => {
const number = String(i + 1).padStart(2, '0');
Expand Down

0 comments on commit cf1bef2

Please sign in to comment.