From cc6b55ee2a29aa54dace480ecf5dd8bef6258b72 Mon Sep 17 00:00:00 2001 From: skidau Date: Wed, 4 Feb 2015 23:23:52 +1100 Subject: [PATCH 01/12] Fixed the save state hotkeys so that they work with the Render to Main Window option. --- Source/Core/DolphinWX/Frame.cpp | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/Source/Core/DolphinWX/Frame.cpp b/Source/Core/DolphinWX/Frame.cpp index 82a089eb7e..7e19c092fa 100644 --- a/Source/Core/DolphinWX/Frame.cpp +++ b/Source/Core/DolphinWX/Frame.cpp @@ -1398,25 +1398,22 @@ void CFrame::ParseHotkeys(wxKeyEvent &event) } unsigned int i = NUM_HOTKEYS; - if (!SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain || TASInputHasFocus()) + for (i = 0; i < NUM_HOTKEYS; i++) { - for (i = 0; i < NUM_HOTKEYS; i++) + if (IsHotkey(event, i)) { - if (IsHotkey(event, i)) + int cmd = GetCmdForHotkey(i); + if (cmd >= 0) { - int cmd = GetCmdForHotkey(i); - if (cmd >= 0) + wxCommandEvent evt(wxEVT_MENU, cmd); + wxMenuItem *item = GetMenuBar()->FindItem(cmd); + if (item && item->IsCheckable()) { - wxCommandEvent evt(wxEVT_MENU, cmd); - wxMenuItem *item = GetMenuBar()->FindItem(cmd); - if (item && item->IsCheckable()) - { - item->wxMenuItemBase::Toggle(); - evt.SetInt(item->IsChecked()); - } - GetEventHandler()->AddPendingEvent(evt); - break; + item->wxMenuItemBase::Toggle(); + evt.SetInt(item->IsChecked()); } + GetEventHandler()->AddPendingEvent(evt); + break; } } } From 679d9351eadda908a3056994f26ef0db0eaecddd Mon Sep 17 00:00:00 2001 From: skidau Date: Sat, 28 Feb 2015 11:29:57 +1100 Subject: [PATCH 02/12] Fixed the Connect Wiimote hotkeys from getting activated while a GameCube game is running. --- Source/Core/DolphinWX/Frame.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/DolphinWX/Frame.cpp b/Source/Core/DolphinWX/Frame.cpp index 7e19c092fa..56a6d7402e 100644 --- a/Source/Core/DolphinWX/Frame.cpp +++ b/Source/Core/DolphinWX/Frame.cpp @@ -1433,7 +1433,7 @@ void CFrame::ParseHotkeys(wxKeyEvent &event) // Actually perform the Wiimote connection or disconnection if (Core::GetState() != Core::CORE_UNINITIALIZED) { - if (WiimoteId >= 0) + if (WiimoteId >= 0 && SConfig::GetInstance().m_LocalCoreStartupParameter.bWii) { wxCommandEvent evt; evt.SetId(IDM_CONNECT_WIIMOTE1 + WiimoteId); From d080632527de87eb39296bef5e77d05256f48643 Mon Sep 17 00:00:00 2001 From: skidau Date: Sat, 28 Feb 2015 15:57:41 +1100 Subject: [PATCH 03/12] Ignore the File Open command if a game is running --- Source/Core/DolphinWX/FrameTools.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Core/DolphinWX/FrameTools.cpp b/Source/Core/DolphinWX/FrameTools.cpp index 5ae3e62076..7ab7e9523c 100644 --- a/Source/Core/DolphinWX/FrameTools.cpp +++ b/Source/Core/DolphinWX/FrameTools.cpp @@ -686,7 +686,8 @@ void CFrame::BootGame(const std::string& filename) // Open file to boot void CFrame::OnOpen(wxCommandEvent& WXUNUSED (event)) { - DoOpen(true); + if (Core::GetState() == Core::CORE_UNINITIALIZED) + DoOpen(true); } void CFrame::DoOpen(bool Boot) From d2abbcd3533d3b0db6ff2194509c742fa1b33df8 Mon Sep 17 00:00:00 2001 From: skidau Date: Sat, 28 Feb 2015 16:40:24 +1100 Subject: [PATCH 04/12] Removed the requirement to have the Freelook option enabled for the freelook hotkeys to work. --- Source/Core/DolphinWX/Frame.cpp | 45 +++++++++++++++------------------ 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/Source/Core/DolphinWX/Frame.cpp b/Source/Core/DolphinWX/Frame.cpp index 56a6d7402e..be2f0c68dc 100644 --- a/Source/Core/DolphinWX/Frame.cpp +++ b/Source/Core/DolphinWX/Frame.cpp @@ -1440,30 +1440,27 @@ void CFrame::ParseHotkeys(wxKeyEvent &event) OnConnectWiimote(evt); } - if (g_Config.bFreeLook) - { - static float debugSpeed = 1.0f; + static float debugSpeed = 1.0f; - if (IsHotkey(event, HK_FREELOOK_DECREASE_SPEED)) - debugSpeed /= 2.0f; - else if (IsHotkey(event, HK_FREELOOK_INCREASE_SPEED)) - debugSpeed *= 2.0f; - else if (IsHotkey(event, HK_FREELOOK_RESET_SPEED)) - debugSpeed = 1.0f; - else if (IsHotkey(event, HK_FREELOOK_UP)) - VertexShaderManager::TranslateView(0.0f, 0.0f, -debugSpeed); - else if (IsHotkey(event, HK_FREELOOK_DOWN)) - VertexShaderManager::TranslateView(0.0f, 0.0f, debugSpeed); - else if (IsHotkey(event, HK_FREELOOK_LEFT)) - VertexShaderManager::TranslateView(debugSpeed, 0.0f); - else if (IsHotkey(event, HK_FREELOOK_RIGHT)) - VertexShaderManager::TranslateView(-debugSpeed, 0.0f); - else if (IsHotkey(event, HK_FREELOOK_ZOOM_IN)) - VertexShaderManager::TranslateView(0.0f, debugSpeed); - else if (IsHotkey(event, HK_FREELOOK_ZOOM_OUT)) - VertexShaderManager::TranslateView(0.0f, -debugSpeed); - else if (IsHotkey(event, HK_FREELOOK_RESET)) - VertexShaderManager::ResetView(); - } + if (IsHotkey(event, HK_FREELOOK_DECREASE_SPEED)) + debugSpeed /= 2.0f; + else if (IsHotkey(event, HK_FREELOOK_INCREASE_SPEED)) + debugSpeed *= 2.0f; + else if (IsHotkey(event, HK_FREELOOK_RESET_SPEED)) + debugSpeed = 1.0f; + else if (IsHotkey(event, HK_FREELOOK_UP)) + VertexShaderManager::TranslateView(0.0f, 0.0f, -debugSpeed); + else if (IsHotkey(event, HK_FREELOOK_DOWN)) + VertexShaderManager::TranslateView(0.0f, 0.0f, debugSpeed); + else if (IsHotkey(event, HK_FREELOOK_LEFT)) + VertexShaderManager::TranslateView(debugSpeed, 0.0f); + else if (IsHotkey(event, HK_FREELOOK_RIGHT)) + VertexShaderManager::TranslateView(-debugSpeed, 0.0f); + else if (IsHotkey(event, HK_FREELOOK_ZOOM_IN)) + VertexShaderManager::TranslateView(0.0f, debugSpeed); + else if (IsHotkey(event, HK_FREELOOK_ZOOM_OUT)) + VertexShaderManager::TranslateView(0.0f, -debugSpeed); + else if (IsHotkey(event, HK_FREELOOK_RESET)) + VertexShaderManager::ResetView(); } } From a83d27b9c2bcc1c5c617474edf84b6a24c722085 Mon Sep 17 00:00:00 2001 From: skidau Date: Sun, 1 Mar 2015 07:43:34 +1100 Subject: [PATCH 05/12] Increased the performance of the hotkey code by: * Halving the number of hotkeys checked for (there were extra for future use) * Gets the controller status once before parsing hotkeys * Checks for the GUI lock once before parsing hotkeys * Removed some redundant memsets --- Source/Core/Core/HotkeyManager.cpp | 41 ++++++++++++++---------------- Source/Core/Core/HotkeyManager.h | 5 ++-- Source/Core/DolphinWX/Frame.cpp | 4 +++ 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/Source/Core/Core/HotkeyManager.cpp b/Source/Core/Core/HotkeyManager.cpp index 8233b32d5e..9fc7208ddb 100644 --- a/Source/Core/Core/HotkeyManager.cpp +++ b/Source/Core/Core/HotkeyManager.cpp @@ -153,7 +153,8 @@ const int num_hotkeys = (sizeof(hotkey_labels) / sizeof(hotkey_labels[0])); namespace HotkeyManagerEmu { -static u32 hotkeyDown[6]; +static u32 hotkeyDown[3]; +static HotkeyStatus hotkey; static InputConfig s_config("Hotkeys", _trans("Hotkeys"), "Hotkeys"); InputConfig* GetConfig() @@ -161,31 +162,22 @@ InputConfig* GetConfig() return &s_config; } -void GetStatus(u8 _port, HotkeyStatus* _pHotkeyStatus) +void GetStatus() { - memset(_pHotkeyStatus, 0, sizeof(*_pHotkeyStatus)); - _pHotkeyStatus->err = PAD_ERR_NONE; - - std::unique_lock lk(s_config.controls_lock, std::try_to_lock); - - if (!lk.owns_lock()) - { - // if gui has lock (messing with controls), skip this input cycle - for (int i = 0; i < 6; i++) - _pHotkeyStatus->button[i] = 0; - - return; - } + hotkey.err = PAD_ERR_NONE; // get input - ((HotkeyManager*)s_config.controllers[_port])->GetInput(_pHotkeyStatus); + ((HotkeyManager*)s_config.controllers[0])->GetInput(&hotkey); +} + +bool IsReady() +{ + std::unique_lock lk(s_config.controls_lock, std::try_to_lock); + return lk.owns_lock(); } bool IsPressed(int Id, bool held) { - HotkeyStatus hotkey; - memset(&hotkey, 0, sizeof(hotkey)); - GetStatus(0, &hotkey); unsigned int set = Id / 32; unsigned int setKey = Id % 32; if (hotkey.button[set] & (1 << setKey)) @@ -215,7 +207,7 @@ void Initialize(void* const hwnd) // load the saved controller config s_config.LoadConfig(true); - for (unsigned int i = 0; i < 6; ++i) + for (unsigned int i = 0; i < 3; ++i) hotkeyDown[i] = 0; } @@ -235,7 +227,7 @@ void Shutdown() HotkeyManager::HotkeyManager() { - for (int set = 0; set < 6; set++) + for (int set = 0; set < 3; set++) { // buttons if ((set * 32) < num_hotkeys) @@ -266,9 +258,14 @@ std::string HotkeyManager::GetName() const void HotkeyManager::GetInput(HotkeyStatus* const kb) { - for (int set = 0; set < 6; set++) + for (int set = 0; set < 3; set++) + { if ((set * 32) < num_hotkeys) + { + kb->button[set] = 0; m_keys[set]->GetState(&kb->button[set], hotkey_bitmasks); + } + } } void HotkeyManager::LoadDefaults(const ControllerInterface& ciface) diff --git a/Source/Core/Core/HotkeyManager.h b/Source/Core/Core/HotkeyManager.h index 1e03163def..6095db4906 100644 --- a/Source/Core/Core/HotkeyManager.h +++ b/Source/Core/Core/HotkeyManager.h @@ -24,7 +24,7 @@ public: void LoadDefaults(const ControllerInterface& ciface); private: - Buttons* m_keys[6]; + Buttons* m_keys[3]; ControlGroup* m_options; }; @@ -34,6 +34,7 @@ namespace HotkeyManagerEmu void Shutdown(); InputConfig* GetConfig(); - void GetStatus(u8 _port, HotkeyStatus* _pKeyboardStatus); + void GetStatus(); + bool IsReady(); bool IsPressed(int Id, bool held); } diff --git a/Source/Core/DolphinWX/Frame.cpp b/Source/Core/DolphinWX/Frame.cpp index be2f0c68dc..8906dba1f6 100644 --- a/Source/Core/DolphinWX/Frame.cpp +++ b/Source/Core/DolphinWX/Frame.cpp @@ -1263,11 +1263,15 @@ const CGameListCtrl *CFrame::GetGameListCtrl() const void CFrame::PollHotkeys(wxTimerEvent& event) { + if (!HotkeyManagerEmu::IsReady()) + return; + if (Core::GetState() == Core::CORE_UNINITIALIZED || Core::GetState() == Core::CORE_PAUSE) g_controller_interface.UpdateInput(); if (Core::GetState() != Core::CORE_STOPPING) { + HotkeyManagerEmu::GetStatus(); wxKeyEvent keyevent = 0; if (IsHotkey(keyevent, HK_TOGGLE_THROTTLE)) From 099876782fa1dde03d428738fb7dd17aeff8cc35 Mon Sep 17 00:00:00 2001 From: skidau Date: Sun, 1 Mar 2015 08:23:15 +1100 Subject: [PATCH 06/12] Made the "Frame Advance" hotkey work while the key is held --- Source/Core/DolphinWX/Frame.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Source/Core/DolphinWX/Frame.cpp b/Source/Core/DolphinWX/Frame.cpp index 8906dba1f6..5a4e674f32 100644 --- a/Source/Core/DolphinWX/Frame.cpp +++ b/Source/Core/DolphinWX/Frame.cpp @@ -1404,7 +1404,11 @@ void CFrame::ParseHotkeys(wxKeyEvent &event) unsigned int i = NUM_HOTKEYS; for (i = 0; i < NUM_HOTKEYS; i++) { - if (IsHotkey(event, i)) + bool held = false; + if (i == HK_FRAME_ADVANCE) + held = true; + + if (IsHotkey(event, i, held)) { int cmd = GetCmdForHotkey(i); if (cmd >= 0) From b446ea013241fc28797f5bfdfdb40b374394baed Mon Sep 17 00:00:00 2001 From: skidau Date: Sun, 1 Mar 2015 15:21:53 +1100 Subject: [PATCH 07/12] Made the freelook keys work while held down --- Source/Core/DolphinWX/Frame.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Source/Core/DolphinWX/Frame.cpp b/Source/Core/DolphinWX/Frame.cpp index 5a4e674f32..9352dcb367 100644 --- a/Source/Core/DolphinWX/Frame.cpp +++ b/Source/Core/DolphinWX/Frame.cpp @@ -937,7 +937,7 @@ void CFrame::OnGameListCtrl_ItemActivated(wxListEvent& WXUNUSED(event)) } } -static bool IsHotkey(wxKeyEvent &event, int Id, bool keyUp = false) +static bool IsHotkey(wxKeyEvent &event, int id, bool held = false) { if (Core::GetState() == Core::CORE_UNINITIALIZED) return false; @@ -945,7 +945,7 @@ static bool IsHotkey(wxKeyEvent &event, int Id, bool keyUp = false) // Input event hotkey if (event.GetKeyCode() == WXK_NONE) { - return HotkeyManagerEmu::IsPressed(Id, keyUp); + return HotkeyManagerEmu::IsPressed(id, held); } return false; @@ -1450,25 +1450,25 @@ void CFrame::ParseHotkeys(wxKeyEvent &event) static float debugSpeed = 1.0f; - if (IsHotkey(event, HK_FREELOOK_DECREASE_SPEED)) + if (IsHotkey(event, HK_FREELOOK_DECREASE_SPEED, true)) debugSpeed /= 2.0f; - else if (IsHotkey(event, HK_FREELOOK_INCREASE_SPEED)) + else if (IsHotkey(event, HK_FREELOOK_INCREASE_SPEED, true)) debugSpeed *= 2.0f; - else if (IsHotkey(event, HK_FREELOOK_RESET_SPEED)) + else if (IsHotkey(event, HK_FREELOOK_RESET_SPEED, true)) debugSpeed = 1.0f; - else if (IsHotkey(event, HK_FREELOOK_UP)) + else if (IsHotkey(event, HK_FREELOOK_UP, true)) VertexShaderManager::TranslateView(0.0f, 0.0f, -debugSpeed); - else if (IsHotkey(event, HK_FREELOOK_DOWN)) + else if (IsHotkey(event, HK_FREELOOK_DOWN, true)) VertexShaderManager::TranslateView(0.0f, 0.0f, debugSpeed); - else if (IsHotkey(event, HK_FREELOOK_LEFT)) + else if (IsHotkey(event, HK_FREELOOK_LEFT, true)) VertexShaderManager::TranslateView(debugSpeed, 0.0f); - else if (IsHotkey(event, HK_FREELOOK_RIGHT)) + else if (IsHotkey(event, HK_FREELOOK_RIGHT, true)) VertexShaderManager::TranslateView(-debugSpeed, 0.0f); - else if (IsHotkey(event, HK_FREELOOK_ZOOM_IN)) + else if (IsHotkey(event, HK_FREELOOK_ZOOM_IN, true)) VertexShaderManager::TranslateView(0.0f, debugSpeed); - else if (IsHotkey(event, HK_FREELOOK_ZOOM_OUT)) + else if (IsHotkey(event, HK_FREELOOK_ZOOM_OUT, true)) VertexShaderManager::TranslateView(0.0f, -debugSpeed); - else if (IsHotkey(event, HK_FREELOOK_RESET)) + else if (IsHotkey(event, HK_FREELOOK_RESET, true)) VertexShaderManager::ResetView(); } } From 780eef68f6ec7deee1a11f8bc1386f70133b6cc0 Mon Sep 17 00:00:00 2001 From: skidau Date: Thu, 5 Mar 2015 19:49:10 +1100 Subject: [PATCH 08/12] Fixed the crash that would occur when the Refresh button was pressed in the controllers config. - Simplified the locking mechanism when controllers were updated - Reloaded the config of the controls instead of re-initialising the control plugins - Fixed controls being unresponsive after the Refresh button was pressed - Disables the hotkeys while the controller config is open --- Source/Core/Core/Core.cpp | 11 +++- Source/Core/Core/HW/GCKeyboard.cpp | 18 ++----- Source/Core/Core/HW/GCKeyboard.h | 1 + Source/Core/Core/HW/GCPad.cpp | 21 +++----- Source/Core/Core/HW/GCPad.h | 1 + Source/Core/Core/HW/Wiimote.cpp | 8 ++- Source/Core/Core/HW/Wiimote.h | 1 + Source/Core/Core/HotkeyManager.cpp | 18 +++++-- Source/Core/Core/HotkeyManager.h | 6 ++- .../Core/DolphinWX/ControllerConfigDiag.cpp | 53 ++++--------------- Source/Core/DolphinWX/Frame.cpp | 2 +- Source/Core/DolphinWX/FrameTools.cpp | 31 ++++++----- Source/Core/DolphinWX/InputConfigDiag.cpp | 14 +++++ .../ControllerInterface.cpp | 3 -- Source/Core/InputCommon/InputConfig.cpp | 7 --- Source/Core/InputCommon/InputConfig.h | 2 - 16 files changed, 93 insertions(+), 104 deletions(-) diff --git a/Source/Core/Core/Core.cpp b/Source/Core/Core/Core.cpp index f4190aa72c..113ac0e553 100644 --- a/Source/Core/Core/Core.cpp +++ b/Source/Core/Core/Core.cpp @@ -427,11 +427,20 @@ void EmuThread() Keyboard::Initialize(s_window_handle); init_controllers = true; } + else + { + // Update references in case controllers were refreshed + Pad::LoadConfig(); + Keyboard::LoadConfig(); + } // Load and Init Wiimotes - only if we are booting in Wii mode if (core_parameter.bWii) { - Wiimote::Initialize(s_window_handle, !s_state_filename.empty()); + if (init_controllers) + Wiimote::Initialize(s_window_handle, !s_state_filename.empty()); + else + Wiimote::LoadConfig(); // Activate Wiimotes which don't have source set to "None" for (unsigned int i = 0; i != MAX_BBMOTES; ++i) diff --git a/Source/Core/Core/HW/GCKeyboard.cpp b/Source/Core/Core/HW/GCKeyboard.cpp index 1e57e8e802..d6ac24e637 100644 --- a/Source/Core/Core/HW/GCKeyboard.cpp +++ b/Source/Core/Core/HW/GCKeyboard.cpp @@ -45,6 +45,11 @@ void Initialize(void* const hwnd) s_config.LoadConfig(true); } +void LoadConfig() +{ + s_config.LoadConfig(true); +} + void GetStatus(u8 _port, KeyboardStatus* _pKeyboardStatus) { memset(_pKeyboardStatus, 0, sizeof(*_pKeyboardStatus)); @@ -52,19 +57,6 @@ void GetStatus(u8 _port, KeyboardStatus* _pKeyboardStatus) std::unique_lock lk(s_config.controls_lock, std::try_to_lock); - if (!lk.owns_lock()) - { - // if gui has lock (messing with controls), skip this input cycle - // center axes and return - _pKeyboardStatus->key0x = 0; - _pKeyboardStatus->key1x = 0; - _pKeyboardStatus->key2x = 0; - _pKeyboardStatus->key3x = 0; - _pKeyboardStatus->key4x = 0; - _pKeyboardStatus->key5x = 0; - return; - } - // get input ((GCKeyboard*)s_config.controllers[_port])->GetInput(_pKeyboardStatus); } diff --git a/Source/Core/Core/HW/GCKeyboard.h b/Source/Core/Core/HW/GCKeyboard.h index 407b822db1..f535567381 100644 --- a/Source/Core/Core/HW/GCKeyboard.h +++ b/Source/Core/Core/HW/GCKeyboard.h @@ -13,6 +13,7 @@ namespace Keyboard void Shutdown(); void Initialize(void* const hwnd); +void LoadConfig(); InputConfig* GetConfig(); diff --git a/Source/Core/Core/HW/GCPad.cpp b/Source/Core/Core/HW/GCPad.cpp index 34ae9ea618..b57a6d02f2 100644 --- a/Source/Core/Core/HW/GCPad.cpp +++ b/Source/Core/Core/HW/GCPad.cpp @@ -46,6 +46,12 @@ void Initialize(void* const hwnd) s_config.LoadConfig(true); } +void LoadConfig() +{ + s_config.LoadConfig(true); +} + + void GetStatus(u8 _numPAD, GCPadStatus* _pPADStatus) { memset(_pPADStatus, 0, sizeof(*_pPADStatus)); @@ -53,16 +59,6 @@ void GetStatus(u8 _numPAD, GCPadStatus* _pPADStatus) std::unique_lock lk(s_config.controls_lock, std::try_to_lock); - if (!lk.owns_lock()) - { - // if gui has lock (messing with controls), skip this input cycle - // center axes and return - _pPADStatus->stickX = GCPadStatus::MAIN_STICK_CENTER_X; - _pPADStatus->stickY = GCPadStatus::MAIN_STICK_CENTER_Y; - _pPADStatus->substickX = GCPadStatus::C_STICK_CENTER_X; - _pPADStatus->substickY = GCPadStatus::C_STICK_CENTER_Y; - return; - } // get input ((GCPad*)s_config.controllers[_numPAD])->GetInput(_pPADStatus); @@ -72,9 +68,6 @@ void Rumble(u8 _numPAD, const ControlState strength) { std::unique_lock lk(s_config.controls_lock, std::try_to_lock); - if (!lk.owns_lock()) - return; - ((GCPad*)s_config.controllers[ _numPAD ])->SetOutput(strength); } @@ -83,8 +76,6 @@ bool GetMicButton(u8 pad) std::unique_lock lk(s_config.controls_lock, std::try_to_lock); - if (!lk.owns_lock()) - return false; return ((GCPad*)s_config.controllers[pad])->GetMicButton(); } diff --git a/Source/Core/Core/HW/GCPad.h b/Source/Core/Core/HW/GCPad.h index d9da72e9fc..5d70f9274c 100644 --- a/Source/Core/Core/HW/GCPad.h +++ b/Source/Core/Core/HW/GCPad.h @@ -13,6 +13,7 @@ namespace Pad void Shutdown(); void Initialize(void* const hwnd); +void LoadConfig(); InputConfig* GetConfig(); diff --git a/Source/Core/Core/HW/Wiimote.cpp b/Source/Core/Core/HW/Wiimote.cpp index 357b3b1fea..756384ca30 100644 --- a/Source/Core/Core/HW/Wiimote.cpp +++ b/Source/Core/Core/HW/Wiimote.cpp @@ -55,6 +55,12 @@ void Initialize(void* const hwnd, bool wait) Movie::ChangeWiiPads(); } +void LoadConfig() +{ + s_config.LoadConfig(true); +} + + void Resume() { WiimoteReal::Resume(); @@ -113,7 +119,7 @@ void Update(int _number) //PanicAlert( "Wiimote_Update" ); // TODO: change this to a try_to_lock, and make it give empty input on failure - std::lock_guard lk(s_config.controls_lock); + std::unique_lock lk(s_config.controls_lock, std::try_to_lock); if (WIIMOTE_SRC_EMU & g_wiimote_sources[_number]) ((WiimoteEmu::Wiimote*)s_config.controllers[_number])->Update(); diff --git a/Source/Core/Core/HW/Wiimote.h b/Source/Core/Core/HW/Wiimote.h index 71fa2d28b6..81f2e83c5c 100644 --- a/Source/Core/Core/HW/Wiimote.h +++ b/Source/Core/Core/HW/Wiimote.h @@ -36,6 +36,7 @@ namespace Wiimote void Shutdown(); void Initialize(void* const hwnd, bool wait = false); +void LoadConfig(); void Resume(); void Pause(); diff --git a/Source/Core/Core/HotkeyManager.cpp b/Source/Core/Core/HotkeyManager.cpp index 9fc7208ddb..fd25108a5e 100644 --- a/Source/Core/Core/HotkeyManager.cpp +++ b/Source/Core/Core/HotkeyManager.cpp @@ -157,6 +157,7 @@ static u32 hotkeyDown[3]; static HotkeyStatus hotkey; static InputConfig s_config("Hotkeys", _trans("Hotkeys"), "Hotkeys"); + InputConfig* GetConfig() { return &s_config; @@ -170,10 +171,14 @@ void GetStatus() ((HotkeyManager*)s_config.controllers[0])->GetInput(&hotkey); } -bool IsReady() +bool IsEnabled() { - std::unique_lock lk(s_config.controls_lock, std::try_to_lock); - return lk.owns_lock(); + return enabled; +} + +void Enable(bool enable_toggle) +{ + enabled = enable_toggle; } bool IsPressed(int Id, bool held) @@ -209,6 +214,13 @@ void Initialize(void* const hwnd) for (unsigned int i = 0; i < 3; ++i) hotkeyDown[i] = 0; + + enabled = true; +} + +void LoadConfig() +{ + s_config.LoadConfig(true); } void Shutdown() diff --git a/Source/Core/Core/HotkeyManager.h b/Source/Core/Core/HotkeyManager.h index 6095db4906..bd76395046 100644 --- a/Source/Core/Core/HotkeyManager.h +++ b/Source/Core/Core/HotkeyManager.h @@ -32,9 +32,13 @@ namespace HotkeyManagerEmu { void Initialize(void* const hwnd); void Shutdown(); + void LoadConfig(); InputConfig* GetConfig(); void GetStatus(); - bool IsReady(); + bool IsEnabled(); + void Enable(bool enable_toggle); bool IsPressed(int Id, bool held); + + static bool enabled; } diff --git a/Source/Core/DolphinWX/ControllerConfigDiag.cpp b/Source/Core/DolphinWX/ControllerConfigDiag.cpp index 909f70b1b1..6f3ae906f5 100644 --- a/Source/Core/DolphinWX/ControllerConfigDiag.cpp +++ b/Source/Core/DolphinWX/ControllerConfigDiag.cpp @@ -23,6 +23,7 @@ #include "Common/SysConf.h" #include "Core/ConfigManager.h" #include "Core/Core.h" +#include "Core/HotkeyManager.h" #include "Core/Movie.h" #include "Core/NetPlayProto.h" #include "Core/HW/GCKeyboard.h" @@ -207,12 +208,13 @@ wxStaticBoxSizer* ControllerConfigDiag::CreateWiimoteConfigSizer() wiimote_configure_bt[i]->Bind(wxEVT_BUTTON, &ControllerConfigDiag::ConfigEmulatedWiimote, this); // Disable controller type selection for certain circumstances. - if (NetPlay::IsNetPlayRunning() || Movie::IsMovieActive()) + bool wii_game_started = SConfig::GetInstance().m_LocalCoreStartupParameter.bWii || Core::GetState() == Core::CORE_UNINITIALIZED; + if (NetPlay::IsNetPlayRunning() || Movie::IsMovieActive() || !wii_game_started) wiimote_source_ch[i]->Disable(); m_orig_wiimote_sources[i] = g_wiimote_sources[i]; wiimote_source_ch[i]->Select(m_orig_wiimote_sources[i]); - if (m_orig_wiimote_sources[i] != WIIMOTE_SRC_EMU && m_orig_wiimote_sources[i] != WIIMOTE_SRC_HYBRID) + if (!wii_game_started || (m_orig_wiimote_sources[i] != WIIMOTE_SRC_EMU && m_orig_wiimote_sources[i] != WIIMOTE_SRC_HYBRID)) wiimote_configure_bt[i]->Disable(); } @@ -390,28 +392,13 @@ wxStaticBoxSizer* ControllerConfigDiag::CreateGeneralWiimoteSettingsSizer() void ControllerConfigDiag::ConfigEmulatedWiimote(wxCommandEvent& ev) { InputConfig* const wiimote_plugin = Wiimote::GetConfig(); - bool was_init = false; - if (g_controller_interface.IsInit()) // check if game is running - { - was_init = true; - } - else - { -#if defined(HAVE_X11) && HAVE_X11 - Window win = X11Utils::XWindowFromHandle(GetHandle()); - Wiimote::Initialize(reinterpret_cast(win)); -#else - Wiimote::Initialize(reinterpret_cast(GetHandle())); -#endif - } + + HotkeyManagerEmu::Enable(false); InputConfigDialog m_ConfigFrame(this, *wiimote_plugin, _("Dolphin Emulated Wiimote Configuration"), m_wiimote_index_from_conf_bt_id[ev.GetId()]); m_ConfigFrame.ShowModal(); - if (!was_init) // if game isn't running - { - Wiimote::Shutdown(); - } + HotkeyManagerEmu::Enable(true); } void ControllerConfigDiag::RefreshRealWiimotes(wxCommandEvent&) @@ -535,24 +522,7 @@ void ControllerConfigDiag::OnGameCubeConfigButton(wxCommandEvent& event) InputConfig* const key_plugin = Keyboard::GetConfig(); const int port_num = m_gc_port_config_ids[event.GetId()]; - bool was_init = false; - - // check if game is running - if (g_controller_interface.IsInit()) - { - was_init = true; - } - else - { -#if defined(HAVE_X11) && HAVE_X11 - Window win = X11Utils::XWindowFromHandle(GetHandle()); - Pad::Initialize(reinterpret_cast(win)); - Keyboard::Initialize(reinterpret_cast(win)); -#else - Pad::Initialize(reinterpret_cast(GetHandle())); - Keyboard::Initialize(reinterpret_cast(GetHandle())); -#endif - } + HotkeyManagerEmu::Enable(false); if (SConfig::GetInstance().m_SIDevice[port_num] == SIDEVICE_GC_KEYBOARD) { @@ -565,10 +535,5 @@ void ControllerConfigDiag::OnGameCubeConfigButton(wxCommandEvent& event) m_ConfigFrame.ShowModal(); } - // if game isn't running - if (!was_init) - { - Keyboard::Shutdown(); - Pad::Shutdown(); - } + HotkeyManagerEmu::Enable(true); } diff --git a/Source/Core/DolphinWX/Frame.cpp b/Source/Core/DolphinWX/Frame.cpp index 9352dcb367..b6b28a57f2 100644 --- a/Source/Core/DolphinWX/Frame.cpp +++ b/Source/Core/DolphinWX/Frame.cpp @@ -1263,7 +1263,7 @@ const CGameListCtrl *CFrame::GetGameListCtrl() const void CFrame::PollHotkeys(wxTimerEvent& event) { - if (!HotkeyManagerEmu::IsReady()) + if (!HotkeyManagerEmu::IsEnabled()) return; if (Core::GetState() == Core::CORE_UNINITIALIZED || Core::GetState() == Core::CORE_PAUSE) diff --git a/Source/Core/DolphinWX/FrameTools.cpp b/Source/Core/DolphinWX/FrameTools.cpp index 7ab7e9523c..04534a48fb 100644 --- a/Source/Core/DolphinWX/FrameTools.cpp +++ b/Source/Core/DolphinWX/FrameTools.cpp @@ -51,6 +51,7 @@ #include "Core/State.h" #include "Core/HW/CPU.h" #include "Core/HW/DVDInterface.h" +#include "Core/HW/GCKeyboard.h" #include "Core/HW/GCPad.h" #include "Core/HW/ProcessorInterface.h" #include "Core/HW/SI_Device.h" @@ -1366,27 +1367,31 @@ void CFrame::OnConfigHotkey(wxCommandEvent& WXUNUSED (event)) InputConfig* const hotkey_plugin = HotkeyManagerEmu::GetConfig(); // check if game is running - if (g_controller_interface.IsInit()) + bool game_running = false; + if (Core::GetState() == Core::CORE_RUN) { - was_init = true; - } - else - { -#if defined(HAVE_X11) && HAVE_X11 - Window win = X11Utils::XWindowFromHandle(GetHandle()); - HotkeyManagerEmu::Initialize(reinterpret_cast(win)); -#else - HotkeyManagerEmu::Initialize(reinterpret_cast(GetHandle())); -#endif + Core::SetState(Core::CORE_PAUSE); + game_running = true; } + HotkeyManagerEmu::Enable(false); + InputConfigDialog m_ConfigFrame(this, *hotkey_plugin, _("Dolphin Hotkeys")); m_ConfigFrame.ShowModal(); + // Update references in case controllers were refreshed + if (SConfig::GetInstance().m_LocalCoreStartupParameter.bWii) + Wiimote::LoadConfig(); + Keyboard::LoadConfig(); + Pad::LoadConfig(); + HotkeyManagerEmu::LoadConfig(); + + HotkeyManagerEmu::Enable(true); + // if game isn't running - if (!was_init) + if (game_running) { - HotkeyManagerEmu::Shutdown(); + Core::SetState(Core::CORE_RUN); } // Update the GUI in case menu accelerators were changed diff --git a/Source/Core/DolphinWX/InputConfigDiag.cpp b/Source/Core/DolphinWX/InputConfigDiag.cpp index 653f92ea11..d45458535a 100644 --- a/Source/Core/DolphinWX/InputConfigDiag.cpp +++ b/Source/Core/DolphinWX/InputConfigDiag.cpp @@ -44,6 +44,10 @@ #include "Common/FileUtil.h" #include "Common/IniFile.h" #include "Common/MsgHandler.h" +#include "Core/Core.h" +#include "Core/HotkeyManager.h" +#include "Core/HW/GCKeyboard.h" +#include "Core/HW/GCPad.h" #include "Core/HW/Wiimote.h" #include "DolphinWX/InputConfigDiag.h" #include "DolphinWX/WxUtils.h" @@ -740,6 +744,8 @@ void InputConfigDialog::UpdateDeviceComboBox() void GamepadPage::RefreshDevices(wxCommandEvent&) { + bool was_unpaused = Core::PauseAndLock(true); + std::lock_guard lk(m_config.controls_lock); // refresh devices @@ -750,6 +756,14 @@ void GamepadPage::RefreshDevices(wxCommandEvent&) // update device cbox m_config_dialog->UpdateDeviceComboBox(); + + //if (SConfig::GetInstance().m_LocalCoreStartupParameter.bWii) + Wiimote::LoadConfig(); + Keyboard::LoadConfig(); + Pad::LoadConfig(); + HotkeyManagerEmu::LoadConfig(); + + Core::PauseAndLock(false, was_unpaused); } ControlGroupBox::~ControlGroupBox() diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp index 3eb1b95ff2..1330cb1e0a 100644 --- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp +++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp @@ -136,9 +136,6 @@ void ControllerInterface::UpdateInput() { std::unique_lock lk(update_lock, std::defer_lock); - if (!lk.try_lock()) - return; - for (ciface::Core::Device* d : m_devices) d->UpdateInput(); } diff --git a/Source/Core/InputCommon/InputConfig.cpp b/Source/Core/InputCommon/InputConfig.cpp index da5bb5081a..ef517d407d 100644 --- a/Source/Core/InputCommon/InputConfig.cpp +++ b/Source/Core/InputCommon/InputConfig.cpp @@ -7,13 +7,6 @@ #include "Core/HW/Wiimote.h" #include "InputCommon/InputConfig.h" -InputConfig::~InputConfig() -{ - // delete pads - for (ControllerEmu* pad : controllers) - delete pad; -} - bool InputConfig::LoadConfig(bool isGC) { IniFile inifile; diff --git a/Source/Core/InputCommon/InputConfig.h b/Source/Core/InputCommon/InputConfig.h index e6e80c83fc..a234cdf167 100644 --- a/Source/Core/InputCommon/InputConfig.h +++ b/Source/Core/InputCommon/InputConfig.h @@ -21,8 +21,6 @@ public: const char* const _profile_name) : ini_name(_ini_name), gui_name(_gui_name), profile_name(_profile_name) {} - ~InputConfig(); - bool LoadConfig(bool isGC); void SaveConfig(); From 12ecc537e9251da148e1d6ef3f7d1759fc6b7673 Mon Sep 17 00:00:00 2001 From: skidau Date: Fri, 6 Mar 2015 11:54:29 +1100 Subject: [PATCH 09/12] Renamed the Menu Accelerators to Key Shortcuts. Cleared the default mapping of hotkeys as they were conflicting with the key shortcuts. Removed the Open, Change Disc, Refresh List and Exit hotkeys as they work only when driven from the menu. --- Source/Core/Core/HotkeyManager.cpp | 313 +++++---------------------- Source/Core/DolphinWX/Frame.cpp | 2 +- Source/Core/DolphinWX/FrameTools.cpp | 4 +- Source/Core/DolphinWX/HotkeyDlg.h | 2 +- 4 files changed, 56 insertions(+), 265 deletions(-) diff --git a/Source/Core/Core/HotkeyManager.cpp b/Source/Core/Core/HotkeyManager.cpp index fd25108a5e..9b7c0f2436 100644 --- a/Source/Core/Core/HotkeyManager.cpp +++ b/Source/Core/Core/HotkeyManager.cpp @@ -6,47 +6,11 @@ #include "Core/CoreParameter.h" #include "Core/HotkeyManager.h" -static const u32 hotkey_bitmasks[] = -{ - 1 << 0, - 1 << 1, - 1 << 2, - 1 << 3, - 1 << 4, - 1 << 5, - 1 << 6, - 1 << 7, - 1 << 8, - 1 << 9, - 1 << 10, - 1 << 11, - 1 << 12, - 1 << 13, - 1 << 14, - 1 << 15, - 1 << 16, - 1 << 17, - 1 << 18, - 1 << 19, - 1 << 20, - 1 << 21, - 1 << 22, - 1 << 23, - 1 << 24, - 1 << 25, - 1 << 26, - 1 << 27, - 1 << 28, - 1 << 29, - 1 << 30, - 1u << 31u -}; - const std::string hotkey_labels[] = { - _trans("Open"), - _trans("Change Disc"), - _trans("Refresh List"), + (""), // Open + (""), // Change Disc + (""), // Refresh List _trans("Toggle Pause"), _trans("Stop"), @@ -60,7 +24,7 @@ const std::string hotkey_labels[] = _trans("Toggle Fullscreen"), _trans("Take Screenshot"), - _trans("Exit"), + (""), // Exit _trans("Connect Wiimote 1"), _trans("Connect Wiimote 2"), @@ -247,7 +211,7 @@ HotkeyManager::HotkeyManager() for (int key = 0; key < 32; key++) { - if ((set * 32 + key) < num_hotkeys) + if ((set * 32 + key) < num_hotkeys && hotkey_labels[set * 32 + key].length() != 0) { m_keys[set]->controls.emplace_back(new ControlGroup::Input(hotkey_labels[set * 32 + key])); } @@ -272,10 +236,17 @@ void HotkeyManager::GetInput(HotkeyStatus* const kb) { for (int set = 0; set < 3; set++) { + std::vector bitmasks; + for (int key = 0; key < 32; key++) + { + if (hotkey_labels[set * 32 + key].length() != 0) + bitmasks.push_back(1 << key); + } + if ((set * 32) < num_hotkeys) { kb->button[set] = 0; - m_keys[set]->GetState(&kb->button[set], hotkey_bitmasks); + m_keys[set]->GetState(&kb->button[set], bitmasks.data()); } } } @@ -287,26 +258,25 @@ void HotkeyManager::LoadDefaults(const ControllerInterface& ciface) ControllerEmu::LoadDefaults(ciface); // Buttons -#ifdef _WIN32 - set_control(m_keys[0], 0, "(LCONTROL | RCONTROL) & L"); // Open + set_control(m_keys[0], 0, ""); // Open set_control(m_keys[0], 1, ""); // ChangeDisc set_control(m_keys[0], 2, ""); // RefreshList - set_control(m_keys[0], 3, "F10"); // PlayPause - set_control(m_keys[0], 4, "ESCAPE"); // Stop + set_control(m_keys[0], 3, ""); // PlayPause + set_control(m_keys[0], 4, ""); // Stop set_control(m_keys[0], 5, ""); // Reset set_control(m_keys[0], 6, ""); // FrameAdvance set_control(m_keys[0], 7, ""); // StartRecording set_control(m_keys[0], 8, ""); // PlayRecording set_control(m_keys[0], 9, ""); // ExportRecording set_control(m_keys[0], 10, ""); // Readonlymode - set_control(m_keys[0], 11, "(LMENU | RMENU) & RETURN"); // ToggleFullscreen - set_control(m_keys[0], 12, "`F9` & !(LMENU | RMENU)"); // Screenshot + set_control(m_keys[0], 11, ""); // ToggleFullscreen + set_control(m_keys[0], 12, ""); // Screenshot set_control(m_keys[0], 13, ""); // Exit - set_control(m_keys[0], 14, "(LMENU | RMENU) & `F5`"); // Wiimote1Connect - set_control(m_keys[0], 15, "(LMENU | RMENU) & `F6`"); // Wiimote2Connect - set_control(m_keys[0], 16, "(LMENU | RMENU) & `F7`"); // Wiimote3Connect - set_control(m_keys[0], 17, "(LMENU | RMENU) & `F8`"); // Wiimote4Connect - set_control(m_keys[0], 18, "(LMENU | RMENU) & `F9`"); // BalanceBoardConnect + set_control(m_keys[0], 14, ""); // Wiimote1Connect + set_control(m_keys[0], 15, ""); // Wiimote2Connect + set_control(m_keys[0], 16, ""); // Wiimote3Connect + set_control(m_keys[0], 17, ""); // Wiimote4Connect + set_control(m_keys[0], 18, ""); // BalanceBoardConnect set_control(m_keys[0], 19, ""); // VolumeDown set_control(m_keys[0], 20, ""); // VolumeUp set_control(m_keys[0], 21, ""); // VolumeToggleMute @@ -314,41 +284,41 @@ void HotkeyManager::LoadDefaults(const ControllerInterface& ciface) set_control(m_keys[0], 23, ""); // ToggleAspectRatio set_control(m_keys[0], 24, ""); // ToggleEFBCopies set_control(m_keys[0], 25, ""); // ToggleFog - set_control(m_keys[0], 26, "TAB"); // ToggleThrottle + set_control(m_keys[0], 26, ""); // ToggleThrottle set_control(m_keys[0], 27, ""); // DecreaseFrameLimit set_control(m_keys[0], 28, ""); // IncreaseFrameLimit - set_control(m_keys[0], 29, "1"); // FreelookDecreaseSpeed - set_control(m_keys[0], 30, "2"); // FreelookIncreaseSpeed - set_control(m_keys[0], 31, "F"); // FreelookResetSpeed - set_control(m_keys[1], 0, "E"); // FreelookUp - set_control(m_keys[1], 1, "Q"); // FreelookDown - set_control(m_keys[1], 2, "A"); // FreelookLeft - set_control(m_keys[1], 3, "D"); // FreelookRight - set_control(m_keys[1], 4, "W"); // FreelookZoomIn - set_control(m_keys[1], 5, "S"); // FreelookZoomOut - set_control(m_keys[1], 6, "R"); // FreelookReset + set_control(m_keys[0], 29, ""); // FreelookDecreaseSpeed + set_control(m_keys[0], 30, ""); // FreelookIncreaseSpeed + set_control(m_keys[0], 31, ""); // FreelookResetSpeed + set_control(m_keys[1], 0, ""); // FreelookUp + set_control(m_keys[1], 1, ""); // FreelookDown + set_control(m_keys[1], 2, ""); // FreelookLeft + set_control(m_keys[1], 3, ""); // FreelookRight + set_control(m_keys[1], 4, ""); // FreelookZoomIn + set_control(m_keys[1], 5, ""); // FreelookZoomOut + set_control(m_keys[1], 6, ""); // FreelookReset set_control(m_keys[1], 7, ""); // DecreaseDepth set_control(m_keys[1], 8, ""); // IncreaseDepth set_control(m_keys[1], 9, ""); // DecreaseConvergence set_control(m_keys[1], 10, ""); // IncreaseConvergence - set_control(m_keys[1], 11, "`F1` & !(LSHIFT | RSHIFT) & !(LMENU | RMENU)"); // LoadStateSlot1 - set_control(m_keys[1], 12, "`F2` & !(LSHIFT | RSHIFT) & !(LMENU | RMENU)"); // LoadStateSlot2 - set_control(m_keys[1], 13, "`F3` & !(LSHIFT | RSHIFT) & !(LMENU | RMENU)"); // LoadStateSlot3 - set_control(m_keys[1], 14, "`F4` & !(LSHIFT | RSHIFT) & !(LMENU | RMENU)"); // LoadStateSlot4 - set_control(m_keys[1], 15, "`F5` & !(LSHIFT | RSHIFT) & !(LMENU | RMENU)"); // LoadStateSlot5 - set_control(m_keys[1], 16, "`F6` & !(LSHIFT | RSHIFT) & !(LMENU | RMENU)"); // LoadStateSlot6 - set_control(m_keys[1], 17, "`F7` & !(LSHIFT | RSHIFT) & !(LMENU | RMENU)"); // LoadStateSlot7 - set_control(m_keys[1], 18, "`F8` & !(LSHIFT | RSHIFT) & !(LMENU | RMENU)"); // LoadStateSlot8 + set_control(m_keys[1], 11, ""); // LoadStateSlot1 + set_control(m_keys[1], 12, ""); // LoadStateSlot2 + set_control(m_keys[1], 13, ""); // LoadStateSlot3 + set_control(m_keys[1], 14, ""); // LoadStateSlot4 + set_control(m_keys[1], 15, ""); // LoadStateSlot5 + set_control(m_keys[1], 16, ""); // LoadStateSlot6 + set_control(m_keys[1], 17, ""); // LoadStateSlot7 + set_control(m_keys[1], 18, ""); // LoadStateSlot8 set_control(m_keys[1], 19, ""); // LoadStateSlot9 set_control(m_keys[1], 20, ""); // LoadStateSlot10 - set_control(m_keys[1], 21, "(LSHIFT | RSHIFT) & `F1`"); // SaveStateSlot1 - set_control(m_keys[1], 22, "(LSHIFT | RSHIFT) & `F2`"); // SaveStateSlot2 - set_control(m_keys[1], 23, "(LSHIFT | RSHIFT) & `F3`"); // SaveStateSlot3 - set_control(m_keys[1], 24, "(LSHIFT | RSHIFT) & `F4`"); // SaveStateSlot4 - set_control(m_keys[1], 25, "(LSHIFT | RSHIFT) & `F5`"); // SaveStateSlot5 - set_control(m_keys[1], 26, "(LSHIFT | RSHIFT) & `F6`"); // SaveStateSlot6 - set_control(m_keys[1], 27, "(LSHIFT | RSHIFT) & `F7`"); // SaveStateSlot7 - set_control(m_keys[1], 28, "(LSHIFT | RSHIFT) & `F8`"); // SaveStateSlot8 + set_control(m_keys[1], 21, ""); // SaveStateSlot1 + set_control(m_keys[1], 22, ""); // SaveStateSlot2 + set_control(m_keys[1], 23, ""); // SaveStateSlot3 + set_control(m_keys[1], 24, ""); // SaveStateSlot4 + set_control(m_keys[1], 25, ""); // SaveStateSlot5 + set_control(m_keys[1], 26, ""); // SaveStateSlot6 + set_control(m_keys[1], 27, ""); // SaveStateSlot7 + set_control(m_keys[1], 28, ""); // SaveStateSlot8 set_control(m_keys[1], 29, ""); // SaveStateSlot9 set_control(m_keys[1], 30, ""); // SaveStateSlot10 set_control(m_keys[1], 31, ""); // SelectStateSlot1 @@ -372,187 +342,8 @@ void HotkeyManager::LoadDefaults(const ControllerInterface& ciface) set_control(m_keys[2], 17, ""); // LoadLastState7 set_control(m_keys[2], 18, ""); // LoadLastState8 set_control(m_keys[2], 19, ""); // SaveFirstState - set_control(m_keys[2], 20, "`F12` & !(LSHIFT | RSHIFT)"); // UndoLoadState - set_control(m_keys[2], 21, "(LSHIFT | RSHIFT) & `F12`"); // UndoSaveState + set_control(m_keys[2], 20, ""); // UndoLoadState + set_control(m_keys[2], 21, ""); // UndoSaveState set_control(m_keys[2], 22, ""); // SaveStateFile set_control(m_keys[2], 23, ""); // LoadStateFile -#elif __APPLE__ - set_control(m_keys[0], 0, "(`Left Command` | `Right Command`) & `O`"); // Open - set_control(m_keys[0], 1, ""); // ChangeDisc - set_control(m_keys[0], 2, ""); // RefreshList - set_control(m_keys[0], 3, "(`Left Command` | `Right Command`) & `P`"); // PlayPause - set_control(m_keys[0], 4, "(`Left Command` | `Right Command`) & `W`"); // Stop - set_control(m_keys[0], 5, ""); // Reset - set_control(m_keys[0], 6, ""); // FrameAdvance - set_control(m_keys[0], 7, ""); // StartRecording - set_control(m_keys[0], 8, ""); // PlayRecording - set_control(m_keys[0], 9, ""); // ExportRecording - set_control(m_keys[0], 10, ""); // Readonlymode - set_control(m_keys[0], 11, "(`Left Command` | `Right Command`) & `F`"); // ToggleFullscreen - set_control(m_keys[0], 12, "(`Left Command` | `Right Command`) & `S`"); // Screenshot - set_control(m_keys[0], 13, ""); // Exit - set_control(m_keys[0], 14, "(`Left Command` | `Right Command`) & `1`"); // Wiimote1Connect - set_control(m_keys[0], 15, "(`Left Command` | `Right Command`) & `2`"); // Wiimote2Connect - set_control(m_keys[0], 16, "(`Left Command` | `Right Command`) & `3`"); // Wiimote3Connect - set_control(m_keys[0], 17, "(`Left Command` | `Right Command`) & `4`"); // Wiimote4Connect - set_control(m_keys[0], 18, "(`Left Command` | `Right Command`) & `5`"); // BalanceBoardConnect - set_control(m_keys[0], 19, ""); // VolumeDown - set_control(m_keys[0], 20, ""); // VolumeUp - set_control(m_keys[0], 21, ""); // VolumeToggleMute - set_control(m_keys[0], 22, ""); // ToggleIR - set_control(m_keys[0], 23, ""); // ToggleAspectRatio - set_control(m_keys[0], 24, ""); // ToggleEFBCopies - set_control(m_keys[0], 25, ""); // ToggleFog - set_control(m_keys[0], 26, "Tab"); // ToggleThrottle - set_control(m_keys[0], 27, ""); // DecreaseFrameLimit - set_control(m_keys[0], 28, ""); // IncreaseFrameLimit - set_control(m_keys[0], 29, "`1` & !(`Left Command` | `Right Command`)"); // FreelookDecreaseSpeed - set_control(m_keys[0], 30, "`2` & !(`Left Command` | `Right Command`)"); // FreelookIncreaseSpeed - set_control(m_keys[0], 31, "`F` & !(`Left Command` | `Right Command`)"); // FreelookResetSpeed - set_control(m_keys[1], 0, "`E` & !(`Left Command` | `Right Command`)"); // FreelookUp - set_control(m_keys[1], 1, "`Q` & !(`Left Command` | `Right Command`)"); // FreelookDown - set_control(m_keys[1], 2, "`A` & !(`Left Command` | `Right Command`)"); // FreelookLeft - set_control(m_keys[1], 3, "`D` & !(`Left Command` | `Right Command`)"); // FreelookRight - set_control(m_keys[1], 4, "`W` & !(`Left Command` | `Right Command`)"); // FreelookZoomIn - set_control(m_keys[1], 5, "`S` & !(`Left Command` | `Right Command`)"); // FreelookZoomOut - set_control(m_keys[1], 6, "`R` & !(`Left Command` | `Right Command`)"); // FreelookReset - set_control(m_keys[1], 7, ""); // DecreaseDepth - set_control(m_keys[1], 8, ""); // IncreaseDepth - set_control(m_keys[1], 9, ""); // DecreaseConvergence - set_control(m_keys[1], 10, ""); // IncreaseConvergence - set_control(m_keys[1], 11, "`F1` & !(`Left Shift` | `Right Shift`)"); // LoadStateSlot1 - set_control(m_keys[1], 12, "`F2` & !(`Left Shift` | `Right Shift`)"); // LoadStateSlot2 - set_control(m_keys[1], 13, "`F3` & !(`Left Shift` | `Right Shift`)"); // LoadStateSlot3 - set_control(m_keys[1], 14, "`F4` & !(`Left Shift` | `Right Shift`)"); // LoadStateSlot4 - set_control(m_keys[1], 15, "`F5` & !(`Left Shift` | `Right Shift`)"); // LoadStateSlot5 - set_control(m_keys[1], 16, "`F6` & !(`Left Shift` | `Right Shift`)"); // LoadStateSlot6 - set_control(m_keys[1], 17, "`F7` & !(`Left Shift` | `Right Shift`)"); // LoadStateSlot7 - set_control(m_keys[1], 18, "`F8` & !(`Left Shift` | `Right Shift`)"); // LoadStateSlot8 - set_control(m_keys[1], 19, ""); // LoadStateSlot9 - set_control(m_keys[1], 20, ""); // LoadStateSlot10 - set_control(m_keys[1], 21, "(`Left Shift` | `Right Shift`) & `F1`"); // SaveStateSlot1 - set_control(m_keys[1], 22, "(`Left Shift` | `Right Shift`) & `F2`"); // SaveStateSlot2 - set_control(m_keys[1], 23, "(`Left Shift` | `Right Shift`) & `F3`"); // SaveStateSlot3 - set_control(m_keys[1], 24, "(`Left Shift` | `Right Shift`) & `F4`"); // SaveStateSlot4 - set_control(m_keys[1], 25, "(`Left Shift` | `Right Shift`) & `F5`"); // SaveStateSlot5 - set_control(m_keys[1], 26, "(`Left Shift` | `Right Shift`) & `F6`"); // SaveStateSlot6 - set_control(m_keys[1], 27, "(`Left Shift` | `Right Shift`) & `F7`"); // SaveStateSlot7 - set_control(m_keys[1], 28, "(`Left Shift` | `Right Shift`) & `F8`"); // SaveStateSlot8 - set_control(m_keys[1], 29, ""); // SaveStateSlot9 - set_control(m_keys[1], 30, ""); // SaveStateSlot10 - set_control(m_keys[1], 31, ""); // SelectStateSlot1 - set_control(m_keys[2], 0, ""); // SelectStateSlot2 - set_control(m_keys[2], 1, ""); // SelectStateSlot3 - set_control(m_keys[2], 2, ""); // SelectStateSlot4 - set_control(m_keys[2], 3, ""); // SelectStateSlot5 - set_control(m_keys[2], 4, ""); // SelectStateSlot6 - set_control(m_keys[2], 5, ""); // SelectStateSlot7 - set_control(m_keys[2], 6, ""); // SelectStateSlot8 - set_control(m_keys[2], 7, ""); // SelectStateSlot9 - set_control(m_keys[2], 8, ""); // SelectStateSlot10 - set_control(m_keys[2], 9, ""); // SaveSelectedSlot - set_control(m_keys[2], 10, ""); // LoadSelectedSlot - set_control(m_keys[2], 11, ""); // LoadLastState1 - set_control(m_keys[2], 12, ""); // LoadLastState2 - set_control(m_keys[2], 13, ""); // LoadLastState3 - set_control(m_keys[2], 14, ""); // LoadLastState4 - set_control(m_keys[2], 15, ""); // LoadLastState5 - set_control(m_keys[2], 16, ""); // LoadLastState6 - set_control(m_keys[2], 17, ""); // LoadLastState7 - set_control(m_keys[2], 18, ""); // LoadLastState8 - set_control(m_keys[2], 19, ""); // SaveFirstState - set_control(m_keys[2], 20, "`F12` & !(`Left Shift` | `Right Shift`)"); // UndoLoadState - set_control(m_keys[2], 21, "(`Left Shift` | `Right Shift`) & `F12`"); // UndoSaveState - set_control(m_keys[2], 22, ""); // SaveStateFile - set_control(m_keys[2], 23, ""); // LoadStateFile -#else // linux - set_control(m_keys[0], 0, "(`Control_L` | `Control_R`) & `O`"); // Open - set_control(m_keys[0], 1, ""); // ChangeDisc - set_control(m_keys[0], 2, ""); // RefreshList - set_control(m_keys[0], 3, "`F10` & !(`Alt_L` | `Alt_R`)"); // PlayPause - set_control(m_keys[0], 4, "Escape & !(`Alt_L` | `Alt_R`)"); // Stop - set_control(m_keys[0], 5, ""); // Reset - set_control(m_keys[0], 6, ""); // FrameAdvance - set_control(m_keys[0], 7, ""); // StartRecording - set_control(m_keys[0], 8, ""); // PlayRecording - set_control(m_keys[0], 9, ""); // ExportRecording - set_control(m_keys[0], 10, ""); // Readonlymode - set_control(m_keys[0], 11, "(`Alt_L` | `Alt_R`) & Return"); // ToggleFullscreen - set_control(m_keys[0], 12, "`F9` & !(`Alt_L` | `Alt_R`)"); // Screenshot - set_control(m_keys[0], 13, ""); // Exit - set_control(m_keys[0], 14, "(`Alt_L` | `Alt_R`) & `F5`"); // Wiimote1Connect - set_control(m_keys[0], 15, "(`Alt_L` | `Alt_R`) & `F6`"); // Wiimote2Connect - set_control(m_keys[0], 16, "(`Alt_L` | `Alt_R`) & `F7`"); // Wiimote3Connect - set_control(m_keys[0], 17, "(`Alt_L` | `Alt_R`) & `F8`"); // Wiimote4Connect - set_control(m_keys[0], 18, "(`Alt_L` | `Alt_R`) & `F9`"); // BalanceBoardConnect - set_control(m_keys[0], 19, ""); // VolumeDown - set_control(m_keys[0], 20, ""); // VolumeUp - set_control(m_keys[0], 21, ""); // VolumeToggleMute - set_control(m_keys[0], 22, ""); // ToggleIR - set_control(m_keys[0], 23, ""); // ToggleAspectRatio - set_control(m_keys[0], 24, ""); // ToggleEFBCopies - set_control(m_keys[0], 25, ""); // ToggleFog - set_control(m_keys[0], 26, "Tab & !(`Alt_L` | `Alt_R`)"); // ToggleThrottle - set_control(m_keys[0], 27, ""); // DecreaseFrameLimit - set_control(m_keys[0], 28, ""); // IncreaseFrameLimit - set_control(m_keys[0], 29, "1 & !(`Alt_L` | `Alt_R`)"); // FreelookDecreaseSpeed - set_control(m_keys[0], 30, "2 & !(`Alt_L` | `Alt_R`)"); // FreelookIncreaseSpeed - set_control(m_keys[0], 31, "F & !(`Alt_L` | `Alt_R`)"); // FreelookResetSpeed - set_control(m_keys[1], 0, "E & !(`Alt_L` | `Alt_R`)"); // FreelookUp - set_control(m_keys[1], 1, "Q & !(`Alt_L` | `Alt_R`)"); // FreelookDown - set_control(m_keys[1], 2, "A & !(`Alt_L` | `Alt_R`)"); // FreelookLeft - set_control(m_keys[1], 3, "D & !(`Alt_L` | `Alt_R`)"); // FreelookRight - set_control(m_keys[1], 4, "W & !(`Alt_L` | `Alt_R`)"); // FreelookZoomIn - set_control(m_keys[1], 5, "S & !(`Alt_L` | `Alt_R`)"); // FreelookZoomOut - set_control(m_keys[1], 6, "R & !(`Alt_L` | `Alt_R`)"); // FreelookReset - set_control(m_keys[1], 7, ""); // DecreaseDepth - set_control(m_keys[1], 8, ""); // IncreaseDepth - set_control(m_keys[1], 9, ""); // DecreaseConvergence - set_control(m_keys[1], 10, ""); // IncreaseConvergence - set_control(m_keys[1], 11, "`F1` & !(`Shift_L` | `Shift_R`) & !(`Alt_L` | `Alt_R`)"); // LoadStateSlot1 - set_control(m_keys[1], 12, "`F2` & !(`Shift_L` | `Shift_R`) & !(`Alt_L` | `Alt_R`)"); // LoadStateSlot2 - set_control(m_keys[1], 13, "`F3` & !(`Shift_L` | `Shift_R`) & !(`Alt_L` | `Alt_R`)"); // LoadStateSlot3 - set_control(m_keys[1], 14, "`F4` & !(`Shift_L` | `Shift_R`) & !(`Alt_L` | `Alt_R`)"); // LoadStateSlot4 - set_control(m_keys[1], 15, "`F5` & !(`Shift_L` | `Shift_R`) & !(`Alt_L` | `Alt_R`)"); // LoadStateSlot5 - set_control(m_keys[1], 16, "`F6` & !(`Shift_L` | `Shift_R`) & !(`Alt_L` | `Alt_R`)"); // LoadStateSlot6 - set_control(m_keys[1], 17, "`F7` & !(`Shift_L` | `Shift_R`) & !(`Alt_L` | `Alt_R`)"); // LoadStateSlot7 - set_control(m_keys[1], 18, "`F8` & !(`Shift_L` | `Shift_R`) & !(`Alt_L` | `Alt_R`)"); // LoadStateSlot8 - set_control(m_keys[1], 19, ""); // LoadStateSlot9 - set_control(m_keys[1], 20, ""); // LoadStateSlot10 - set_control(m_keys[1], 21, "(`Shift_L` | `Shift_R`) & `F1` & !(`Alt_L` | `Alt_R`)"); // SaveStateSlot1 - set_control(m_keys[1], 22, "(`Shift_L` | `Shift_R`) & `F2` & !(`Alt_L` | `Alt_R`)"); // SaveStateSlot2 - set_control(m_keys[1], 23, "(`Shift_L` | `Shift_R`) & `F3` & !(`Alt_L` | `Alt_R`)"); // SaveStateSlot3 - set_control(m_keys[1], 24, "(`Shift_L` | `Shift_R`) & `F4` & !(`Alt_L` | `Alt_R`)"); // SaveStateSlot4 - set_control(m_keys[1], 25, "(`Shift_L` | `Shift_R`) & `F5` & !(`Alt_L` | `Alt_R`)"); // SaveStateSlot5 - set_control(m_keys[1], 26, "(`Shift_L` | `Shift_R`) & `F6` & !(`Alt_L` | `Alt_R`)"); // SaveStateSlot6 - set_control(m_keys[1], 27, "(`Shift_L` | `Shift_R`) & `F7` & !(`Alt_L` | `Alt_R`)"); // SaveStateSlot7 - set_control(m_keys[1], 28, "(`Shift_L` | `Shift_R`) & `F8` & !(`Alt_L` | `Alt_R`)"); // SaveStateSlot8 - set_control(m_keys[1], 29, ""); // SaveStateSlot9 - set_control(m_keys[1], 30, ""); // SaveStateSlot10 - set_control(m_keys[1], 31, ""); // SelectStateSlot1 - set_control(m_keys[2], 0, ""); // SelectStateSlot2 - set_control(m_keys[2], 1, ""); // SelectStateSlot3 - set_control(m_keys[2], 2, ""); // SelectStateSlot4 - set_control(m_keys[2], 3, ""); // SelectStateSlot5 - set_control(m_keys[2], 4, ""); // SelectStateSlot6 - set_control(m_keys[2], 5, ""); // SelectStateSlot7 - set_control(m_keys[2], 6, ""); // SelectStateSlot8 - set_control(m_keys[2], 7, ""); // SelectStateSlot9 - set_control(m_keys[2], 8, ""); // SelectStateSlot10 - set_control(m_keys[2], 9, ""); // SaveSelectedSlot - set_control(m_keys[2], 10, ""); // LoadSelectedSlot - set_control(m_keys[2], 11, ""); // LoadLastState1 - set_control(m_keys[2], 12, ""); // LoadLastState2 - set_control(m_keys[2], 13, ""); // LoadLastState3 - set_control(m_keys[2], 14, ""); // LoadLastState4 - set_control(m_keys[2], 15, ""); // LoadLastState5 - set_control(m_keys[2], 16, ""); // LoadLastState6 - set_control(m_keys[2], 17, ""); // LoadLastState7 - set_control(m_keys[2], 18, ""); // LoadLastState8 - set_control(m_keys[2], 19, ""); // SaveFirstState - set_control(m_keys[2], 20, "`F12` & !(`Shift_L` | `Shift_R`) & !(`Alt_L` | `Alt_R`)"); // UndoLoadState - set_control(m_keys[2], 21, "(`Shift_L` | `Shift_R`) & `F12` & !(`Alt_L` | `Alt_R`)"); // UndoSaveState - set_control(m_keys[2], 22, ""); // SaveStateFile - set_control(m_keys[2], 23, ""); // LoadStateFile -#endif } diff --git a/Source/Core/DolphinWX/Frame.cpp b/Source/Core/DolphinWX/Frame.cpp index b6b28a57f2..84272227f7 100644 --- a/Source/Core/DolphinWX/Frame.cpp +++ b/Source/Core/DolphinWX/Frame.cpp @@ -1414,7 +1414,7 @@ void CFrame::ParseHotkeys(wxKeyEvent &event) if (cmd >= 0) { wxCommandEvent evt(wxEVT_MENU, cmd); - wxMenuItem *item = GetMenuBar()->FindItem(cmd); + wxMenuItem* item = GetMenuBar()->FindItem(cmd); if (item && item->IsCheckable()) { item->wxMenuItemBase::Toggle(); diff --git a/Source/Core/DolphinWX/FrameTools.cpp b/Source/Core/DolphinWX/FrameTools.cpp index 04534a48fb..fda4f4ee0e 100644 --- a/Source/Core/DolphinWX/FrameTools.cpp +++ b/Source/Core/DolphinWX/FrameTools.cpp @@ -239,8 +239,8 @@ wxMenuBar* CFrame::CreateMenu() pOptionsMenu->Append(IDM_CONFIG_GFX_BACKEND, _("&Graphics Settings")); pOptionsMenu->Append(IDM_CONFIG_AUDIO, _("&Audio Settings")); pOptionsMenu->Append(IDM_CONFIG_CONTROLLERS, _("&Controller Settings")); + pOptionsMenu->Append(IDM_CONFIG_MENU_COMMANDS, _("&Key Shortcuts")); pOptionsMenu->Append(IDM_CONFIG_HOTKEYS, _("&Hotkey Settings")); - pOptionsMenu->Append(IDM_CONFIG_MENU_COMMANDS, _("&Menu Accelerators")); if (g_pCodeWindow) { pOptionsMenu->AppendSeparator(); @@ -1767,7 +1767,7 @@ void CFrame::UpdateGUI() GetMenuBar()->FindItem(IDM_SCREENSHOT)->Enable(Running || Paused); GetMenuBar()->FindItem(IDM_TOGGLE_FULLSCREEN)->Enable(Running || Paused); - // Update Menu Accelerators + // Update Key Shortcuts for (unsigned int i = 0; i < NUM_HOTKEYS; i++) { if (GetCmdForHotkey(i) == -1) diff --git a/Source/Core/DolphinWX/HotkeyDlg.h b/Source/Core/DolphinWX/HotkeyDlg.h index db4c687c52..9dd5307928 100644 --- a/Source/Core/DolphinWX/HotkeyDlg.h +++ b/Source/Core/DolphinWX/HotkeyDlg.h @@ -29,7 +29,7 @@ class HotkeyConfigDialog : public wxDialog public: HotkeyConfigDialog(wxWindow* parent, wxWindowID id = wxID_ANY, - const wxString &title = _("Menu Accelerators"), + const wxString &title = _("Key Shortcuts"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE); From 9c133c0509ff75e6e04f8d56513d6fd8196dc408 Mon Sep 17 00:00:00 2001 From: skidau Date: Fri, 6 Mar 2015 14:05:47 +1100 Subject: [PATCH 10/12] Readded the Key Shortcut function. --- Source/Core/DolphinWX/Frame.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/Core/DolphinWX/Frame.cpp b/Source/Core/DolphinWX/Frame.cpp index 84272227f7..5c536229d4 100644 --- a/Source/Core/DolphinWX/Frame.cpp +++ b/Source/Core/DolphinWX/Frame.cpp @@ -948,7 +948,9 @@ static bool IsHotkey(wxKeyEvent &event, int id, bool held = false) return HotkeyManagerEmu::IsPressed(id, held); } - return false; + return (event.GetKeyCode() != WXK_NONE && + event.GetKeyCode() == SConfig::GetInstance().m_LocalCoreStartupParameter.iHotkey[id] && + event.GetModifiers() == SConfig::GetInstance().m_LocalCoreStartupParameter.iHotkeyModifier[id]); } int GetCmdForHotkey(unsigned int key) From 8f0bc1cd3a76c492ab39a19d2e2f2ffd1e7394a8 Mon Sep 17 00:00:00 2001 From: skidau Date: Fri, 6 Mar 2015 16:27:28 +1100 Subject: [PATCH 11/12] Slowed down the freelook speed keys and allowed the depth/convergence keys to be held down. --- Source/Core/DolphinWX/Frame.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/Source/Core/DolphinWX/Frame.cpp b/Source/Core/DolphinWX/Frame.cpp index 5c536229d4..46c2d3538d 100644 --- a/Source/Core/DolphinWX/Frame.cpp +++ b/Source/Core/DolphinWX/Frame.cpp @@ -1370,24 +1370,26 @@ void CFrame::ParseHotkeys(wxKeyEvent &event) { State::Load(g_saveSlot); } - else if (IsHotkey(event, HK_DECREASE_DEPTH)) + else if (IsHotkey(event, HK_DECREASE_DEPTH, true)) { if (--g_Config.iStereoDepth < 0) g_Config.iStereoDepth = 0; } - else if (IsHotkey(event, HK_INCREASE_DEPTH)) + else if (IsHotkey(event, HK_INCREASE_DEPTH, true)) { if (++g_Config.iStereoDepth > 100) g_Config.iStereoDepth = 100; } - else if (IsHotkey(event, HK_DECREASE_CONVERGENCE)) + else if (IsHotkey(event, HK_DECREASE_CONVERGENCE, true)) { - if (--g_Config.iStereoConvergence < 0) + g_Config.iStereoConvergence -= 5; + if (g_Config.iStereoConvergence < 0) g_Config.iStereoConvergence = 0; } - else if (IsHotkey(event, HK_INCREASE_CONVERGENCE)) + else if (IsHotkey(event, HK_INCREASE_CONVERGENCE, true)) { - if (++g_Config.iStereoConvergence > 500) + g_Config.iStereoConvergence += 5; + if (g_Config.iStereoConvergence > 500) g_Config.iStereoConvergence = 500; } @@ -1453,9 +1455,9 @@ void CFrame::ParseHotkeys(wxKeyEvent &event) static float debugSpeed = 1.0f; if (IsHotkey(event, HK_FREELOOK_DECREASE_SPEED, true)) - debugSpeed /= 2.0f; + debugSpeed /= 1.1f; else if (IsHotkey(event, HK_FREELOOK_INCREASE_SPEED, true)) - debugSpeed *= 2.0f; + debugSpeed *= 1.1f; else if (IsHotkey(event, HK_FREELOOK_RESET_SPEED, true)) debugSpeed = 1.0f; else if (IsHotkey(event, HK_FREELOOK_UP, true)) From 3e12787cc8e801c00957f1e5305622ea1eb3423b Mon Sep 17 00:00:00 2001 From: skidau Date: Sat, 7 Mar 2015 14:41:08 +1100 Subject: [PATCH 12/12] Fixed a crash on launch which occurred if the hotkeys are not defined and the default hotkeys are loaded. --- Source/Core/Core/HotkeyManager.cpp | 102 +++-------------------------- 1 file changed, 8 insertions(+), 94 deletions(-) diff --git a/Source/Core/Core/HotkeyManager.cpp b/Source/Core/Core/HotkeyManager.cpp index 9b7c0f2436..c3a6461ebe 100644 --- a/Source/Core/Core/HotkeyManager.cpp +++ b/Source/Core/Core/HotkeyManager.cpp @@ -239,7 +239,7 @@ void HotkeyManager::GetInput(HotkeyStatus* const kb) std::vector bitmasks; for (int key = 0; key < 32; key++) { - if (hotkey_labels[set * 32 + key].length() != 0) + if ((set * 32 + key) < num_hotkeys && hotkey_labels[set * 32 + key].length() != 0) bitmasks.push_back(1 << key); } @@ -253,97 +253,11 @@ void HotkeyManager::GetInput(HotkeyStatus* const kb) void HotkeyManager::LoadDefaults(const ControllerInterface& ciface) { -#define set_control(group, num, str) (group)->controls[num]->control_ref->expression = (str) - - ControllerEmu::LoadDefaults(ciface); - - // Buttons - set_control(m_keys[0], 0, ""); // Open - set_control(m_keys[0], 1, ""); // ChangeDisc - set_control(m_keys[0], 2, ""); // RefreshList - set_control(m_keys[0], 3, ""); // PlayPause - set_control(m_keys[0], 4, ""); // Stop - set_control(m_keys[0], 5, ""); // Reset - set_control(m_keys[0], 6, ""); // FrameAdvance - set_control(m_keys[0], 7, ""); // StartRecording - set_control(m_keys[0], 8, ""); // PlayRecording - set_control(m_keys[0], 9, ""); // ExportRecording - set_control(m_keys[0], 10, ""); // Readonlymode - set_control(m_keys[0], 11, ""); // ToggleFullscreen - set_control(m_keys[0], 12, ""); // Screenshot - set_control(m_keys[0], 13, ""); // Exit - set_control(m_keys[0], 14, ""); // Wiimote1Connect - set_control(m_keys[0], 15, ""); // Wiimote2Connect - set_control(m_keys[0], 16, ""); // Wiimote3Connect - set_control(m_keys[0], 17, ""); // Wiimote4Connect - set_control(m_keys[0], 18, ""); // BalanceBoardConnect - set_control(m_keys[0], 19, ""); // VolumeDown - set_control(m_keys[0], 20, ""); // VolumeUp - set_control(m_keys[0], 21, ""); // VolumeToggleMute - set_control(m_keys[0], 22, ""); // ToggleIR - set_control(m_keys[0], 23, ""); // ToggleAspectRatio - set_control(m_keys[0], 24, ""); // ToggleEFBCopies - set_control(m_keys[0], 25, ""); // ToggleFog - set_control(m_keys[0], 26, ""); // ToggleThrottle - set_control(m_keys[0], 27, ""); // DecreaseFrameLimit - set_control(m_keys[0], 28, ""); // IncreaseFrameLimit - set_control(m_keys[0], 29, ""); // FreelookDecreaseSpeed - set_control(m_keys[0], 30, ""); // FreelookIncreaseSpeed - set_control(m_keys[0], 31, ""); // FreelookResetSpeed - set_control(m_keys[1], 0, ""); // FreelookUp - set_control(m_keys[1], 1, ""); // FreelookDown - set_control(m_keys[1], 2, ""); // FreelookLeft - set_control(m_keys[1], 3, ""); // FreelookRight - set_control(m_keys[1], 4, ""); // FreelookZoomIn - set_control(m_keys[1], 5, ""); // FreelookZoomOut - set_control(m_keys[1], 6, ""); // FreelookReset - set_control(m_keys[1], 7, ""); // DecreaseDepth - set_control(m_keys[1], 8, ""); // IncreaseDepth - set_control(m_keys[1], 9, ""); // DecreaseConvergence - set_control(m_keys[1], 10, ""); // IncreaseConvergence - set_control(m_keys[1], 11, ""); // LoadStateSlot1 - set_control(m_keys[1], 12, ""); // LoadStateSlot2 - set_control(m_keys[1], 13, ""); // LoadStateSlot3 - set_control(m_keys[1], 14, ""); // LoadStateSlot4 - set_control(m_keys[1], 15, ""); // LoadStateSlot5 - set_control(m_keys[1], 16, ""); // LoadStateSlot6 - set_control(m_keys[1], 17, ""); // LoadStateSlot7 - set_control(m_keys[1], 18, ""); // LoadStateSlot8 - set_control(m_keys[1], 19, ""); // LoadStateSlot9 - set_control(m_keys[1], 20, ""); // LoadStateSlot10 - set_control(m_keys[1], 21, ""); // SaveStateSlot1 - set_control(m_keys[1], 22, ""); // SaveStateSlot2 - set_control(m_keys[1], 23, ""); // SaveStateSlot3 - set_control(m_keys[1], 24, ""); // SaveStateSlot4 - set_control(m_keys[1], 25, ""); // SaveStateSlot5 - set_control(m_keys[1], 26, ""); // SaveStateSlot6 - set_control(m_keys[1], 27, ""); // SaveStateSlot7 - set_control(m_keys[1], 28, ""); // SaveStateSlot8 - set_control(m_keys[1], 29, ""); // SaveStateSlot9 - set_control(m_keys[1], 30, ""); // SaveStateSlot10 - set_control(m_keys[1], 31, ""); // SelectStateSlot1 - set_control(m_keys[2], 0, ""); // SelectStateSlot2 - set_control(m_keys[2], 1, ""); // SelectStateSlot3 - set_control(m_keys[2], 2, ""); // SelectStateSlot4 - set_control(m_keys[2], 3, ""); // SelectStateSlot5 - set_control(m_keys[2], 4, ""); // SelectStateSlot6 - set_control(m_keys[2], 5, ""); // SelectStateSlot7 - set_control(m_keys[2], 6, ""); // SelectStateSlot8 - set_control(m_keys[2], 7, ""); // SelectStateSlot9 - set_control(m_keys[2], 8, ""); // SelectStateSlot10 - set_control(m_keys[2], 9, ""); // SaveSelectedSlot - set_control(m_keys[2], 10, ""); // LoadSelectedSlot - set_control(m_keys[2], 11, ""); // LoadLastState1 - set_control(m_keys[2], 12, ""); // LoadLastState2 - set_control(m_keys[2], 13, ""); // LoadLastState3 - set_control(m_keys[2], 14, ""); // LoadLastState4 - set_control(m_keys[2], 15, ""); // LoadLastState5 - set_control(m_keys[2], 16, ""); // LoadLastState6 - set_control(m_keys[2], 17, ""); // LoadLastState7 - set_control(m_keys[2], 18, ""); // LoadLastState8 - set_control(m_keys[2], 19, ""); // SaveFirstState - set_control(m_keys[2], 20, ""); // UndoLoadState - set_control(m_keys[2], 21, ""); // UndoSaveState - set_control(m_keys[2], 22, ""); // SaveStateFile - set_control(m_keys[2], 23, ""); // LoadStateFile + for (int set = 0; set < 3; set++) + { + for (unsigned int key = 0; key < (m_keys[set])->controls.size(); key++) + { + (m_keys[set])->controls[key]->control_ref->expression = ""; + } + } }