UI: Add configurable hotkeys + a new fast forward hotkey (#1519)

This commit is contained in:
AnimeGIF 2025-07-08 00:55:57 +03:00 committed by GitHub
parent e68c31e5fb
commit cdca5eaf78
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 619 additions and 8 deletions

View file

@ -191,6 +191,50 @@ enum class CrashDump
ENABLE_ENUM_ITERATORS(CrashDump, CrashDump::Disabled, CrashDump::Enabled);
#endif
typedef union
{
struct
{
uint16 key : 13; // enough bits for all keycodes
uint16 alt : 1;
uint16 ctrl : 1;
uint16 shift : 1;
};
uint16 raw;
} uKeyboardHotkey;
typedef sint16 ControllerHotkey_t;
struct sHotkeyCfg
{
static constexpr uint8 keyboardNone{WXK_NONE};
static constexpr sint8 controllerNone{-1}; // no enums to work with, but buttons start from 0
uKeyboardHotkey keyboard{keyboardNone};
ControllerHotkey_t controller{controllerNone};
/* for defaults */
sHotkeyCfg(const uKeyboardHotkey& keyboard = {WXK_NONE}, const ControllerHotkey_t& controller = {-1}) :
keyboard(keyboard), controller(controller) {};
/* for reading from xml */
sHotkeyCfg(const char* xml_values)
{
std::istringstream iss(xml_values);
iss >> keyboard.raw >> controller;
}
};
template <>
struct fmt::formatter<sHotkeyCfg> : formatter<string_view>
{
template <typename FormatContext>
auto format(const sHotkeyCfg c, FormatContext &ctx) const {
std::string xml_values = fmt::format("{} {}", c.keyboard.raw, c.controller);
return formatter<string_view>::format(xml_values, ctx);
}
};
template <>
struct fmt::formatter<PrecompiledShaderOption> : formatter<string_view> {
template <typename FormatContext>
@ -499,6 +543,17 @@ struct CemuConfig
ConfigValue<uint16> port{ 26760 };
}dsu_client{};
// hotkeys
struct
{
sHotkeyCfg modifiers;
sHotkeyCfg toggleFullscreen;
sHotkeyCfg toggleFullscreenAlt;
sHotkeyCfg exitFullscreen;
sHotkeyCfg takeScreenshot;
sHotkeyCfg toggleFastForward;
} hotkeys{};
// debug
ConfigValueBounds<CrashDump> crash_dump{ CrashDump::Disabled };
ConfigValue<uint16> gdb_port{ 1337 };