Merge pull request #2518 from degasus/hotkeys

Hotkeys: Drop old GUI
This commit is contained in:
Matthew Parlane 2015-06-07 20:10:10 +10:00
commit cf8f049c4d
12 changed files with 80 additions and 778 deletions

View File

@ -13,139 +13,6 @@
SConfig* SConfig::m_Instance; 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() SConfig::SConfig()
{ {
// Make sure we have log manager // Make sure we have log manager
@ -178,7 +45,6 @@ void SConfig::SaveSettings()
SaveGeneralSettings(ini); SaveGeneralSettings(ini);
SaveInterfaceSettings(ini); SaveInterfaceSettings(ini);
SaveHotkeySettings(ini);
SaveDisplaySettings(ini); SaveDisplaySettings(ini);
SaveGameListSettings(ini); SaveGameListSettings(ini);
SaveCoreSettings(ini); SaveCoreSettings(ini);
@ -251,18 +117,6 @@ void SConfig::SaveInterfaceSettings(IniFile& ini)
interface->Set("PauseOnFocusLost", m_PauseOnFocusLost); 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) void SConfig::SaveDisplaySettings(IniFile& ini)
{ {
IniFile::Section* display = ini.GetOrCreateSection("Display"); IniFile::Section* display = ini.GetOrCreateSection("Display");
@ -407,7 +261,6 @@ void SConfig::LoadSettings()
LoadGeneralSettings(ini); LoadGeneralSettings(ini);
LoadInterfaceSettings(ini); LoadInterfaceSettings(ini);
LoadHotkeySettings(ini);
LoadDisplaySettings(ini); LoadDisplaySettings(ini);
LoadGameListSettings(ini); LoadGameListSettings(ini);
LoadCoreSettings(ini); LoadCoreSettings(ini);
@ -501,19 +354,6 @@ void SConfig::LoadInterfaceSettings(IniFile& ini)
interface->Get("PauseOnFocusLost", &m_PauseOnFocusLost, false); 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) void SConfig::LoadDisplaySettings(IniFile& ini)
{ {
IniFile::Section* display = ini.GetOrCreateSection("Display"); IniFile::Section* display = ini.GetOrCreateSection("Display");

View File

@ -139,7 +139,6 @@ private:
void SaveGeneralSettings(IniFile& ini); void SaveGeneralSettings(IniFile& ini);
void SaveInterfaceSettings(IniFile& ini); void SaveInterfaceSettings(IniFile& ini);
void SaveDisplaySettings(IniFile& ini); void SaveDisplaySettings(IniFile& ini);
void SaveHotkeySettings(IniFile& ini);
void SaveGameListSettings(IniFile& ini); void SaveGameListSettings(IniFile& ini);
void SaveCoreSettings(IniFile& ini); void SaveCoreSettings(IniFile& ini);
void SaveDSPSettings(IniFile& ini); void SaveDSPSettings(IniFile& ini);
@ -150,7 +149,6 @@ private:
void LoadGeneralSettings(IniFile& ini); void LoadGeneralSettings(IniFile& ini);
void LoadInterfaceSettings(IniFile& ini); void LoadInterfaceSettings(IniFile& ini);
void LoadDisplaySettings(IniFile& ini); void LoadDisplaySettings(IniFile& ini);
void LoadHotkeySettings(IniFile& ini);
void LoadGameListSettings(IniFile& ini); void LoadGameListSettings(IniFile& ini);
void LoadCoreSettings(IniFile& ini); void LoadCoreSettings(IniFile& ini);
void LoadDSPSettings(IniFile& ini); void LoadDSPSettings(IniFile& ini);

View File

@ -111,6 +111,8 @@ enum Hotkey
HK_LOAD_LAST_STATE_6, HK_LOAD_LAST_STATE_6,
HK_LOAD_LAST_STATE_7, HK_LOAD_LAST_STATE_7,
HK_LOAD_LAST_STATE_8, HK_LOAD_LAST_STATE_8,
HK_LOAD_LAST_STATE_9,
HK_LOAD_LAST_STATE_10,
HK_SAVE_FIRST_STATE, HK_SAVE_FIRST_STATE,
HK_UNDO_LOAD_STATE, HK_UNDO_LOAD_STATE,
@ -193,10 +195,6 @@ struct SCoreStartupParameter
bool bConfirmStop, bHideCursor, bAutoHideCursor, bUsePanicHandlers, bOnScreenDisplayMessages; bool bConfirmStop, bHideCursor, bAutoHideCursor, bUsePanicHandlers, bOnScreenDisplayMessages;
std::string theme_name; std::string theme_name;
// Hotkeys
int iHotkey[NUM_HOTKEYS];
int iHotkeyModifier[NUM_HOTKEYS];
// Display settings // Display settings
std::string strFullscreenResolution; std::string strFullscreenResolution;
int iRenderWindowXPos, iRenderWindowYPos; int iRenderWindowXPos, iRenderWindowYPos;

View File

@ -41,7 +41,6 @@ set(GUI_SRCS
FrameAui.cpp FrameAui.cpp
FrameTools.cpp FrameTools.cpp
GameListCtrl.cpp GameListCtrl.cpp
HotkeyDlg.cpp
ISOFile.cpp ISOFile.cpp
ISOProperties.cpp ISOProperties.cpp
InputConfigDiag.cpp InputConfigDiag.cpp

View File

@ -88,7 +88,6 @@
<ClCompile Include="FrameAui.cpp" /> <ClCompile Include="FrameAui.cpp" />
<ClCompile Include="FrameTools.cpp" /> <ClCompile Include="FrameTools.cpp" />
<ClCompile Include="GameListCtrl.cpp" /> <ClCompile Include="GameListCtrl.cpp" />
<ClCompile Include="HotkeyDlg.cpp" />
<ClCompile Include="InputConfigDiag.cpp" /> <ClCompile Include="InputConfigDiag.cpp" />
<ClCompile Include="InputConfigDiagBitmaps.cpp" /> <ClCompile Include="InputConfigDiagBitmaps.cpp" />
<ClCompile Include="ISOFile.cpp" /> <ClCompile Include="ISOFile.cpp" />
@ -151,7 +150,6 @@
<ClInclude Include="Frame.h" /> <ClInclude Include="Frame.h" />
<ClInclude Include="GameListCtrl.h" /> <ClInclude Include="GameListCtrl.h" />
<ClInclude Include="Globals.h" /> <ClInclude Include="Globals.h" />
<ClInclude Include="HotkeyDlg.h" />
<ClInclude Include="InputConfigDiag.h" /> <ClInclude Include="InputConfigDiag.h" />
<ClInclude Include="ISOFile.h" /> <ClInclude Include="ISOFile.h" />
<ClInclude Include="ISOProperties.h" /> <ClInclude Include="ISOProperties.h" />

View File

@ -139,9 +139,6 @@
<ClCompile Include="GameListCtrl.cpp"> <ClCompile Include="GameListCtrl.cpp">
<Filter>GUI</Filter> <Filter>GUI</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="HotkeyDlg.cpp">
<Filter>GUI</Filter>
</ClCompile>
<ClCompile Include="ISOProperties.cpp"> <ClCompile Include="ISOProperties.cpp">
<Filter>GUI</Filter> <Filter>GUI</Filter>
</ClCompile> </ClCompile>
@ -303,9 +300,6 @@
<ClInclude Include="Globals.h"> <ClInclude Include="Globals.h">
<Filter>GUI</Filter> <Filter>GUI</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="HotkeyDlg.h">
<Filter>GUI</Filter>
</ClInclude>
<ClInclude Include="ISOProperties.h"> <ClInclude Include="ISOProperties.h">
<Filter>GUI</Filter> <Filter>GUI</Filter>
</ClInclude> </ClInclude>

View File

@ -262,7 +262,6 @@ EVT_MENU(IDM_CONFIG_GFX_BACKEND, CFrame::OnConfigGFX)
EVT_MENU(IDM_CONFIG_AUDIO, CFrame::OnConfigAudio) EVT_MENU(IDM_CONFIG_AUDIO, CFrame::OnConfigAudio)
EVT_MENU(IDM_CONFIG_CONTROLLERS, CFrame::OnConfigControllers) EVT_MENU(IDM_CONFIG_CONTROLLERS, CFrame::OnConfigControllers)
EVT_MENU(IDM_CONFIG_HOTKEYS, CFrame::OnConfigHotkey) 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_SAVE_PERSPECTIVE, CFrame::OnPerspectiveMenu)
EVT_MENU(IDM_EDIT_PERSPECTIVES, CFrame::OnPerspectiveMenu) EVT_MENU(IDM_EDIT_PERSPECTIVES, CFrame::OnPerspectiveMenu)
@ -934,17 +933,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 return HotkeyManagerEmu::IsPressed(id, held);
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]);
} }
int GetCmdForHotkey(unsigned int key) int GetCmdForHotkey(unsigned int key)
@ -1081,41 +1072,6 @@ bool TASInputHasFocus()
return false; 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) void CFrame::OnMouse(wxMouseEvent& event)
{ {
// next handlers are all for FreeLook, so we don't need to check them if disabled // next handlers are all for FreeLook, so we don't need to check them if disabled
@ -1304,15 +1260,13 @@ void CFrame::PollHotkeys(wxTimerEvent& event)
if (Core::GetState() != Core::CORE_STOPPING) if (Core::GetState() != Core::CORE_STOPPING)
{ {
HotkeyManagerEmu::GetStatus(); HotkeyManagerEmu::GetStatus();
wxKeyEvent keyevent = 0; ParseHotkeys();
ParseHotkeys(keyevent);
} }
} }
void CFrame::ParseHotkeys(wxKeyEvent &event) void CFrame::ParseHotkeys()
{ {
unsigned int i = 0; for (int i = 0; i < NUM_HOTKEYS; i++)
for (i = 0; i < NUM_HOTKEYS; i++)
{ {
switch (i) switch (i)
{ {
@ -1326,46 +1280,11 @@ void CFrame::ParseHotkeys(wxKeyEvent &event)
case HK_EXPORT_RECORDING: case HK_EXPORT_RECORDING:
case HK_READ_ONLY_MODE: 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_LOAD_STATE_FILE:
case HK_SAVE_STATE_FILE: case HK_SAVE_STATE_FILE:
case HK_LOAD_STATE_SLOT_SELECTED: case HK_LOAD_STATE_SLOT_SELECTED:
if (IsHotkey(event, i)) if (IsHotkey(i))
{ {
int cmd = GetCmdForHotkey(i); int cmd = GetCmdForHotkey(i);
if (cmd >= 0) if (cmd >= 0)
@ -1385,56 +1304,44 @@ void CFrame::ParseHotkeys(wxKeyEvent &event)
// do nothing // 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) if (!Core::IsRunningAndStarted())
{ {
event.Skip();
return; return;
} }
// Toggle fullscreen // Toggle fullscreen
if (IsHotkey(event, HK_FULLSCREEN)) if (IsHotkey(HK_FULLSCREEN))
DoFullscreen(!RendererIsFullscreen()); DoFullscreen(!RendererIsFullscreen());
// Pause and Unpause // Pause and Unpause
if (IsHotkey(event, HK_PLAY_PAUSE)) if (IsHotkey(HK_PLAY_PAUSE))
DoPause(); DoPause();
// Stop // Stop
if (IsHotkey(event, HK_STOP)) if (IsHotkey(HK_STOP))
DoStop(); DoStop();
// Screenshot hotkey // Screenshot hotkey
if (IsHotkey(event, HK_SCREENSHOT)) if (IsHotkey(HK_SCREENSHOT))
Core::SaveScreenShot(); Core::SaveScreenShot();
if (IsHotkey(event, HK_EXIT)) if (IsHotkey(HK_EXIT))
wxPostEvent(this, wxCommandEvent(wxID_EXIT)); wxPostEvent(this, wxCommandEvent(wxID_EXIT));
if (IsHotkey(event, HK_VOLUME_DOWN)) if (IsHotkey(HK_VOLUME_DOWN))
AudioCommon::DecreaseVolume(3); AudioCommon::DecreaseVolume(3);
if (IsHotkey(event, HK_VOLUME_UP)) if (IsHotkey(HK_VOLUME_UP))
AudioCommon::IncreaseVolume(3); AudioCommon::IncreaseVolume(3);
if (IsHotkey(event, HK_VOLUME_TOGGLE_MUTE)) if (IsHotkey(HK_VOLUME_TOGGLE_MUTE))
AudioCommon::ToggleMuteVolume(); AudioCommon::ToggleMuteVolume();
// Wiimote connect and disconnect hotkeys // Wiimote connect and disconnect hotkeys
int WiimoteId = -1; int WiimoteId = -1;
if (IsHotkey(event, HK_WIIMOTE1_CONNECT)) if (IsHotkey(HK_WIIMOTE1_CONNECT))
WiimoteId = 0; WiimoteId = 0;
if (IsHotkey(event, HK_WIIMOTE2_CONNECT)) if (IsHotkey(HK_WIIMOTE2_CONNECT))
WiimoteId = 1; WiimoteId = 1;
if (IsHotkey(event, HK_WIIMOTE3_CONNECT)) if (IsHotkey(HK_WIIMOTE3_CONNECT))
WiimoteId = 2; WiimoteId = 2;
if (IsHotkey(event, HK_WIIMOTE4_CONNECT)) if (IsHotkey(HK_WIIMOTE4_CONNECT))
WiimoteId = 3; WiimoteId = 3;
if (IsHotkey(event, HK_BALANCEBOARD_CONNECT)) if (IsHotkey(HK_BALANCEBOARD_CONNECT))
WiimoteId = 4; WiimoteId = 4;
// Actually perform the Wiimote connection or disconnection // Actually perform the Wiimote connection or disconnection
@ -1445,119 +1352,128 @@ void CFrame::ParseHotkeys(wxKeyEvent &event)
OnConnectWiimote(evt); OnConnectWiimote(evt);
} }
if (IsHotkey(event, HK_TOGGLE_IR)) if (IsHotkey(HK_TOGGLE_IR))
{ {
OSDChoice = 1; OSDChoice = 1;
// Toggle native resolution // Toggle native resolution
if (++g_Config.iEFBScale > SCALE_4X) if (++g_Config.iEFBScale > SCALE_4X)
g_Config.iEFBScale = SCALE_AUTO; g_Config.iEFBScale = SCALE_AUTO;
} }
if (IsHotkey(event, HK_INCREASE_IR)) if (IsHotkey(HK_INCREASE_IR))
{ {
OSDChoice = 1; OSDChoice = 1;
++g_Config.iEFBScale; ++g_Config.iEFBScale;
} }
if (IsHotkey(event, HK_DECREASE_IR)) if (IsHotkey(HK_DECREASE_IR))
{ {
OSDChoice = 1; OSDChoice = 1;
if (--g_Config.iEFBScale < SCALE_1X) if (--g_Config.iEFBScale < SCALE_1X)
g_Config.iEFBScale = SCALE_1X; g_Config.iEFBScale = SCALE_1X;
} }
if (IsHotkey(event, HK_TOGGLE_AR)) if (IsHotkey(HK_TOGGLE_AR))
{ {
OSDChoice = 2; OSDChoice = 2;
// Toggle aspect ratio // Toggle aspect ratio
g_Config.iAspectRatio = (g_Config.iAspectRatio + 1) & 3; g_Config.iAspectRatio = (g_Config.iAspectRatio + 1) & 3;
} }
if (IsHotkey(event, HK_TOGGLE_EFBCOPIES)) if (IsHotkey(HK_TOGGLE_EFBCOPIES))
{ {
OSDChoice = 3; OSDChoice = 3;
// Toggle EFB copies between EFB2RAM and EFB2Texture // Toggle EFB copies between EFB2RAM and EFB2Texture
g_Config.bSkipEFBCopyToRam = !g_Config.bSkipEFBCopyToRam; g_Config.bSkipEFBCopyToRam = !g_Config.bSkipEFBCopyToRam;
} }
if (IsHotkey(event, HK_TOGGLE_FOG)) if (IsHotkey(HK_TOGGLE_FOG))
{ {
OSDChoice = 4; OSDChoice = 4;
g_Config.bDisableFog = !g_Config.bDisableFog; g_Config.bDisableFog = !g_Config.bDisableFog;
} }
if (IsHotkey(event, HK_TOGGLE_THROTTLE, false)) Core::SetIsFramelimiterTempDisabled(IsHotkey(HK_TOGGLE_THROTTLE, true));
{ if (IsHotkey(HK_DECREASE_FRAME_LIMIT))
Core::SetIsFramelimiterTempDisabled(false);
}
else if (IsHotkey(event, HK_TOGGLE_THROTTLE, true))
{
Core::SetIsFramelimiterTempDisabled(true);
}
if (IsHotkey(event, HK_DECREASE_FRAME_LIMIT))
{ {
if (--SConfig::GetInstance().m_Framelimit > 0x19) if (--SConfig::GetInstance().m_Framelimit > 0x19)
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) if (++SConfig::GetInstance().m_Framelimit > 0x19)
SConfig::GetInstance().m_Framelimit = 0; SConfig::GetInstance().m_Framelimit = 0;
} }
if (IsHotkey(event, HK_SAVE_STATE_SLOT_SELECTED)) if (IsHotkey(HK_SAVE_STATE_SLOT_SELECTED))
{ {
State::Save(g_saveSlot); State::Save(g_saveSlot);
} }
if (IsHotkey(event, HK_LOAD_STATE_SLOT_SELECTED)) if (IsHotkey(HK_LOAD_STATE_SLOT_SELECTED))
{ {
State::Load(g_saveSlot); State::Load(g_saveSlot);
} }
if (IsHotkey(event, HK_DECREASE_DEPTH, true)) if (IsHotkey(HK_DECREASE_DEPTH, true))
{ {
if (--g_Config.iStereoDepth < 0) if (--g_Config.iStereoDepth < 0)
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) if (++g_Config.iStereoDepth > 100)
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; g_Config.iStereoConvergence -= 5;
if (g_Config.iStereoConvergence < 0) if (g_Config.iStereoConvergence < 0)
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; g_Config.iStereoConvergence += 5;
if (g_Config.iStereoConvergence > 500) if (g_Config.iStereoConvergence > 500)
g_Config.iStereoConvergence = 500; g_Config.iStereoConvergence = 500;
} }
for (i = HK_SELECT_STATE_SLOT_1; i < HK_SELECT_STATE_SLOT_10; ++i) static float debugSpeed = 1.0f;
if (IsHotkey(HK_FREELOOK_DECREASE_SPEED, true))
debugSpeed /= 1.1f;
if (IsHotkey(HK_FREELOOK_INCREASE_SPEED, true))
debugSpeed *= 1.1f;
if (IsHotkey(HK_FREELOOK_RESET_SPEED, true))
debugSpeed = 1.0f;
if (IsHotkey(HK_FREELOOK_UP, true))
VertexShaderManager::TranslateView(0.0f, 0.0f, -debugSpeed);
if (IsHotkey(HK_FREELOOK_DOWN, true))
VertexShaderManager::TranslateView(0.0f, 0.0f, debugSpeed);
if (IsHotkey(HK_FREELOOK_LEFT, true))
VertexShaderManager::TranslateView(debugSpeed, 0.0f);
if (IsHotkey(HK_FREELOOK_RIGHT, true))
VertexShaderManager::TranslateView(-debugSpeed, 0.0f);
if (IsHotkey(HK_FREELOOK_ZOOM_IN, true))
VertexShaderManager::TranslateView(0.0f, debugSpeed);
if (IsHotkey(HK_FREELOOK_ZOOM_OUT, true))
VertexShaderManager::TranslateView(0.0f, -debugSpeed);
if (IsHotkey(HK_FREELOOK_RESET, true))
VertexShaderManager::ResetView();
// Savestates
for (int i = 0; i < 10; i++)
{ {
if (IsHotkey(event, 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; wxCommandEvent slot_event;
slot_event.SetId(i + IDM_SELECT_SLOT_1 - HK_SELECT_STATE_SLOT_1); slot_event.SetId(i + IDM_SELECT_SLOT_1 - HK_SELECT_STATE_SLOT_1);
CFrame::OnSelectSlot(slot_event); CFrame::OnSelectSlot(slot_event);
} }
} }
if (IsHotkey(HK_SAVE_FIRST_STATE))
static float debugSpeed = 1.0f; State::SaveFirstSaved();
if (IsHotkey(event, HK_FREELOOK_DECREASE_SPEED, true)) if (IsHotkey(HK_UNDO_LOAD_STATE))
debugSpeed /= 1.1f; State::UndoLoadState();
if (IsHotkey(event, HK_FREELOOK_INCREASE_SPEED, true)) if (IsHotkey(HK_UNDO_SAVE_STATE))
debugSpeed *= 1.1f; State::UndoSaveState();
if (IsHotkey(event, HK_FREELOOK_RESET_SPEED, true))
debugSpeed = 1.0f;
if (IsHotkey(event, HK_FREELOOK_UP, true))
VertexShaderManager::TranslateView(0.0f, 0.0f, -debugSpeed);
if (IsHotkey(event, HK_FREELOOK_DOWN, true))
VertexShaderManager::TranslateView(0.0f, 0.0f, debugSpeed);
if (IsHotkey(event, HK_FREELOOK_LEFT, true))
VertexShaderManager::TranslateView(debugSpeed, 0.0f);
if (IsHotkey(event, HK_FREELOOK_RIGHT, true))
VertexShaderManager::TranslateView(-debugSpeed, 0.0f);
if (IsHotkey(event, HK_FREELOOK_ZOOM_IN, true))
VertexShaderManager::TranslateView(0.0f, debugSpeed);
if (IsHotkey(event, HK_FREELOOK_ZOOM_OUT, true))
VertexShaderManager::TranslateView(0.0f, -debugSpeed);
if (IsHotkey(event, HK_FREELOOK_RESET, true))
VertexShaderManager::ResetView();
} }

View File

@ -306,7 +306,6 @@ private:
void OnConfigAudio(wxCommandEvent& event); void OnConfigAudio(wxCommandEvent& event);
void OnConfigControllers(wxCommandEvent& event); void OnConfigControllers(wxCommandEvent& event);
void OnConfigHotkey(wxCommandEvent& event); void OnConfigHotkey(wxCommandEvent& event);
void OnConfigMenuCommands(wxCommandEvent& event);
void OnToggleFullscreen(wxCommandEvent& event); void OnToggleFullscreen(wxCommandEvent& event);
void OnToggleDualCore(wxCommandEvent& event); void OnToggleDualCore(wxCommandEvent& event);
@ -352,7 +351,7 @@ private:
void OnLoadCurrentSlot(wxCommandEvent& event); void OnLoadCurrentSlot(wxCommandEvent& event);
void PollHotkeys(wxTimerEvent&); void PollHotkeys(wxTimerEvent&);
void ParseHotkeys(wxKeyEvent &event); void ParseHotkeys();
bool InitControllers(); bool InitControllers();

View File

@ -60,7 +60,6 @@
#include "DolphinWX/Frame.h" #include "DolphinWX/Frame.h"
#include "DolphinWX/GameListCtrl.h" #include "DolphinWX/GameListCtrl.h"
#include "DolphinWX/Globals.h" #include "DolphinWX/Globals.h"
#include "DolphinWX/HotkeyDlg.h"
#include "DolphinWX/InputConfigDiag.h" #include "DolphinWX/InputConfigDiag.h"
#include "DolphinWX/ISOFile.h" #include "DolphinWX/ISOFile.h"
#include "DolphinWX/LogWindow.h" #include "DolphinWX/LogWindow.h"
@ -230,7 +229,6 @@ wxMenuBar* CFrame::CreateMenu()
pOptionsMenu->Append(IDM_CONFIG_GFX_BACKEND, _("&Graphics Settings")); pOptionsMenu->Append(IDM_CONFIG_GFX_BACKEND, _("&Graphics Settings"));
pOptionsMenu->Append(IDM_CONFIG_AUDIO, _("&Audio Settings")); pOptionsMenu->Append(IDM_CONFIG_AUDIO, _("&Audio Settings"));
pOptionsMenu->Append(IDM_CONFIG_CONTROLLERS, _("&Controller 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_HOTKEYS, _("&Hotkey Settings"));
if (g_pCodeWindow) if (g_pCodeWindow)
{ {
@ -390,11 +388,7 @@ wxMenuBar* CFrame::CreateMenu()
wxString CFrame::GetMenuLabel(int Id) wxString CFrame::GetMenuLabel(int Id)
{ {
int hotkey = SConfig::GetInstance().\ wxString Label;
m_LocalCoreStartupParameter.iHotkey[Id];
int hotkeymodifier = SConfig::GetInstance().\
m_LocalCoreStartupParameter.iHotkeyModifier[Id];
wxString Hotkey, Label, Modifier;
switch (Id) switch (Id)
{ {
@ -533,14 +527,7 @@ wxString CFrame::GetMenuLabel(int Id)
Label = wxString::Format(_("Undefined %i"), Id); Label = wxString::Format(_("Undefined %i"), Id);
} }
hotkeymodifier &= wxMOD_CONTROL | wxMOD_ALT | wxMOD_SHIFT; return Label;
Modifier = WxUtils::WXKeymodToString(hotkeymodifier);
Hotkey = WxUtils::WXKeyToString(hotkey);
if (Modifier.Len() + Hotkey.Len() > 0)
Label += '\t';
return Label + Modifier + Hotkey;
} }
@ -1059,8 +1046,6 @@ void CFrame::StartGame(const std::string& filename)
m_RenderParent->SetFocus(); 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_DOWN, &CFrame::OnMouse, this);
wxTheApp->Bind(wxEVT_RIGHT_UP, &CFrame::OnMouse, this); wxTheApp->Bind(wxEVT_RIGHT_UP, &CFrame::OnMouse, this);
wxTheApp->Bind(wxEVT_MIDDLE_DOWN, &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 // Destroy the renderer frame when not rendering to main
m_RenderParent->Unbind(wxEVT_SIZE, &CFrame::OnRenderParentResize, this); 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 // Mouse
wxTheApp->Unbind(wxEVT_RIGHT_DOWN, &CFrame::OnMouse, this); wxTheApp->Unbind(wxEVT_RIGHT_DOWN, &CFrame::OnMouse, this);
wxTheApp->Unbind(wxEVT_RIGHT_UP, &CFrame::OnMouse, this); wxTheApp->Unbind(wxEVT_RIGHT_UP, &CFrame::OnMouse, this);
@ -1340,16 +1321,6 @@ void CFrame::OnConfigControllers(wxCommandEvent& WXUNUSED (event))
config_dlg.ShowModal(); 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)) void CFrame::OnConfigHotkey(wxCommandEvent& WXUNUSED (event))
{ {
InputConfig* const hotkey_plugin = HotkeyManagerEmu::GetConfig(); InputConfig* const hotkey_plugin = HotkeyManagerEmu::GetConfig();

View File

@ -158,7 +158,6 @@ enum
IDM_CONFIG_AUDIO, IDM_CONFIG_AUDIO,
IDM_CONFIG_CONTROLLERS, IDM_CONFIG_CONTROLLERS,
IDM_CONFIG_HOTKEYS, IDM_CONFIG_HOTKEYS,
IDM_CONFIG_MENU_COMMANDS,
IDM_CONFIG_LOGGER, IDM_CONFIG_LOGGER,
// Views // Views

View File

@ -1,360 +0,0 @@
// Copyright 2010 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include <cstddef>
#include <wx/button.h>
#include <wx/dialog.h>
#include <wx/font.h>
#include <wx/gbsizer.h>
#include <wx/notebook.h>
#include <wx/panel.h>
#include <wx/sizer.h>
#include <wx/stattext.h>
#include <wx/timer.h>
#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(_("<Press Key>"));
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();
}

View File

@ -1,50 +0,0 @@
// Copyright 2010 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include <wx/dialog.h>
#include <wx/timer.h>
#include "Core/CoreParameter.h"
#if defined(HAVE_X11) && HAVE_X11
#include <X11/Xlib.h>
#include <X11/keysym.h>
#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;
};