From 3e12787cc8e801c00957f1e5305622ea1eb3423b Mon Sep 17 00:00:00 2001 From: skidau Date: Sat, 7 Mar 2015 14:41:08 +1100 Subject: [PATCH] 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 = ""; + } + } }