mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-05-20 01:52:39 +00:00
Qt/Core: Implement GBA Hotkeys
This commit is contained in:
parent
d6f86e1754
commit
b73d16a71a
9 changed files with 193 additions and 8 deletions
|
@ -23,7 +23,7 @@
|
|||
#include "InputCommon/GCPadStatus.h"
|
||||
|
||||
// clang-format off
|
||||
constexpr std::array<const char*, 126> s_hotkey_labels{{
|
||||
constexpr std::array<const char*, NUM_HOTKEYS> s_hotkey_labels{{
|
||||
_trans("Open"),
|
||||
_trans("Change Disc"),
|
||||
_trans("Eject Disc"),
|
||||
|
@ -178,6 +178,19 @@ constexpr std::array<const char*, 126> s_hotkey_labels{{
|
|||
_trans("Undo Save State"),
|
||||
_trans("Save State"),
|
||||
_trans("Load State"),
|
||||
|
||||
_trans("Load ROM"),
|
||||
_trans("Unload ROM"),
|
||||
_trans("Reset"),
|
||||
|
||||
_trans("Volume Down"),
|
||||
_trans("Volume Up"),
|
||||
_trans("Volume Toggle Mute"),
|
||||
|
||||
_trans("1x"),
|
||||
_trans("2x"),
|
||||
_trans("3x"),
|
||||
_trans("4x"),
|
||||
}};
|
||||
// clang-format on
|
||||
static_assert(NUM_HOTKEYS == s_hotkey_labels.size(), "Wrong count of hotkey_labels");
|
||||
|
@ -195,10 +208,10 @@ InputConfig* GetConfig()
|
|||
return &s_config;
|
||||
}
|
||||
|
||||
void GetStatus()
|
||||
void GetStatus(bool ignore_focus)
|
||||
{
|
||||
// Get input
|
||||
static_cast<HotkeyManager*>(s_config.GetController(0))->GetInput(&s_hotkey);
|
||||
static_cast<HotkeyManager*>(s_config.GetController(0))->GetInput(&s_hotkey, ignore_focus);
|
||||
}
|
||||
|
||||
bool IsEnabled()
|
||||
|
@ -307,6 +320,7 @@ struct HotkeyGroupInfo
|
|||
const char* name;
|
||||
Hotkey first;
|
||||
Hotkey last;
|
||||
bool ignore_focus = false;
|
||||
};
|
||||
|
||||
constexpr std::array<HotkeyGroupInfo, NUM_HOTKEY_GROUPS> s_groups_info = {
|
||||
|
@ -334,7 +348,10 @@ constexpr std::array<HotkeyGroupInfo, NUM_HOTKEY_GROUPS> s_groups_info = {
|
|||
{_trans("Save State"), HK_SAVE_STATE_SLOT_1, HK_SAVE_STATE_SLOT_SELECTED},
|
||||
{_trans("Select State"), HK_SELECT_STATE_SLOT_1, HK_SELECT_STATE_SLOT_10},
|
||||
{_trans("Load Last State"), HK_LOAD_LAST_STATE_1, HK_LOAD_LAST_STATE_10},
|
||||
{_trans("Other State Hotkeys"), HK_SAVE_FIRST_STATE, HK_LOAD_STATE_FILE}}};
|
||||
{_trans("Other State Hotkeys"), HK_SAVE_FIRST_STATE, HK_LOAD_STATE_FILE},
|
||||
{_trans("GBA Core"), HK_GBA_LOAD, HK_GBA_RESET, true},
|
||||
{_trans("GBA Volume"), HK_GBA_VOLUME_DOWN, HK_GBA_TOGGLE_MUTE, true},
|
||||
{_trans("GBA Window Size"), HK_GBA_1X, HK_GBA_4X, true}}};
|
||||
|
||||
HotkeyManager::HotkeyManager()
|
||||
{
|
||||
|
@ -359,11 +376,14 @@ std::string HotkeyManager::GetName() const
|
|||
return "Hotkeys";
|
||||
}
|
||||
|
||||
void HotkeyManager::GetInput(HotkeyStatus* const kb)
|
||||
void HotkeyManager::GetInput(HotkeyStatus* kb, bool ignore_focus)
|
||||
{
|
||||
const auto lock = GetStateLock();
|
||||
for (std::size_t group = 0; group < s_groups_info.size(); group++)
|
||||
{
|
||||
if (s_groups_info[group].ignore_focus != ignore_focus)
|
||||
continue;
|
||||
|
||||
const int group_count = (s_groups_info[group].last - s_groups_info[group].first) + 1;
|
||||
std::vector<u32> bitmasks(group_count);
|
||||
for (size_t key = 0; key < bitmasks.size(); key++)
|
||||
|
@ -441,4 +461,30 @@ void HotkeyManager::LoadDefaults(const ControllerInterface& ciface)
|
|||
}
|
||||
set_key_expression(HK_UNDO_LOAD_STATE, "F12");
|
||||
set_key_expression(HK_UNDO_SAVE_STATE, hotkey_string({"Shift", "F12"}));
|
||||
|
||||
// GBA
|
||||
set_key_expression(HK_GBA_LOAD, hotkey_string({"`Shift`", "`O`"}));
|
||||
set_key_expression(HK_GBA_UNLOAD, hotkey_string({"`Shift`", "`W`"}));
|
||||
set_key_expression(HK_GBA_RESET, hotkey_string({"`Shift`", "`R`"}));
|
||||
|
||||
#ifdef _WIN32
|
||||
set_key_expression(HK_GBA_VOLUME_DOWN, "`SUBTRACT`");
|
||||
set_key_expression(HK_GBA_VOLUME_UP, "`ADD`");
|
||||
#else
|
||||
set_key_expression(HK_GBA_VOLUME_DOWN, "`KP_Subtract`");
|
||||
set_key_expression(HK_GBA_VOLUME_UP, "`KP_Add`");
|
||||
#endif
|
||||
set_key_expression(HK_GBA_TOGGLE_MUTE, "`M`");
|
||||
|
||||
#ifdef _WIN32
|
||||
set_key_expression(HK_GBA_1X, "`NUMPAD1`");
|
||||
set_key_expression(HK_GBA_2X, "`NUMPAD2`");
|
||||
set_key_expression(HK_GBA_3X, "`NUMPAD3`");
|
||||
set_key_expression(HK_GBA_4X, "`NUMPAD4`");
|
||||
#else
|
||||
set_key_expression(HK_GBA_1X, "`KP_1`");
|
||||
set_key_expression(HK_GBA_2X, "`KP_2`");
|
||||
set_key_expression(HK_GBA_3X, "`KP_3`");
|
||||
set_key_expression(HK_GBA_4X, "`KP_4`");
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue