Core: Clean up default hotkey expressions.

This commit is contained in:
Jordan Woyak 2019-10-25 19:35:21 -05:00
parent f015c99a51
commit f7bf26cd60
3 changed files with 56 additions and 67 deletions

View File

@ -187,10 +187,10 @@ void GCPad::LoadDefaults(const ControllerInterface& ciface)
m_buttons->SetControlExpression(3, "S"); // Y
m_buttons->SetControlExpression(4, "D"); // Z
#ifdef _WIN32
m_buttons->SetControlExpression(5, "!LMENU & RETURN"); // Start
m_buttons->SetControlExpression(5, "RETURN"); // Start
#else
// OS X/Linux
m_buttons->SetControlExpression(5, "!`Alt_L` & Return"); // Start
m_buttons->SetControlExpression(5, "Return"); // Start
#endif
// stick modifiers to 50 %

View File

@ -603,9 +603,9 @@ void Wiimote::LoadDefaults(const ControllerInterface& ciface)
m_buttons->SetControlExpression(5, "E"); // +
#ifdef _WIN32
m_buttons->SetControlExpression(6, "!LMENU & RETURN"); // Home
m_buttons->SetControlExpression(6, "RETURN"); // Home
#else
m_buttons->SetControlExpression(6, "!`Alt_L` & Return"); // Home
m_buttons->SetControlExpression(6, "Return"); // Home
#endif
// Shake

View File

