Merge pull request #2489 from degasus/hotkeys

Hotkeys fixes
This commit is contained in:
Markus Wick 2015-05-31 23:28:26 +02:00
commit da97d77e08
4 changed files with 126 additions and 130 deletions

View File

@ -138,10 +138,10 @@ void GCPad::LoadDefaults(const ControllerInterface& ciface)
set_control(m_buttons, 3, "S"); // Y set_control(m_buttons, 3, "S"); // Y
set_control(m_buttons, 4, "D"); // Z set_control(m_buttons, 4, "D"); // Z
#ifdef _WIN32 #ifdef _WIN32
set_control(m_buttons, 5, "RETURN"); // Start set_control(m_buttons, 5, "!LMENU & RETURN"); // Start
#else #else
// OS X/Linux // OS X/Linux
set_control(m_buttons, 5, "Return"); // Start set_control(m_buttons, 5, "!`Alt_L` & Return"); // Start
#endif #endif
// stick modifiers to 50 % // stick modifiers to 50 %

View File

@ -895,9 +895,9 @@ void Wiimote::LoadDefaults(const ControllerInterface& ciface)
set_control(m_buttons, 5, "E"); // + set_control(m_buttons, 5, "E"); // +
#ifdef _WIN32 #ifdef _WIN32
set_control(m_buttons, 6, "RETURN"); // Home set_control(m_buttons, 6, "!LMENU & RETURN"); // Home
#else #else
set_control(m_buttons, 6, "Return"); // Home set_control(m_buttons, 6, "!`Alt_L` & Return"); // Home
#endif #endif
// Shake // Shake

View File

