From c84cefa990cd4bd8d418447e4379d223155c5e73 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Tue, 26 May 2015 12:04:16 -0700 Subject: [PATCH 1/2] Remove wx-based Hotkey stuff The core InputCommon Hotkeys interface does all of this for us. --- Source/Core/Core/ConfigManager.cpp | 160 -------- Source/Core/Core/ConfigManager.h | 2 - Source/Core/Core/CoreParameter.h | 4 - Source/Core/DolphinWX/CMakeLists.txt | 1 - Source/Core/DolphinWX/DolphinWX.vcxproj | 2 - .../Core/DolphinWX/DolphinWX.vcxproj.filters | 6 - Source/Core/DolphinWX/Frame.cpp | 152 +++----- Source/Core/DolphinWX/Frame.h | 3 +- Source/Core/DolphinWX/FrameTools.cpp | 33 +- Source/Core/DolphinWX/Globals.h | 1 - Source/Core/DolphinWX/HotkeyDlg.cpp | 360 ------------------ Source/Core/DolphinWX/HotkeyDlg.h | 50 --- 12 files changed, 47 insertions(+), 727 deletions(-) delete mode 100644 Source/Core/DolphinWX/HotkeyDlg.cpp delete mode 100644 Source/Core/DolphinWX/HotkeyDlg.h diff --git a/Source/Core/Core/ConfigManager.cpp b/Source/Core/Core/ConfigManager.cpp index 600151db4d..feddb8dda1 100644 --- a/Source/Core/Core/ConfigManager.cpp +++ b/Source/Core/Core/ConfigManager.cpp @@ -13,139 +13,6 @@ SConfig* SConfig::m_Instance; -static const struct -{ - const char* IniText; - const int DefaultKey; - const int DefaultModifier; -} g_HKData[] = { - { "Open", 79 /* 'O' */, 2 /* wxMOD_CONTROL */ }, - { "ChangeDisc", 0, 0 /* wxMOD_NONE */ }, - { "RefreshList", 0, 0 /* wxMOD_NONE */ }, -#ifdef __APPLE__ - { "PlayPause", 80 /* 'P' */, 2 /* wxMOD_CMD */ }, - { "Stop", 87 /* 'W' */, 2 /* wxMOD_CMD */ }, - { "Reset", 0, 0 /* wxMOD_NONE */ }, - { "FrameAdvance", 0, 0 /* wxMOD_NONE */ }, - - { "StartRecording", 0, 0 /* wxMOD_NONE */ }, - { "PlayRecording", 0, 0 /* wxMOD_NONE */ }, - { "ExportRecording", 0, 0 /* wxMOD_NONE */ }, - { "Readonlymode", 0, 0 /* wxMOD_NONE */ }, - - { "ToggleFullscreen", 70 /* 'F' */, 2 /* wxMOD_CMD */ }, - { "Screenshot", 83 /* 'S' */, 2 /* wxMOD_CMD */ }, - { "Exit", 0, 0 /* wxMOD_NONE */ }, - - { "Wiimote1Connect", 49 /* '1' */, 2 /* wxMOD_CMD */ }, - { "Wiimote2Connect", 50 /* '2' */, 2 /* wxMOD_CMD */ }, - { "Wiimote3Connect", 51 /* '3' */, 2 /* wxMOD_CMD */ }, - { "Wiimote4Connect", 52 /* '4' */, 2 /* wxMOD_CMD */ }, - { "BalanceBoardConnect", 53 /* '4' */, 2 /* wxMOD_CMD */ }, -#else - { "PlayPause", 349 /* WXK_F10 */, 0 /* wxMOD_NONE */ }, - { "Stop", 27 /* WXK_ESCAPE */, 0 /* wxMOD_NONE */ }, - { "Reset", 0, 0 /* wxMOD_NONE */ }, - { "FrameAdvance", 0, 0 /* wxMOD_NONE */ }, - - { "StartRecording", 0, 0 /* wxMOD_NONE */ }, - { "PlayRecording", 0, 0 /* wxMOD_NONE */ }, - { "ExportRecording", 0, 0 /* wxMOD_NONE */ }, - { "Readonlymode", 0, 0 /* wxMOD_NONE */ }, - - { "ToggleFullscreen", 13 /* WXK_RETURN */, 1 /* wxMOD_ALT */ }, - { "Screenshot", 348 /* WXK_F9 */, 0 /* wxMOD_NONE */ }, - { "Exit", 0, 0 /* wxMOD_NONE */ }, - - { "Wiimote1Connect", 344 /* WXK_F5 */, 1 /* wxMOD_ALT */ }, - { "Wiimote2Connect", 345 /* WXK_F6 */, 1 /* wxMOD_ALT */ }, - { "Wiimote3Connect", 346 /* WXK_F7 */, 1 /* wxMOD_ALT */ }, - { "Wiimote4Connect", 347 /* WXK_F8 */, 1 /* wxMOD_ALT */ }, - { "BalanceBoardConnect", 348 /* WXK_F9 */, 1 /* wxMOD_ALT */ }, -#endif - - { "VolumeDown", 0, 0 /* wxMOD_NONE */ }, - { "VolumeUp", 0, 0 /* wxMOD_NONE */ }, - { "VolumeToggleMute", 0, 0 /* wxMOD_NONE */ }, - - { "IncreaseIR", 0, 0 /* wxMOD_NONE */ }, - { "DecreaseIR", 0, 0 /* wxMOD_NONE */ }, - - { "ToggleIR", 0, 0 /* wxMOD_NONE */ }, - { "ToggleAspectRatio", 0, 0 /* wxMOD_NONE */ }, - { "ToggleEFBCopies", 0, 0 /* wxMOD_NONE */ }, - { "ToggleFog", 0, 0 /* wxMOD_NONE */ }, - { "ToggleThrottle", 9 /* '\t' */, 0 /* wxMOD_NONE */ }, - { "DecreaseFrameLimit", 0, 0 /* wxMOD_NONE */ }, - { "IncreaseFrameLimit", 0, 0 /* wxMOD_NONE */ }, - - { "FreelookDecreaseSpeed", 49 /* '1' */, 4 /* wxMOD_SHIFT */ }, - { "FreelookIncreaseSpeed", 50 /* '2' */, 4 /* wxMOD_SHIFT */ }, - { "FreelookResetSpeed", 70 /* 'F' */, 4 /* wxMOD_SHIFT */ }, - { "FreelookUp", 69 /* 'E' */, 4 /* wxMOD_SHIFT */ }, - { "FreelookDown", 81 /* 'Q' */, 4 /* wxMOD_SHIFT */ }, - { "FreelookLeft", 65 /* 'A' */, 4 /* wxMOD_SHIFT */ }, - { "FreelookRight", 68 /* 'D' */, 4 /* wxMOD_SHIFT */ }, - { "FreelookZoomIn", 87 /* 'W' */, 4 /* wxMOD_SHIFT */ }, - { "FreelookZoomOut", 83 /* 'S' */, 4 /* wxMOD_SHIFT */ }, - { "FreelookReset", 82 /* 'R' */, 4 /* wxMOD_SHIFT */ }, - - { "DecreaseDepth", 0, 0 /* wxMOD_NONE */ }, - { "IncreaseDepth", 0, 0 /* wxMOD_NONE */ }, - { "DecreaseConvergence", 0, 0 /* wxMOD_NONE */ }, - { "IncreaseConvergence", 0, 0 /* wxMOD_NONE */ }, - - { "LoadStateSlot1", 340 /* WXK_F1 */, 0 /* wxMOD_NONE */ }, - { "LoadStateSlot2", 341 /* WXK_F2 */, 0 /* wxMOD_NONE */ }, - { "LoadStateSlot3", 342 /* WXK_F3 */, 0 /* wxMOD_NONE */ }, - { "LoadStateSlot4", 343 /* WXK_F4 */, 0 /* wxMOD_NONE */ }, - { "LoadStateSlot5", 344 /* WXK_F5 */, 0 /* wxMOD_NONE */ }, - { "LoadStateSlot6", 345 /* WXK_F6 */, 0 /* wxMOD_NONE */ }, - { "LoadStateSlot7", 346 /* WXK_F7 */, 0 /* wxMOD_NONE */ }, - { "LoadStateSlot8", 347 /* WXK_F8 */, 0 /* wxMOD_NONE */ }, - { "LoadStateSlot9", 0, 0 /* wxMOD_NONE */ }, - { "LoadStateSlot10", 0, 0 /* wxMOD_NONE */ }, - - { "SaveStateSlot1", 340 /* WXK_F1 */, 4 /* wxMOD_SHIFT */ }, - { "SaveStateSlot2", 341 /* WXK_F2 */, 4 /* wxMOD_SHIFT */ }, - { "SaveStateSlot3", 342 /* WXK_F3 */, 4 /* wxMOD_SHIFT */ }, - { "SaveStateSlot4", 343 /* WXK_F4 */, 4 /* wxMOD_SHIFT */ }, - { "SaveStateSlot5", 344 /* WXK_F5 */, 4 /* wxMOD_SHIFT */ }, - { "SaveStateSlot6", 345 /* WXK_F6 */, 4 /* wxMOD_SHIFT */ }, - { "SaveStateSlot7", 346 /* WXK_F7 */, 4 /* wxMOD_SHIFT */ }, - { "SaveStateSlot8", 347 /* WXK_F8 */, 4 /* wxMOD_SHIFT */ }, - { "SaveStateSlot9", 0, 0 /* wxMOD_NONE */ }, - { "SaveStateSlot10", 0, 0 /* wxMOD_NONE */ }, - - { "SelectStateSlot1", 0, 0 /* wxMOD_NONE */ }, - { "SelectStateSlot2", 0, 0 /* wxMOD_NONE */ }, - { "SelectStateSlot3", 0, 0 /* wxMOD_NONE */ }, - { "SelectStateSlot4", 0, 0 /* wxMOD_NONE */ }, - { "SelectStateSlot5", 0, 0 /* wxMOD_NONE */ }, - { "SelectStateSlot6", 0, 0 /* wxMOD_NONE */ }, - { "SelectStateSlot7", 0, 0 /* wxMOD_NONE */ }, - { "SelectStateSlot8", 0, 0 /* wxMOD_NONE */ }, - { "SelectStateSlot9", 0, 0 /* wxMOD_NONE */ }, - { "SelectStateSlot10", 0, 0 /* wxMOD_NONE */ }, - { "SaveSelectedSlot", 0, 0 /* wxMOD_NONE */ }, - { "LoadSelectedSlot", 0, 0 /* wxMOD_NONE */ }, - - { "LoadLastState1", 0, 0 /* wxMOD_NONE */ }, - { "LoadLastState2", 0, 0 /* wxMOD_NONE */ }, - { "LoadLastState3", 0, 0 /* wxMOD_NONE */ }, - { "LoadLastState4", 0, 0 /* wxMOD_NONE */ }, - { "LoadLastState5", 0, 0 /* wxMOD_NONE */ }, - { "LoadLastState6", 0, 0 /* wxMOD_NONE */ }, - { "LoadLastState7", 0, 0 /* wxMOD_NONE */ }, - { "LoadLastState8", 0, 0 /* wxMOD_NONE */ }, - - { "SaveFirstState", 0, 0 /* wxMOD_NONE */ }, - { "UndoLoadState", 351 /* WXK_F12 */, 0 /* wxMOD_NONE */ }, - { "UndoSaveState", 351 /* WXK_F12 */, 4 /* wxMOD_SHIFT */ }, - { "SaveStateFile", 0, 0 /* wxMOD_NONE */ }, - { "LoadStateFile", 0, 0 /* wxMOD_NONE */ }, -}; - SConfig::SConfig() { // Make sure we have log manager @@ -178,7 +45,6 @@ void SConfig::SaveSettings() SaveGeneralSettings(ini); SaveInterfaceSettings(ini); - SaveHotkeySettings(ini); SaveDisplaySettings(ini); SaveGameListSettings(ini); SaveCoreSettings(ini); @@ -251,18 +117,6 @@ void SConfig::SaveInterfaceSettings(IniFile& ini) interface->Set("PauseOnFocusLost", m_PauseOnFocusLost); } -void SConfig::SaveHotkeySettings(IniFile& ini) -{ - IniFile::Section* hotkeys = ini.GetOrCreateSection("Hotkeys"); - - for (int i = 0; i < NUM_HOTKEYS; i++) - { - hotkeys->Set(g_HKData[i].IniText, m_LocalCoreStartupParameter.iHotkey[i]); - hotkeys->Set(std::string(g_HKData[i].IniText) + "Modifier", - m_LocalCoreStartupParameter.iHotkeyModifier[i]); - } -} - void SConfig::SaveDisplaySettings(IniFile& ini) { IniFile::Section* display = ini.GetOrCreateSection("Display"); @@ -407,7 +261,6 @@ void SConfig::LoadSettings() LoadGeneralSettings(ini); LoadInterfaceSettings(ini); - LoadHotkeySettings(ini); LoadDisplaySettings(ini); LoadGameListSettings(ini); LoadCoreSettings(ini); @@ -501,19 +354,6 @@ void SConfig::LoadInterfaceSettings(IniFile& ini) interface->Get("PauseOnFocusLost", &m_PauseOnFocusLost, false); } -void SConfig::LoadHotkeySettings(IniFile& ini) -{ - IniFile::Section* hotkeys = ini.GetOrCreateSection("Hotkeys"); - - for (int i = 0; i < NUM_HOTKEYS; i++) - { - hotkeys->Get(g_HKData[i].IniText, - &m_LocalCoreStartupParameter.iHotkey[i], 0); - hotkeys->Get(std::string(g_HKData[i].IniText) + "Modifier", - &m_LocalCoreStartupParameter.iHotkeyModifier[i], 0); - } -} - void SConfig::LoadDisplaySettings(IniFile& ini) { IniFile::Section* display = ini.GetOrCreateSection("Display"); diff --git a/Source/Core/Core/ConfigManager.h b/Source/Core/Core/ConfigManager.h index 42cd8d5d2b..6034fa9c1a 100644 --- a/Source/Core/Core/ConfigManager.h +++ b/Source/Core/Core/ConfigManager.h @@ -139,7 +139,6 @@ private: void SaveGeneralSettings(IniFile& ini); void SaveInterfaceSettings(IniFile& ini); void SaveDisplaySettings(IniFile& ini); - void SaveHotkeySettings(IniFile& ini); void SaveGameListSettings(IniFile& ini); void SaveCoreSettings(IniFile& ini); void SaveDSPSettings(IniFile& ini); @@ -150,7 +149,6 @@ private: void LoadGeneralSettings(IniFile& ini); void LoadInterfaceSettings(IniFile& ini); void LoadDisplaySettings(IniFile& ini); - void LoadHotkeySettings(IniFile& ini); void LoadGameListSettings(IniFile& ini); void LoadCoreSettings(IniFile& ini); void LoadDSPSettings(IniFile& ini); diff --git a/Source/Core/Core/CoreParameter.h b/Source/Core/Core/CoreParameter.h index b459c1b3be..7be02ce6f6 100644 --- a/Source/Core/Core/CoreParameter.h +++ b/Source/Core/Core/CoreParameter.h @@ -193,10 +193,6 @@ struct SCoreStartupParameter bool bConfirmStop, bHideCursor, bAutoHideCursor, bUsePanicHandlers, bOnScreenDisplayMessages; std::string theme_name; - // Hotkeys - int iHotkey[NUM_HOTKEYS]; - int iHotkeyModifier[NUM_HOTKEYS]; - // Display settings std::string strFullscreenResolution; int iRenderWindowXPos, iRenderWindowYPos; diff --git a/Source/Core/DolphinWX/CMakeLists.txt b/Source/Core/DolphinWX/CMakeLists.txt index 275a68f426..c7f8e371de 100644 --- a/Source/Core/DolphinWX/CMakeLists.txt +++ b/Source/Core/DolphinWX/CMakeLists.txt @@ -41,7 +41,6 @@ set(GUI_SRCS FrameAui.cpp FrameTools.cpp GameListCtrl.cpp - HotkeyDlg.cpp ISOFile.cpp ISOProperties.cpp InputConfigDiag.cpp diff --git a/Source/Core/DolphinWX/DolphinWX.vcxproj b/Source/Core/DolphinWX/DolphinWX.vcxproj index f6ecb0ae14..3ecb72fa13 100644 --- a/Source/Core/DolphinWX/DolphinWX.vcxproj +++ b/Source/Core/DolphinWX/DolphinWX.vcxproj @@ -88,7 +88,6 @@ - @@ -151,7 +150,6 @@ - diff --git a/Source/Core/DolphinWX/DolphinWX.vcxproj.filters b/Source/Core/DolphinWX/DolphinWX.vcxproj.filters index 54604a1a33..87fb5df32a 100644 --- a/Source/Core/DolphinWX/DolphinWX.vcxproj.filters +++ b/Source/Core/DolphinWX/DolphinWX.vcxproj.filters @@ -139,9 +139,6 @@ GUI - - GUI - GUI @@ -303,9 +300,6 @@ GUI - - GUI - GUI diff --git a/Source/Core/DolphinWX/Frame.cpp b/Source/Core/DolphinWX/Frame.cpp index 583275932c..27aec09d9d 100644 --- a/Source/Core/DolphinWX/Frame.cpp +++ b/Source/Core/DolphinWX/Frame.cpp @@ -262,7 +262,6 @@ EVT_MENU(IDM_CONFIG_GFX_BACKEND, CFrame::OnConfigGFX) EVT_MENU(IDM_CONFIG_AUDIO, CFrame::OnConfigAudio) EVT_MENU(IDM_CONFIG_CONTROLLERS, CFrame::OnConfigControllers) EVT_MENU(IDM_CONFIG_HOTKEYS, CFrame::OnConfigHotkey) -EVT_MENU(IDM_CONFIG_MENU_COMMANDS, CFrame::OnConfigMenuCommands) EVT_MENU(IDM_SAVE_PERSPECTIVE, CFrame::OnPerspectiveMenu) EVT_MENU(IDM_EDIT_PERSPECTIVES, CFrame::OnPerspectiveMenu) @@ -930,17 +929,9 @@ void CFrame::OnGameListCtrlItemActivated(wxListEvent& WXUNUSED(event)) } } -static bool IsHotkey(wxKeyEvent &event, int id, bool held = false) +static bool IsHotkey(int id, bool held = false) { - // Input event hotkey - if (event.GetKeyCode() == WXK_NONE) - { - return HotkeyManagerEmu::IsPressed(id, held); - } - - return (event.GetKeyCode() != WXK_NONE && - event.GetKeyCode() == SConfig::GetInstance().m_LocalCoreStartupParameter.iHotkey[id] && - event.GetModifiers() == SConfig::GetInstance().m_LocalCoreStartupParameter.iHotkeyModifier[id]); + return HotkeyManagerEmu::IsPressed(id, held); } int GetCmdForHotkey(unsigned int key) @@ -1077,41 +1068,6 @@ bool TASInputHasFocus() return false; } -void CFrame::OnKeyDown(wxKeyEvent& event) -{ - if (Core::GetState() != Core::CORE_UNINITIALIZED && - (RendererHasFocus() || TASInputHasFocus())) - { - if (IsHotkey(event, HK_TOGGLE_THROTTLE)) - { - Core::SetIsFramelimiterTempDisabled(true); - } - else - { - ParseHotkeys(event); - } - } - else - { - event.Skip(); - } -} - -void CFrame::OnKeyUp(wxKeyEvent& event) -{ - if (Core::IsRunning() && (RendererHasFocus() || TASInputHasFocus())) - { - if (IsHotkey(event, HK_TOGGLE_THROTTLE)) - { - Core::SetIsFramelimiterTempDisabled(false); - } - } - else - { - event.Skip(); - } -} - void CFrame::OnMouse(wxMouseEvent& event) { // next handlers are all for FreeLook, so we don't need to check them if disabled @@ -1300,12 +1256,11 @@ void CFrame::PollHotkeys(wxTimerEvent& event) if (Core::GetState() != Core::CORE_STOPPING) { HotkeyManagerEmu::GetStatus(); - wxKeyEvent keyevent = 0; - ParseHotkeys(keyevent); + ParseHotkeys(); } } -void CFrame::ParseHotkeys(wxKeyEvent &event) +void CFrame::ParseHotkeys() { unsigned int i = 0; for (i = 0; i < NUM_HOTKEYS; i++) @@ -1361,7 +1316,7 @@ void CFrame::ParseHotkeys(wxKeyEvent &event) case HK_LOAD_STATE_SLOT_SELECTED: - if (IsHotkey(event, i)) + if (IsHotkey(i)) { int cmd = GetCmdForHotkey(i); if (cmd >= 0) @@ -1381,56 +1336,44 @@ void CFrame::ParseHotkeys(wxKeyEvent &event) // do nothing } } - // On OS X, we claim all keyboard events while - // emulation is running to avoid wxWidgets sounding - // the system beep for unhandled key events when - // receiving pad/Wiimote keypresses which take an - // entirely different path through the HID subsystem. -#ifndef __APPLE__ - // On other platforms, we leave the key event alone - // so it can be passed on to the windowing system. - if (i == NUM_HOTKEYS) - event.Skip(); -#endif if (Core::GetState() == Core::CORE_UNINITIALIZED) { - event.Skip(); return; } // Toggle fullscreen - if (IsHotkey(event, HK_FULLSCREEN)) + if (IsHotkey(HK_FULLSCREEN)) DoFullscreen(!RendererIsFullscreen()); // Pause and Unpause - if (IsHotkey(event, HK_PLAY_PAUSE)) + if (IsHotkey(HK_PLAY_PAUSE)) DoPause(); // Stop - if (IsHotkey(event, HK_STOP)) + if (IsHotkey(HK_STOP)) DoStop(); // Screenshot hotkey - if (IsHotkey(event, HK_SCREENSHOT)) + if (IsHotkey(HK_SCREENSHOT)) Core::SaveScreenShot(); - if (IsHotkey(event, HK_EXIT)) + if (IsHotkey(HK_EXIT)) wxPostEvent(this, wxCommandEvent(wxID_EXIT)); - if (IsHotkey(event, HK_VOLUME_DOWN)) + if (IsHotkey(HK_VOLUME_DOWN)) AudioCommon::DecreaseVolume(3); - if (IsHotkey(event, HK_VOLUME_UP)) + if (IsHotkey(HK_VOLUME_UP)) AudioCommon::IncreaseVolume(3); - if (IsHotkey(event, HK_VOLUME_TOGGLE_MUTE)) + if (IsHotkey(HK_VOLUME_TOGGLE_MUTE)) AudioCommon::ToggleMuteVolume(); // Wiimote connect and disconnect hotkeys int WiimoteId = -1; - if (IsHotkey(event, HK_WIIMOTE1_CONNECT)) + if (IsHotkey(HK_WIIMOTE1_CONNECT)) WiimoteId = 0; - if (IsHotkey(event, HK_WIIMOTE2_CONNECT)) + if (IsHotkey(HK_WIIMOTE2_CONNECT)) WiimoteId = 1; - if (IsHotkey(event, HK_WIIMOTE3_CONNECT)) + if (IsHotkey(HK_WIIMOTE3_CONNECT)) WiimoteId = 2; - if (IsHotkey(event, HK_WIIMOTE4_CONNECT)) + if (IsHotkey(HK_WIIMOTE4_CONNECT)) WiimoteId = 3; - if (IsHotkey(event, HK_BALANCEBOARD_CONNECT)) + if (IsHotkey(HK_BALANCEBOARD_CONNECT)) WiimoteId = 4; // Actually perform the Wiimote connection or disconnection @@ -1441,84 +1384,77 @@ void CFrame::ParseHotkeys(wxKeyEvent &event) OnConnectWiimote(evt); } - if (IsHotkey(event, HK_TOGGLE_IR)) + if (IsHotkey(HK_TOGGLE_IR)) { OSDChoice = 1; // Toggle native resolution if (++g_Config.iEFBScale > SCALE_4X) g_Config.iEFBScale = SCALE_AUTO; } - if (IsHotkey(event, HK_INCREASE_IR)) + if (IsHotkey(HK_INCREASE_IR)) { OSDChoice = 1; ++g_Config.iEFBScale; } - if (IsHotkey(event, HK_DECREASE_IR)) + if (IsHotkey(HK_DECREASE_IR)) { OSDChoice = 1; if (--g_Config.iEFBScale < SCALE_1X) g_Config.iEFBScale = SCALE_1X; } - if (IsHotkey(event, HK_TOGGLE_AR)) + if (IsHotkey(HK_TOGGLE_AR)) { OSDChoice = 2; // Toggle aspect ratio g_Config.iAspectRatio = (g_Config.iAspectRatio + 1) & 3; } - if (IsHotkey(event, HK_TOGGLE_EFBCOPIES)) + if (IsHotkey(HK_TOGGLE_EFBCOPIES)) { OSDChoice = 3; // Toggle EFB copies between EFB2RAM and EFB2Texture g_Config.bSkipEFBCopyToRam = !g_Config.bSkipEFBCopyToRam; } - if (IsHotkey(event, HK_TOGGLE_FOG)) + if (IsHotkey(HK_TOGGLE_FOG)) { OSDChoice = 4; g_Config.bDisableFog = !g_Config.bDisableFog; } - if (IsHotkey(event, HK_TOGGLE_THROTTLE, false)) - { - Core::SetIsFramelimiterTempDisabled(false); - } - else if (IsHotkey(event, HK_TOGGLE_THROTTLE, true)) - { - Core::SetIsFramelimiterTempDisabled(true); - } - if (IsHotkey(event, HK_DECREASE_FRAME_LIMIT)) + Core::SetIsFramelimiterTempDisabled(IsHotkey(HK_TOGGLE_THROTTLE, true)); + if (IsHotkey(HK_DECREASE_FRAME_LIMIT)) { if (--SConfig::GetInstance().m_Framelimit > 0x19) SConfig::GetInstance().m_Framelimit = 0x19; } - if (IsHotkey(event, HK_INCREASE_FRAME_LIMIT)) + if (IsHotkey(HK_INCREASE_FRAME_LIMIT)) { if (++SConfig::GetInstance().m_Framelimit > 0x19) SConfig::GetInstance().m_Framelimit = 0; } - if (IsHotkey(event, HK_SAVE_STATE_SLOT_SELECTED)) + if (IsHotkey(HK_SAVE_STATE_SLOT_SELECTED)) { State::Save(g_saveSlot); } - if (IsHotkey(event, HK_LOAD_STATE_SLOT_SELECTED)) + if (IsHotkey(HK_LOAD_STATE_SLOT_SELECTED)) { State::Load(g_saveSlot); } - if (IsHotkey(event, HK_DECREASE_DEPTH, true)) + if (IsHotkey(HK_DECREASE_DEPTH, true)) { if (--g_Config.iStereoDepth < 0) g_Config.iStereoDepth = 0; } - if (IsHotkey(event, HK_INCREASE_DEPTH, true)) + if (IsHotkey(HK_INCREASE_DEPTH, true)) { if (++g_Config.iStereoDepth > 100) g_Config.iStereoDepth = 100; } - if (IsHotkey(event, HK_DECREASE_CONVERGENCE, true)) + if (IsHotkey(HK_DECREASE_CONVERGENCE, true)) { g_Config.iStereoConvergence -= 5; if (g_Config.iStereoConvergence < 0) g_Config.iStereoConvergence = 0; } - if (IsHotkey(event, HK_INCREASE_CONVERGENCE, true)) + if (IsHotkey(HK_INCREASE_CONVERGENCE, true)) { g_Config.iStereoConvergence += 5; if (g_Config.iStereoConvergence > 500) @@ -1527,7 +1463,7 @@ void CFrame::ParseHotkeys(wxKeyEvent &event) for (i = HK_SELECT_STATE_SLOT_1; i < HK_SELECT_STATE_SLOT_10; ++i) { - if (IsHotkey(event, i)) + if (IsHotkey(i)) { wxCommandEvent slot_event; slot_event.SetId(i + IDM_SELECT_SLOT_1 - HK_SELECT_STATE_SLOT_1); @@ -1536,24 +1472,24 @@ void CFrame::ParseHotkeys(wxKeyEvent &event) } static float debugSpeed = 1.0f; - if (IsHotkey(event, HK_FREELOOK_DECREASE_SPEED, true)) + if (IsHotkey(HK_FREELOOK_DECREASE_SPEED, true)) debugSpeed /= 1.1f; - if (IsHotkey(event, HK_FREELOOK_INCREASE_SPEED, true)) + if (IsHotkey(HK_FREELOOK_INCREASE_SPEED, true)) debugSpeed *= 1.1f; - if (IsHotkey(event, HK_FREELOOK_RESET_SPEED, true)) + if (IsHotkey(HK_FREELOOK_RESET_SPEED, true)) debugSpeed = 1.0f; - if (IsHotkey(event, HK_FREELOOK_UP, true)) + if (IsHotkey(HK_FREELOOK_UP, true)) VertexShaderManager::TranslateView(0.0f, 0.0f, -debugSpeed); - if (IsHotkey(event, HK_FREELOOK_DOWN, true)) + if (IsHotkey(HK_FREELOOK_DOWN, true)) VertexShaderManager::TranslateView(0.0f, 0.0f, debugSpeed); - if (IsHotkey(event, HK_FREELOOK_LEFT, true)) + if (IsHotkey(HK_FREELOOK_LEFT, true)) VertexShaderManager::TranslateView(debugSpeed, 0.0f); - if (IsHotkey(event, HK_FREELOOK_RIGHT, true)) + if (IsHotkey(HK_FREELOOK_RIGHT, true)) VertexShaderManager::TranslateView(-debugSpeed, 0.0f); - if (IsHotkey(event, HK_FREELOOK_ZOOM_IN, true)) + if (IsHotkey(HK_FREELOOK_ZOOM_IN, true)) VertexShaderManager::TranslateView(0.0f, debugSpeed); - if (IsHotkey(event, HK_FREELOOK_ZOOM_OUT, true)) + if (IsHotkey(HK_FREELOOK_ZOOM_OUT, true)) VertexShaderManager::TranslateView(0.0f, -debugSpeed); - if (IsHotkey(event, HK_FREELOOK_RESET, true)) + if (IsHotkey(HK_FREELOOK_RESET, true)) VertexShaderManager::ResetView(); } diff --git a/Source/Core/DolphinWX/Frame.h b/Source/Core/DolphinWX/Frame.h index c600548d28..4460593497 100644 --- a/Source/Core/DolphinWX/Frame.h +++ b/Source/Core/DolphinWX/Frame.h @@ -306,7 +306,6 @@ private: void OnConfigAudio(wxCommandEvent& event); void OnConfigControllers(wxCommandEvent& event); void OnConfigHotkey(wxCommandEvent& event); - void OnConfigMenuCommands(wxCommandEvent& event); void OnToggleFullscreen(wxCommandEvent& event); void OnToggleDualCore(wxCommandEvent& event); @@ -352,7 +351,7 @@ private: void OnLoadCurrentSlot(wxCommandEvent& event); void PollHotkeys(wxTimerEvent&); - void ParseHotkeys(wxKeyEvent &event); + void ParseHotkeys(); bool InitControllers(); diff --git a/Source/Core/DolphinWX/FrameTools.cpp b/Source/Core/DolphinWX/FrameTools.cpp index 04e31fbfaf..d56a8486b2 100644 --- a/Source/Core/DolphinWX/FrameTools.cpp +++ b/Source/Core/DolphinWX/FrameTools.cpp @@ -60,7 +60,6 @@ #include "DolphinWX/Frame.h" #include "DolphinWX/GameListCtrl.h" #include "DolphinWX/Globals.h" -#include "DolphinWX/HotkeyDlg.h" #include "DolphinWX/InputConfigDiag.h" #include "DolphinWX/ISOFile.h" #include "DolphinWX/LogWindow.h" @@ -230,7 +229,6 @@ 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")); if (g_pCodeWindow) { @@ -390,11 +388,7 @@ wxMenuBar* CFrame::CreateMenu() wxString CFrame::GetMenuLabel(int Id) { - int hotkey = SConfig::GetInstance().\ - m_LocalCoreStartupParameter.iHotkey[Id]; - int hotkeymodifier = SConfig::GetInstance().\ - m_LocalCoreStartupParameter.iHotkeyModifier[Id]; - wxString Hotkey, Label, Modifier; + wxString Label; switch (Id) { @@ -533,14 +527,7 @@ wxString CFrame::GetMenuLabel(int Id) Label = wxString::Format(_("Undefined %i"), Id); } - hotkeymodifier &= wxMOD_CONTROL | wxMOD_ALT | wxMOD_SHIFT; - - Modifier = WxUtils::WXKeymodToString(hotkeymodifier); - Hotkey = WxUtils::WXKeyToString(hotkey); - if (Modifier.Len() + Hotkey.Len() > 0) - Label += '\t'; - - return Label + Modifier + Hotkey; + return Label; } @@ -1059,8 +1046,6 @@ void CFrame::StartGame(const std::string& filename) m_RenderParent->SetFocus(); - wxTheApp->Bind(wxEVT_KEY_DOWN, &CFrame::OnKeyDown, this); - wxTheApp->Bind(wxEVT_KEY_UP, &CFrame::OnKeyUp, this); wxTheApp->Bind(wxEVT_RIGHT_DOWN, &CFrame::OnMouse, this); wxTheApp->Bind(wxEVT_RIGHT_UP, &CFrame::OnMouse, this); wxTheApp->Bind(wxEVT_MIDDLE_DOWN, &CFrame::OnMouse, this); @@ -1222,10 +1207,6 @@ void CFrame::OnStopped() // Destroy the renderer frame when not rendering to main m_RenderParent->Unbind(wxEVT_SIZE, &CFrame::OnRenderParentResize, this); - // Keyboard - wxTheApp->Unbind(wxEVT_KEY_DOWN, &CFrame::OnKeyDown, this); - wxTheApp->Unbind(wxEVT_KEY_UP, &CFrame::OnKeyUp, this); - // Mouse wxTheApp->Unbind(wxEVT_RIGHT_DOWN, &CFrame::OnMouse, this); wxTheApp->Unbind(wxEVT_RIGHT_UP, &CFrame::OnMouse, this); @@ -1340,16 +1321,6 @@ void CFrame::OnConfigControllers(wxCommandEvent& WXUNUSED (event)) config_dlg.ShowModal(); } -void CFrame::OnConfigMenuCommands(wxCommandEvent& WXUNUSED(event)) -{ - HotkeyConfigDialog m_HotkeyDialog(this); - m_HotkeyDialog.ShowModal(); - - // Update the GUI in case menu accelerators were changed - UpdateGUI(); -} - - void CFrame::OnConfigHotkey(wxCommandEvent& WXUNUSED (event)) { InputConfig* const hotkey_plugin = HotkeyManagerEmu::GetConfig(); diff --git a/Source/Core/DolphinWX/Globals.h b/Source/Core/DolphinWX/Globals.h index 246d3e384c..2b327b0fad 100644 --- a/Source/Core/DolphinWX/Globals.h +++ b/Source/Core/DolphinWX/Globals.h @@ -158,7 +158,6 @@ enum IDM_CONFIG_AUDIO, IDM_CONFIG_CONTROLLERS, IDM_CONFIG_HOTKEYS, - IDM_CONFIG_MENU_COMMANDS, IDM_CONFIG_LOGGER, // Views diff --git a/Source/Core/DolphinWX/HotkeyDlg.cpp b/Source/Core/DolphinWX/HotkeyDlg.cpp deleted file mode 100644 index 74a12f0863..0000000000 --- a/Source/Core/DolphinWX/HotkeyDlg.cpp +++ /dev/null @@ -1,360 +0,0 @@ -// Copyright 2010 Dolphin Emulator Project -// Licensed under GPLv2+ -// Refer to the license.txt file included. - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "Core/ConfigManager.h" -#include "Core/CoreParameter.h" -#include "DolphinWX/HotkeyDlg.h" -#include "DolphinWX/WXInputBase.h" - -HotkeyConfigDialog::HotkeyConfigDialog(wxWindow *parent, wxWindowID id, const wxString &title, - const wxPoint &position, const wxSize& size, long style) -: wxDialog(parent, id, title, position, size, style) -, m_ButtonMappingTimer(this) -{ - CreateHotkeyGUIControls(); - - Bind(wxEVT_BUTTON, &HotkeyConfigDialog::OnButtonClick, this, 0, NUM_HOTKEYS - 1); - Bind(wxEVT_TIMER, &HotkeyConfigDialog::OnButtonTimer, this); - - g_Pressed = 0; - g_Modkey = 0; - ClickedButton = nullptr; - GetButtonWaitingID = 0; - GetButtonWaitingTimer = 0; -} - -HotkeyConfigDialog::~HotkeyConfigDialog() -{ -} - -// Save keyboard key mapping -void HotkeyConfigDialog::SaveButtonMapping(int Id, int Key, int Modkey) -{ - SConfig::GetInstance().m_LocalCoreStartupParameter.iHotkey[Id] = Key; - SConfig::GetInstance().m_LocalCoreStartupParameter.iHotkeyModifier[Id] = Modkey; -} - -void HotkeyConfigDialog::EndGetButtons() -{ - m_ButtonMappingTimer.Stop(); - GetButtonWaitingTimer = 0; - GetButtonWaitingID = 0; - ClickedButton = nullptr; - SetEscapeId(wxID_ANY); -} - -void HotkeyConfigDialog::OnKeyDown(wxKeyEvent& event) -{ - if (ClickedButton != nullptr) - { - // Save the key - g_Pressed = event.GetKeyCode(); - g_Modkey = event.GetModifiers(); - - // Don't allow modifier keys - if (g_Pressed == WXK_CONTROL || g_Pressed == WXK_ALT || - g_Pressed == WXK_SHIFT || g_Pressed == WXK_COMMAND) - return; - - // Use the space key to set a blank key - if (g_Pressed == WXK_SPACE) - { - SaveButtonMapping(ClickedButton->GetId(), -1, 0); - SetButtonText(ClickedButton->GetId(), wxString()); - } - else - { - // Check if the hotkey combination was already applied to another button - // and unapply it if necessary. - for (wxButton* btn : m_Button_Hotkeys) - { - // We compare against this to see if we have a duplicate bind attempt. - wxString existingHotkey = btn->GetLabel(); - - wxString tentativeModKey = WxUtils::WXKeymodToString(g_Modkey); - wxString tentativePressedKey = WxUtils::WXKeyToString(g_Pressed); - wxString tentativeHotkey(tentativeModKey + tentativePressedKey); - - // Found a button that already has this binding. Unbind it. - if (tentativeHotkey == existingHotkey) - { - SaveButtonMapping(btn->GetId(), -1, 0); - SetButtonText(btn->GetId(), wxString()); - } - } - - // Proceed to apply the binding to the selected button. - SetButtonText(ClickedButton->GetId(), - WxUtils::WXKeyToString(g_Pressed), - WxUtils::WXKeymodToString(g_Modkey)); - SaveButtonMapping(ClickedButton->GetId(), g_Pressed, g_Modkey); - } - EndGetButtons(); - } -} - -// Update the textbox for the buttons -void HotkeyConfigDialog::SetButtonText(int id, const wxString &keystr, const wxString &modkeystr) -{ - m_Button_Hotkeys[id]->SetLabel(modkeystr + keystr); -} - -void HotkeyConfigDialog::DoGetButtons(int _GetId) -{ - // Values used in this function - const int Seconds = 4; // Seconds to wait for - const int TimesPerSecond = 40; // How often to run the check - - // If the Id has changed or the timer is not running we should start one - if ( GetButtonWaitingID != _GetId || !m_ButtonMappingTimer.IsRunning() ) - { - if (m_ButtonMappingTimer.IsRunning()) - m_ButtonMappingTimer.Stop(); - - // Save the button Id - GetButtonWaitingID = _GetId; - GetButtonWaitingTimer = 0; - - // Start the timer - m_ButtonMappingTimer.Start(1000 / TimesPerSecond); - } - - // Process results - // Count each time - GetButtonWaitingTimer++; - - // This is run every second - if (GetButtonWaitingTimer % TimesPerSecond == 0) - { - // Current time - int TmpTime = Seconds - (GetButtonWaitingTimer / TimesPerSecond); - // Update text - SetButtonText(_GetId, wxString::Format("[ %d ]", TmpTime)); - } - - // Time's up - if (GetButtonWaitingTimer / TimesPerSecond >= Seconds) - { - // Revert back to old label - SetButtonText(_GetId, OldLabel); - EndGetButtons(); - } -} - -// Input button clicked -void HotkeyConfigDialog::OnButtonClick(wxCommandEvent& event) -{ - event.Skip(); - - if (m_ButtonMappingTimer.IsRunning()) - return; - - // Get the button - ClickedButton = (wxButton *)event.GetEventObject(); - SetEscapeId(wxID_CANCEL); - // Save old label so we can revert back - OldLabel = ClickedButton->GetLabel(); - ClickedButton->SetWindowStyle(wxWANTS_CHARS); - ClickedButton->SetLabel(_("")); - DoGetButtons(ClickedButton->GetId()); -} - -#define HOTKEY_NUM_COLUMNS 2 - -const wxString hkText[] = -{ - _("Open"), - _("Change Disc"), - _("Refresh List"), - - _("Play/Pause"), - _("Stop"), - _("Reset"), - _("Frame Advance"), - - _("Start Recording"), - _("Play Recording"), - _("Export Recording"), - _("Read-only mode"), - - _("Toggle Fullscreen"), - _("Take Screenshot"), - _("Exit"), - - _("Connect Wiimote 1"), - _("Connect Wiimote 2"), - _("Connect Wiimote 3"), - _("Connect Wiimote 4"), - _("Connect Balance Board"), - - _("Volume Down"), - _("Volume Up"), - _("Volume Toggle Mute"), - - _("Increase IR"), - _("Decrease IR"), - - _("Toggle IR"), - _("Toggle Aspect Ratio"), - _("Toggle EFB Copies"), - _("Toggle Fog"), - _("Toggle Frame limit"), - _("Decrease Frame limit"), - _("Increase Frame limit"), - - _("Freelook Decrease Speed"), - _("Freelook Increase Speed"), - _("Freelook Reset Speed"), - _("Freelook Move Up"), - _("Freelook Move Down"), - _("Freelook Move Left"), - _("Freelook Move Right"), - _("Freelook Zoom In"), - _("Freelook Zoom Out"), - _("Freelook Reset"), - - _("Decrease Depth"), - _("Increase Depth"), - _("Decrease Convergence"), - _("Increase Convergence"), - - _("Load State Slot 1"), - _("Load State Slot 2"), - _("Load State Slot 3"), - _("Load State Slot 4"), - _("Load State Slot 5"), - _("Load State Slot 6"), - _("Load State Slot 7"), - _("Load State Slot 8"), - _("Load State Slot 9"), - _("Load State Slot 10"), - - _("Save State Slot 1"), - _("Save State Slot 2"), - _("Save State Slot 3"), - _("Save State Slot 4"), - _("Save State Slot 5"), - _("Save State Slot 6"), - _("Save State Slot 7"), - _("Save State Slot 8"), - _("Save State Slot 9"), - _("Save State Slot 10"), - - _("Select State Slot 1"), - _("Select State Slot 2"), - _("Select State Slot 3"), - _("Select State Slot 4"), - _("Select State Slot 5"), - _("Select State Slot 6"), - _("Select State Slot 7"), - _("Select State Slot 8"), - _("Select State Slot 9"), - _("Select State Slot 10"), - - _("Save to selected slot"), - _("Load from selected slot"), - - _("Load State Last 1"), - _("Load State Last 2"), - _("Load State Last 3"), - _("Load State Last 4"), - _("Load State Last 5"), - _("Load State Last 6"), - _("Load State Last 7"), - _("Load State Last 8"), - - _("Save Oldest State"), - _("Undo Load State"), - _("Undo Save State"), - _("Save State"), - _("Load State"), -}; - -void HotkeyConfigDialog::CreateHotkeyGUIControls() -{ - const wxString pageNames[] = - { - _("General"), - _("State Saves") - }; - - const int page_breaks[3] = {HK_OPEN, HK_LOAD_STATE_SLOT_1, NUM_HOTKEYS}; - - // Configuration controls sizes - wxSize size(100,20); - // A small type font - wxFont m_SmallFont(7, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); - - wxNotebook *Notebook = new wxNotebook(this, wxID_ANY); - - for (int j = 0; j < 2; j++) - { - wxPanel *Page = new wxPanel(Notebook); - Notebook->AddPage(Page, pageNames[j]); - - wxGridBagSizer *sHotkeys = new wxGridBagSizer(); - - // Header line - for (int i = 0; i < HOTKEY_NUM_COLUMNS; i++) - { - wxBoxSizer *HeaderSizer = new wxBoxSizer(wxHORIZONTAL); - wxStaticText *StaticTextHeader = new wxStaticText(Page, wxID_ANY, _("Action")); - HeaderSizer->Add(StaticTextHeader, 1, wxALL, 2); - StaticTextHeader = new wxStaticText(Page, wxID_ANY, _("Key"), wxDefaultPosition, size); - HeaderSizer->Add(StaticTextHeader, 0, wxALL, 2); - sHotkeys->Add(HeaderSizer, wxGBPosition(0, i), wxDefaultSpan, wxEXPAND | wxLEFT, (i > 0) ? 30 : 1); - } - - int column_break = (page_breaks[j+1] + page_breaks[j] + 1) / 2; - - for (int i = page_breaks[j]; i < page_breaks[j+1]; i++) - { - // Text for the action - wxStaticText *stHotkeys = new wxStaticText(Page, wxID_ANY, hkText[i]); - - // Key selection button - m_Button_Hotkeys[i] = new wxButton(Page, i, wxEmptyString, wxDefaultPosition, size); - m_Button_Hotkeys[i]->SetFont(m_SmallFont); - m_Button_Hotkeys[i]->SetToolTip(_("Left click to detect hotkeys.\nEnter space to clear.")); - m_Button_Hotkeys[i]->Bind(wxEVT_KEY_DOWN, &HotkeyConfigDialog::OnKeyDown, this); - SetButtonText(i, - WxUtils::WXKeyToString(SConfig::GetInstance().m_LocalCoreStartupParameter.iHotkey[i]), - WxUtils::WXKeymodToString( - SConfig::GetInstance().m_LocalCoreStartupParameter.iHotkeyModifier[i])); - - wxBoxSizer *sHotkey = new wxBoxSizer(wxHORIZONTAL); - sHotkey->Add(stHotkeys, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 2); - sHotkey->Add(m_Button_Hotkeys[i], 0, wxALL, 2); - sHotkeys->Add(sHotkey, - wxGBPosition((i < column_break) ? i - page_breaks[j] + 1 : i - column_break + 1, - (i < column_break) ? 0 : 1), - wxDefaultSpan, wxEXPAND | wxLEFT, (i < column_break) ? 1 : 30); - } - - wxStaticBoxSizer *sHotkeyBox = new wxStaticBoxSizer(wxVERTICAL, Page, _("Hotkeys")); - sHotkeyBox->Add(sHotkeys); - - wxBoxSizer* const sPage = new wxBoxSizer(wxVERTICAL); - sPage->Add(sHotkeyBox, 0, wxEXPAND | wxALL, 5); - Page->SetSizer(sPage); - } - - wxBoxSizer *sMainSizer = new wxBoxSizer(wxVERTICAL); - sMainSizer->Add(Notebook, 0, wxEXPAND | wxALL, 5); - sMainSizer->Add(CreateButtonSizer(wxOK), 0, wxEXPAND | wxLEFT | wxRIGHT | wxDOWN, 5); - SetSizerAndFit(sMainSizer); - SetFocus(); -} - diff --git a/Source/Core/DolphinWX/HotkeyDlg.h b/Source/Core/DolphinWX/HotkeyDlg.h deleted file mode 100644 index a713a0789f..0000000000 --- a/Source/Core/DolphinWX/HotkeyDlg.h +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2010 Dolphin Emulator Project -// Licensed under GPLv2+ -// Refer to the license.txt file included. - -#pragma once - -#include -#include - -#include "Core/CoreParameter.h" - -#if defined(HAVE_X11) && HAVE_X11 -#include -#include -#endif - -class wxButton; - -class HotkeyConfigDialog : public wxDialog -{ -public: - HotkeyConfigDialog(wxWindow* parent, - wxWindowID id = wxID_ANY, - const wxString &title = _("Key Shortcuts"), - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_DIALOG_STYLE); - virtual ~HotkeyConfigDialog(); - -private: - wxString OldLabel; - - wxButton* ClickedButton; - wxButton* m_Button_Hotkeys[NUM_HOTKEYS]; - - wxTimer m_ButtonMappingTimer; - - void OnButtonTimer(wxTimerEvent& WXUNUSED(event)) { DoGetButtons(GetButtonWaitingID); } - void OnButtonClick(wxCommandEvent& event); - void OnKeyDown(wxKeyEvent& event); - void SaveButtonMapping(int Id, int Key, int Modkey); - void CreateHotkeyGUIControls(); - - void SetButtonText(int id, const wxString &keystr, const wxString &modkeystr = wxString()); - - void DoGetButtons(int id); - void EndGetButtons(); - - int GetButtonWaitingID, GetButtonWaitingTimer, g_Pressed, g_Modkey; -}; From dfc951fbbbc6021838f38da3d94396212a1bd60e Mon Sep 17 00:00:00 2001 From: degasus Date: Tue, 2 Jun 2015 23:40:02 +0200 Subject: [PATCH 2/2] Hotkey: move some code into ParseHotkey --- Source/Core/Core/CoreParameter.h | 2 + Source/Core/DolphinWX/Frame.cpp | 76 ++++++++++++-------------------- 2 files changed, 30 insertions(+), 48 deletions(-) diff --git a/Source/Core/Core/CoreParameter.h b/Source/Core/Core/CoreParameter.h index 7be02ce6f6..43d758bbad 100644 --- a/Source/Core/Core/CoreParameter.h +++ b/Source/Core/Core/CoreParameter.h @@ -111,6 +111,8 @@ enum Hotkey HK_LOAD_LAST_STATE_6, HK_LOAD_LAST_STATE_7, HK_LOAD_LAST_STATE_8, + HK_LOAD_LAST_STATE_9, + HK_LOAD_LAST_STATE_10, HK_SAVE_FIRST_STATE, HK_UNDO_LOAD_STATE, diff --git a/Source/Core/DolphinWX/Frame.cpp b/Source/Core/DolphinWX/Frame.cpp index 27aec09d9d..e541ace507 100644 --- a/Source/Core/DolphinWX/Frame.cpp +++ b/Source/Core/DolphinWX/Frame.cpp @@ -1262,8 +1262,7 @@ void CFrame::PollHotkeys(wxTimerEvent& event) void CFrame::ParseHotkeys() { - unsigned int i = 0; - for (i = 0; i < NUM_HOTKEYS; i++) + for (int i = 0; i < NUM_HOTKEYS; i++) { switch (i) { @@ -1277,43 +1276,8 @@ void CFrame::ParseHotkeys() case HK_EXPORT_RECORDING: case HK_READ_ONLY_MODE: - case HK_LOAD_STATE_SLOT_1: - case HK_LOAD_STATE_SLOT_2: - case HK_LOAD_STATE_SLOT_3: - case HK_LOAD_STATE_SLOT_4: - case HK_LOAD_STATE_SLOT_5: - case HK_LOAD_STATE_SLOT_6: - case HK_LOAD_STATE_SLOT_7: - case HK_LOAD_STATE_SLOT_8: - case HK_LOAD_STATE_SLOT_9: - case HK_LOAD_STATE_SLOT_10: - - case HK_SAVE_STATE_SLOT_1: - case HK_SAVE_STATE_SLOT_2: - case HK_SAVE_STATE_SLOT_3: - case HK_SAVE_STATE_SLOT_4: - case HK_SAVE_STATE_SLOT_5: - case HK_SAVE_STATE_SLOT_6: - case HK_SAVE_STATE_SLOT_7: - case HK_SAVE_STATE_SLOT_8: - case HK_SAVE_STATE_SLOT_9: - case HK_SAVE_STATE_SLOT_10: - - case HK_LOAD_LAST_STATE_1: - case HK_LOAD_LAST_STATE_2: - case HK_LOAD_LAST_STATE_3: - case HK_LOAD_LAST_STATE_4: - case HK_LOAD_LAST_STATE_5: - case HK_LOAD_LAST_STATE_6: - case HK_LOAD_LAST_STATE_7: - case HK_LOAD_LAST_STATE_8: - - case HK_SAVE_FIRST_STATE: - case HK_UNDO_LOAD_STATE: - case HK_UNDO_SAVE_STATE: case HK_LOAD_STATE_FILE: case HK_SAVE_STATE_FILE: - case HK_LOAD_STATE_SLOT_SELECTED: if (IsHotkey(i)) @@ -1337,7 +1301,7 @@ void CFrame::ParseHotkeys() } } - if (Core::GetState() == Core::CORE_UNINITIALIZED) + if (!Core::IsRunningAndStarted()) { return; } @@ -1461,16 +1425,6 @@ void CFrame::ParseHotkeys() g_Config.iStereoConvergence = 500; } - for (i = HK_SELECT_STATE_SLOT_1; i < HK_SELECT_STATE_SLOT_10; ++i) - { - if (IsHotkey(i)) - { - wxCommandEvent slot_event; - slot_event.SetId(i + IDM_SELECT_SLOT_1 - HK_SELECT_STATE_SLOT_1); - CFrame::OnSelectSlot(slot_event); - } - } - static float debugSpeed = 1.0f; if (IsHotkey(HK_FREELOOK_DECREASE_SPEED, true)) debugSpeed /= 1.1f; @@ -1492,4 +1446,30 @@ void CFrame::ParseHotkeys() VertexShaderManager::TranslateView(0.0f, -debugSpeed); if (IsHotkey(HK_FREELOOK_RESET, true)) VertexShaderManager::ResetView(); + + // Savestates + for (int i = 0; i < 10; i++) + { + if (IsHotkey(HK_LOAD_STATE_SLOT_1 + i)) + State::Load(1 + i); + + if (IsHotkey(HK_SAVE_STATE_SLOT_1 + i)) + State::Save(1 + i); + + if (IsHotkey(HK_LOAD_LAST_STATE_1 + i)) + State::LoadLastSaved(1 + i); + + if (IsHotkey(HK_SELECT_STATE_SLOT_1 + i)) + { + wxCommandEvent slot_event; + slot_event.SetId(i + IDM_SELECT_SLOT_1 - HK_SELECT_STATE_SLOT_1); + CFrame::OnSelectSlot(slot_event); + } + } + if (IsHotkey(HK_SAVE_FIRST_STATE)) + State::SaveFirstSaved(); + if (IsHotkey(HK_UNDO_LOAD_STATE)) + State::UndoLoadState(); + if (IsHotkey(HK_UNDO_SAVE_STATE)) + State::UndoSaveState(); }