@ -409,83 +409,72 @@ void HotkeyManager::LoadDefaults(const ControllerInterface& ciface)
{
EmulatedController::LoadDefaults(ciface);
#ifdef _WIN32
const std::string NON = "(!(LMENU | RMENU) & !(LSHIFT | RSHIFT) & !(LCONTROL | RCONTROL))";
const std::string ALT = "((LMENU | RMENU) & !(LSHIFT | RSHIFT) & !(LCONTROL | RCONTROL))";
const std::string SHIFT = "(!(LMENU | RMENU) & (LSHIFT | RSHIFT) & !(LCONTROL | RCONTROL))";
const std::string CTRL = "(!(LMENU | RMENU) & !(LSHIFT | RSHIFT) & (LCONTROL | RCONTROL))";
#elif __APPLE__
const std::string NON =
"(!`Left Alt` & !(`Left Shift`| `Right Shift`) & !(`Left Control` | `Right Control`))";
const std::string ALT =
"(`Left Alt` & !(`Left Shift`| `Right Shift`) & !(`Left Control` | `Right Control`))";
const std::string SHIFT =
"(!`Left Alt` & (`Left Shift`| `Right Shift`) & !(`Left Control` | `Right Control`))";
const std::string CTRL =
"(!`Left Alt` & !(`Left Shift`| `Right Shift`) & (`Left Control` | `Right Control`))";
#else
const std::string NON = "(!`Alt_L` & !(`Shift_L` | `Shift_R`) & !(`Control_L` | `Control_R` ))";
const std::string ALT = "(`Alt_L` & !(`Shift_L` | `Shift_R`) & !(`Control_L` | `Control_R` ))";
const std::string SHIFT = "(!`Alt_L` & (`Shift_L` | `Shift_R`) & !(`Control_L` | `Control_R` ))";
const std::string CTRL = "(!`Alt_L` & !(`Shift_L` | `Shift_R`) & (`Control_L` | `Control_R` ))";
#endif
auto set_key_expression = [this](int index, const std::string& expression) {
m_keys[FindGroupByID(index)]
->controls[GetIndexForGroup(FindGroupByID(index), index)]
->control_ref->SetExpression(expression);
};
auto hotkey_string = [](std::vector<std::string_view> inputs) {
std::string result;
for (auto& input : inputs)
{
if (!result.empty())
result += '+';
result += input;
}
return "@(" + result + ')';
};
// General hotkeys
set_key_expression(HK_OPEN, CTRL + " & O");
set_key_expression(HK_PLAY_PAUSE, NON + " & `F10`");
set_key_expression(HK_OPEN, hotkey_string({"Ctrl", "O"}));
set_key_expression(HK_PLAY_PAUSE, "F10");
#ifdef _WIN32
set_key_expression(HK_STOP, NON + " & ESCAPE");
set_key_expression(HK_FULLSCREEN, ALT + " & RETURN");
set_key_expression(HK_STOP, "ESCAPE");
set_key_expression(HK_FULLSCREEN, hotkey_string({"Alt", "RETURN"}));
#else
set_key_expression(HK_STOP, NON + " & Escape");
set_key_expression(HK_FULLSCREEN, ALT + " & Return");
set_key_expression(HK_STOP, "Escape");
set_key_expression(HK_FULLSCREEN, hotkey_string({"Alt", "Return"}));
#endif
set_key_expression(HK_STEP, NON + " & `F11`");
set_key_expression(HK_STEP_OVER, SHIFT + " & `F10`");
set_key_expression(HK_STEP_OUT, SHIFT + " & `F11`");
set_key_expression(HK_BP_TOGGLE, SHIFT + " & `F9`");
set_key_expression(HK_SCREENSHOT, NON + " & `F9`");
set_key_expression(HK_WIIMOTE1_CONNECT, ALT + " & `F5`");
set_key_expression(HK_WIIMOTE2_CONNECT, ALT + " & `F6`");
set_key_expression(HK_WIIMOTE3_CONNECT, ALT + " & `F7`");
set_key_expression(HK_WIIMOTE4_CONNECT, ALT + " & `F8`");
set_key_expression(HK_BALANCEBOARD_CONNECT, ALT + " & `F9`");
set_key_expression(HK_STEP, "F11");
set_key_expression(HK_STEP_OVER, hotkey_string({"Shift", "F10"}));
set_key_expression(HK_STEP_OUT, hotkey_string({"Shift", "F11"}));
set_key_expression(HK_BP_TOGGLE, hotkey_string({"Shift", "F9"}));
set_key_expression(HK_SCREENSHOT, "F9");
set_key_expression(HK_WIIMOTE1_CONNECT, hotkey_string({"Alt", "F5"}));
set_key_expression(HK_WIIMOTE2_CONNECT, hotkey_string({"Alt", "F6"}));
set_key_expression(HK_WIIMOTE3_CONNECT, hotkey_string({"Alt", "F7"}));
set_key_expression(HK_WIIMOTE4_CONNECT, hotkey_string({"Alt", "F8"}));
set_key_expression(HK_BALANCEBOARD_CONNECT, hotkey_string({"Alt", "F9"}));
#ifdef _WIN32
set_key_expression(HK_TOGGLE_THROTTLE, NON + " & TAB");
set_key_expression(HK_TOGGLE_THROTTLE, "TAB");
#else
set_key_expression(HK_TOGGLE_THROTTLE, NON + " & Tab");
set_key_expression(HK_TOGGLE_THROTTLE, "Tab");
#endif
// Freelook
set_key_expression(HK_FREELOOK_DECREASE_SPEED, SHIFT + " & `1`");
set_key_expression(HK_FREELOOK_INCREASE_SPEED, SHIFT + " & `2`");
set_key_expression(HK_FREELOOK_RESET_SPEED, SHIFT + " & F");
set_key_expression(HK_FREELOOK_UP, SHIFT + " & E");
set_key_expression(HK_FREELOOK_DOWN, SHIFT + " & Q");
set_key_expression(HK_FREELOOK_LEFT, SHIFT + " & A");
set_key_expression(HK_FREELOOK_RIGHT, SHIFT + " & D");
set_key_expression(HK_FREELOOK_ZOOM_IN, SHIFT + " & W");
set_key_expression(HK_FREELOOK_ZOOM_OUT, SHIFT + " & S");
set_key_expression(HK_FREELOOK_RESET, SHIFT + " & R");
set_key_expression(HK_FREELOOK_INCREASE_FOV_X, SHIFT + " & `Axis Z+`");
set_key_expression(HK_FREELOOK_DECREASE_FOV_X, SHIFT + " & `Axis Z-`");
set_key_expression(HK_FREELOOK_INCREASE_FOV_Y, SHIFT + " & `Axis Z+`");
set_key_expression(HK_FREELOOK_DECREASE_FOV_Y, SHIFT + " & `Axis Z-`");
set_key_expression(HK_FREELOOK_DECREASE_SPEED, hotkey_string({"Shift", "1"}));
set_key_expression(HK_FREELOOK_INCREASE_SPEED, hotkey_string({"Shift", "2"}));
set_key_expression(HK_FREELOOK_RESET_SPEED, hotkey_string({"Shift", "F"}));
set_key_expression(HK_FREELOOK_UP, hotkey_string({"Shift", "E"}));
set_key_expression(HK_FREELOOK_DOWN, hotkey_string({"Shift", "Q"}));
set_key_expression(HK_FREELOOK_LEFT, hotkey_string({"Shift", "A"}));
set_key_expression(HK_FREELOOK_RIGHT, hotkey_string({"Shift", "D"}));
set_key_expression(HK_FREELOOK_ZOOM_IN, hotkey_string({"Shift", "W"}));
set_key_expression(HK_FREELOOK_ZOOM_OUT, hotkey_string({"Shift", "S"}));
set_key_expression(HK_FREELOOK_RESET, hotkey_string({"Shift", "R"}));
set_key_expression(HK_FREELOOK_INCREASE_FOV_X, hotkey_string({"Shift", "`Axis Z+`"}));
set_key_expression(HK_FREELOOK_DECREASE_FOV_X, hotkey_string({"Shift", "`Axis Z-`"}));
set_key_expression(HK_FREELOOK_INCREASE_FOV_Y, hotkey_string({"Shift", "`Axis Z+`"}));
set_key_expression(HK_FREELOOK_DECREASE_FOV_Y, hotkey_string({"Shift", "`Axis Z-`"}));
// Savestates
const std::string non_fmt = NON + " & `F{}`";
const std::string shift_fmt = SHIFT + " & `F{}`";
for (int i = 0; i < 8; i++)
{
set_key_expression(HK_LOAD_STATE_SLOT_1 + i, fmt::format(non_fmt, i + 1));
set_key_expression(HK_SAVE_STATE_SLOT_1 + i, fmt::format(shift_fmt, i + 1));
set_key_expression(HK_LOAD_STATE_SLOT_1 + i, fmt::format("F%d", i + 1));
set_key_expression(HK_SAVE_STATE_SLOT_1 + i,
hotkey_string({"Shift", fmt::format("F%d", i + 1)}));
}
set_key_expression(HK_UNDO_LOAD_STATE, NON + " & `F12`");
set_key_expression(HK_UNDO_SAVE_STATE, SHIFT + " & `F12`");
set_key_expression(HK_UNDO_LOAD_STATE, "F12");
set_key_expression(HK_UNDO_SAVE_STATE, hotkey_string({"Shift", "F12"}));
}