@ -10,9 +10,9 @@
const std::string hotkey_labels[] = const std::string hotkey_labels[] =
{ {
(""), // Open _trans("Open"),
(""), // Change Disc _trans("Change Disc"),
(""), // Refresh List _trans("Refresh List"),
_trans("Toggle Pause"), _trans("Toggle Pause"),
_trans("Stop"), _trans("Stop"),
@ -26,7 +26,7 @@ const std::string hotkey_labels[] =
_trans("Toggle Fullscreen"), _trans("Toggle Fullscreen"),
_trans("Take Screenshot"), _trans("Take Screenshot"),
(""), // Exit _trans("Exit"),
_trans("Connect Wiimote 1"), _trans("Connect Wiimote 1"),
_trans("Connect Wiimote 2"), _trans("Connect Wiimote 2"),

View File

@ -932,9 +932,6 @@ void CFrame::OnGameListCtrlItemActivated(wxListEvent& WXUNUSED(event))
static bool IsHotkey(wxKeyEvent &event, int id, bool held = false) static bool IsHotkey(wxKeyEvent &event, int id, bool held = false)
{ {
if (Core::GetState() == Core::CORE_UNINITIALIZED)
return false;
// Input event hotkey // Input event hotkey
if (event.GetKeyCode() == WXK_NONE) if (event.GetKeyCode() == WXK_NONE)
{ {
@ -1084,9 +1081,16 @@ void CFrame::OnKeyDown(wxKeyEvent& event)
{ {
if (Core::GetState() != Core::CORE_UNINITIALIZED && if (Core::GetState() != Core::CORE_UNINITIALIZED &&
(RendererHasFocus() || TASInputHasFocus())) (RendererHasFocus() || TASInputHasFocus()))
{
if (IsHotkey(event, HK_TOGGLE_THROTTLE))
{
Core::SetIsFramelimiterTempDisabled(true);
}
else
{ {
ParseHotkeys(event); ParseHotkeys(event);
} }
}
else else
{ {
event.Skip(); event.Skip();
@ -1297,149 +1301,22 @@ void CFrame::PollHotkeys(wxTimerEvent& event)
{ {
HotkeyManagerEmu::GetStatus(); HotkeyManagerEmu::GetStatus();
wxKeyEvent keyevent = 0; wxKeyEvent keyevent = 0;
if (IsHotkey(keyevent, HK_TOGGLE_THROTTLE))
{
Core::SetIsFramelimiterTempDisabled(false);
}
else
{
ParseHotkeys(keyevent); ParseHotkeys(keyevent);
} }
} }
}
void CFrame::ParseHotkeys(wxKeyEvent &event) void CFrame::ParseHotkeys(wxKeyEvent &event)
{ {
int WiimoteId = -1; if (IsHotkey(event, HK_TOGGLE_THROTTLE, false))
// Toggle fullscreen
if (IsHotkey(event, HK_FULLSCREEN))
DoFullscreen(!RendererIsFullscreen());
// Send Debugger keys to CodeWindow
else if (g_pCodeWindow && (event.GetKeyCode() >= WXK_F9 && event.GetKeyCode() <= WXK_F11))
event.Skip();
// Pause and Unpause
else if (IsHotkey(event, HK_PLAY_PAUSE))
DoPause();
// Stop
else if (IsHotkey(event, HK_STOP))
DoStop();
// Screenshot hotkey
else if (IsHotkey(event, HK_SCREENSHOT))
Core::SaveScreenShot();
else if (IsHotkey(event, HK_EXIT))
wxPostEvent(this, wxCommandEvent(wxID_EXIT));
else if (IsHotkey(event, HK_VOLUME_DOWN))
AudioCommon::DecreaseVolume(3);
else if (IsHotkey(event, HK_VOLUME_UP))
AudioCommon::IncreaseVolume(3);
else if (IsHotkey(event, HK_VOLUME_TOGGLE_MUTE))
AudioCommon::ToggleMuteVolume();
// Wiimote connect and disconnect hotkeys
else if (IsHotkey(event, HK_WIIMOTE1_CONNECT))
WiimoteId = 0;
else if (IsHotkey(event, HK_WIIMOTE2_CONNECT))
WiimoteId = 1;
else if (IsHotkey(event, HK_WIIMOTE3_CONNECT))
WiimoteId = 2;
else if (IsHotkey(event, HK_WIIMOTE4_CONNECT))
WiimoteId = 3;
else if (IsHotkey(event, HK_BALANCEBOARD_CONNECT))
WiimoteId = 4;
else if (IsHotkey(event, HK_TOGGLE_IR))
{ {
OSDChoice = 1; Core::SetIsFramelimiterTempDisabled(false);
// Toggle native resolution
if (++g_Config.iEFBScale > SCALE_4X)
g_Config.iEFBScale = SCALE_AUTO;
}
else if (IsHotkey(event, HK_INCREASE_IR))
{
OSDChoice = 1;
if (++g_Config.iEFBScale > SCALE_4X)
g_Config.iEFBScale = SCALE_4X;
}
else if (IsHotkey(event, HK_DECREASE_IR))
{
OSDChoice = 1;
if (--g_Config.iEFBScale < SCALE_1X)
g_Config.iEFBScale = SCALE_1X;
}
else if (IsHotkey(event, HK_TOGGLE_AR))
{
OSDChoice = 2;
// Toggle aspect ratio
g_Config.iAspectRatio = (g_Config.iAspectRatio + 1) & 3;
}
else if (IsHotkey(event, HK_TOGGLE_EFBCOPIES))
{
OSDChoice = 3;
// Toggle EFB copies between EFB2RAM and EFB2Texture
g_Config.bSkipEFBCopyToRam = !g_Config.bSkipEFBCopyToRam;
}
else if (IsHotkey(event, HK_TOGGLE_FOG))
{
OSDChoice = 4;
g_Config.bDisableFog = !g_Config.bDisableFog;
} }
else if (IsHotkey(event, HK_TOGGLE_THROTTLE, true)) else if (IsHotkey(event, HK_TOGGLE_THROTTLE, true))
{ {
Core::SetIsFramelimiterTempDisabled(true); Core::SetIsFramelimiterTempDisabled(true);
} }
else if (IsHotkey(event, HK_DECREASE_FRAME_LIMIT))
{
if (--SConfig::GetInstance().m_Framelimit > 0x19)
SConfig::GetInstance().m_Framelimit = 0x19;
}
else if (IsHotkey(event, HK_INCREASE_FRAME_LIMIT))
{
if (++SConfig::GetInstance().m_Framelimit > 0x19)
SConfig::GetInstance().m_Framelimit = 0;
}
else if (IsHotkey(event, HK_SAVE_STATE_SLOT_SELECTED))
{
State::Save(g_saveSlot);
}
else if (IsHotkey(event, HK_LOAD_STATE_SLOT_SELECTED))
{
State::Load(g_saveSlot);
}
else if (IsHotkey(event, HK_DECREASE_DEPTH, true))
{
if (--g_Config.iStereoDepth < 0)
g_Config.iStereoDepth = 0;
}
else if (IsHotkey(event, HK_INCREASE_DEPTH, true))
{
if (++g_Config.iStereoDepth > 100)
g_Config.iStereoDepth = 100;
}
else if (IsHotkey(event, HK_DECREASE_CONVERGENCE, true))
{
g_Config.iStereoConvergence -= 5;
if (g_Config.iStereoConvergence < 0)
g_Config.iStereoConvergence = 0;
}
else if (IsHotkey(event, HK_INCREASE_CONVERGENCE, true))
{
g_Config.iStereoConvergence += 5;
if (g_Config.iStereoConvergence > 500)
g_Config.iStereoConvergence = 500;
}
else unsigned int i = 0;
{
for (int i = HK_SELECT_STATE_SLOT_1; i < HK_SELECT_STATE_SLOT_10; ++i)
{
if (IsHotkey(event, i))
{
wxCommandEvent slot_event;
slot_event.SetId(i + IDM_SELECT_SLOT_1 - HK_SELECT_STATE_SLOT_1);
CFrame::OnSelectSlot(slot_event);
}
}
unsigned int i = NUM_HOTKEYS;
for (i = 0; i < NUM_HOTKEYS; i++) for (i = 0; i < NUM_HOTKEYS; i++)
{ {
bool held = false; bool held = false;
@ -1474,11 +1351,132 @@ void CFrame::ParseHotkeys(wxKeyEvent &event)
if (i == NUM_HOTKEYS) if (i == NUM_HOTKEYS)
event.Skip(); event.Skip();
#endif #endif
if (Core::GetState() == Core::CORE_UNINITIALIZED)
{
event.Skip();
return;
}
int WiimoteId = -1;
// Toggle fullscreen
if (IsHotkey(event, HK_FULLSCREEN))
DoFullscreen(!RendererIsFullscreen());
// Pause and Unpause
if (IsHotkey(event, HK_PLAY_PAUSE))
DoPause();
// Stop
if (IsHotkey(event, HK_STOP))
DoStop();
// Screenshot hotkey
if (IsHotkey(event, HK_SCREENSHOT))
Core::SaveScreenShot();
if (IsHotkey(event, HK_EXIT))
wxPostEvent(this, wxCommandEvent(wxID_EXIT));
if (IsHotkey(event, HK_VOLUME_DOWN))
AudioCommon::DecreaseVolume(3);
if (IsHotkey(event, HK_VOLUME_UP))
AudioCommon::IncreaseVolume(3);
if (IsHotkey(event, HK_VOLUME_TOGGLE_MUTE))
AudioCommon::ToggleMuteVolume();
// Wiimote connect and disconnect hotkeys
if (IsHotkey(event, HK_WIIMOTE1_CONNECT))
WiimoteId = 0;
if (IsHotkey(event, HK_WIIMOTE2_CONNECT))
WiimoteId = 1;
if (IsHotkey(event, HK_WIIMOTE3_CONNECT))
WiimoteId = 2;
if (IsHotkey(event, HK_WIIMOTE4_CONNECT))
WiimoteId = 3;
if (IsHotkey(event, HK_BALANCEBOARD_CONNECT))
WiimoteId = 4;
if (IsHotkey(event, 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))
{
OSDChoice = 1;
++g_Config.iEFBScale;
}
if (IsHotkey(event, HK_DECREASE_IR))
{
OSDChoice = 1;
if (--g_Config.iEFBScale < SCALE_1X)
g_Config.iEFBScale = SCALE_1X;
}
if (IsHotkey(event, HK_TOGGLE_AR))
{
OSDChoice = 2;
// Toggle aspect ratio
g_Config.iAspectRatio = (g_Config.iAspectRatio + 1) & 3;
}
if (IsHotkey(event, HK_TOGGLE_EFBCOPIES))
{
OSDChoice = 3;
// Toggle EFB copies between EFB2RAM and EFB2Texture
g_Config.bSkipEFBCopyToRam = !g_Config.bSkipEFBCopyToRam;
}
if (IsHotkey(event, HK_TOGGLE_FOG))
{
OSDChoice = 4;
g_Config.bDisableFog = !g_Config.bDisableFog;
}
if (IsHotkey(event, HK_DECREASE_FRAME_LIMIT))
{
if (--SConfig::GetInstance().m_Framelimit > 0x19)
SConfig::GetInstance().m_Framelimit = 0x19;
}
if (IsHotkey(event, HK_INCREASE_FRAME_LIMIT))
{
if (++SConfig::GetInstance().m_Framelimit > 0x19)
SConfig::GetInstance().m_Framelimit = 0;
}
if (IsHotkey(event, HK_SAVE_STATE_SLOT_SELECTED))
{
State::Save(g_saveSlot);
}
if (IsHotkey(event, HK_LOAD_STATE_SLOT_SELECTED))
{
State::Load(g_saveSlot);
}
if (IsHotkey(event, HK_DECREASE_DEPTH, true))
{
if (--g_Config.iStereoDepth < 0)
g_Config.iStereoDepth = 0;
}
if (IsHotkey(event, HK_INCREASE_DEPTH, true))
{
if (++g_Config.iStereoDepth > 100)
g_Config.iStereoDepth = 100;
}
if (IsHotkey(event, HK_DECREASE_CONVERGENCE, true))
{
g_Config.iStereoConvergence -= 5;
if (g_Config.iStereoConvergence < 0)
g_Config.iStereoConvergence = 0;
}
if (IsHotkey(event, HK_INCREASE_CONVERGENCE, true))
{
g_Config.iStereoConvergence += 5;
if (g_Config.iStereoConvergence > 500)
g_Config.iStereoConvergence = 500;
}
for (int i = HK_SELECT_STATE_SLOT_1; i < HK_SELECT_STATE_SLOT_10; ++i)
{
if (IsHotkey(event, i))
{
wxCommandEvent slot_event;
slot_event.SetId(i + IDM_SELECT_SLOT_1 - HK_SELECT_STATE_SLOT_1);
CFrame::OnSelectSlot(slot_event);
}
} }
// Actually perform the Wiimote connection or disconnection // Actually perform the Wiimote connection or disconnection
if (Core::GetState() != Core::CORE_UNINITIALIZED)
{
if (WiimoteId >= 0 && SConfig::GetInstance().m_LocalCoreStartupParameter.bWii) if (WiimoteId >= 0 && SConfig::GetInstance().m_LocalCoreStartupParameter.bWii)
{ {
wxCommandEvent evt; wxCommandEvent evt;
@ -1487,26 +1485,24 @@ void CFrame::ParseHotkeys(wxKeyEvent &event)
} }
static float debugSpeed = 1.0f; static float debugSpeed = 1.0f;
if (IsHotkey(event, HK_FREELOOK_DECREASE_SPEED, true)) if (IsHotkey(event, HK_FREELOOK_DECREASE_SPEED, true))
debugSpeed /= 1.1f; debugSpeed /= 1.1f;
else if (IsHotkey(event, HK_FREELOOK_INCREASE_SPEED, true)) if (IsHotkey(event, HK_FREELOOK_INCREASE_SPEED, true))
debugSpeed *= 1.1f; debugSpeed *= 1.1f;
else if (IsHotkey(event, HK_FREELOOK_RESET_SPEED, true)) if (IsHotkey(event, HK_FREELOOK_RESET_SPEED, true))
debugSpeed = 1.0f; debugSpeed = 1.0f;
else if (IsHotkey(event, HK_FREELOOK_UP, true)) if (IsHotkey(event, HK_FREELOOK_UP, true))
VertexShaderManager::TranslateView(0.0f, 0.0f, -debugSpeed); VertexShaderManager::TranslateView(0.0f, 0.0f, -debugSpeed);
else if (IsHotkey(event, HK_FREELOOK_DOWN, true)) if (IsHotkey(event, HK_FREELOOK_DOWN, true))
VertexShaderManager::TranslateView(0.0f, 0.0f, debugSpeed); VertexShaderManager::TranslateView(0.0f, 0.0f, debugSpeed);
else if (IsHotkey(event, HK_FREELOOK_LEFT, true)) if (IsHotkey(event, HK_FREELOOK_LEFT, true))
VertexShaderManager::TranslateView(debugSpeed, 0.0f); VertexShaderManager::TranslateView(debugSpeed, 0.0f);
else if (IsHotkey(event, HK_FREELOOK_RIGHT, true)) if (IsHotkey(event, HK_FREELOOK_RIGHT, true))
VertexShaderManager::TranslateView(-debugSpeed, 0.0f); VertexShaderManager::TranslateView(-debugSpeed, 0.0f);
else if (IsHotkey(event, HK_FREELOOK_ZOOM_IN, true)) if (IsHotkey(event, HK_FREELOOK_ZOOM_IN, true))
VertexShaderManager::TranslateView(0.0f, debugSpeed); VertexShaderManager::TranslateView(0.0f, debugSpeed);
else if (IsHotkey(event, HK_FREELOOK_ZOOM_OUT, true)) if (IsHotkey(event, HK_FREELOOK_ZOOM_OUT, true))
VertexShaderManager::TranslateView(0.0f, -debugSpeed); VertexShaderManager::TranslateView(0.0f, -debugSpeed);
else if (IsHotkey(event, HK_FREELOOK_RESET, true)) if (IsHotkey(event, HK_FREELOOK_RESET, true))
VertexShaderManager::ResetView(); VertexShaderManager::ResetView();
} }
}