Merge pull request #2505 from degasus/hotkeys

Hotkeys fixes 2
This commit is contained in:
Markus Wick 2015-06-04 10:42:50 +02:00
commit 1ed38e901e
3 changed files with 142 additions and 40 deletions

View File

@ -508,9 +508,9 @@ void SConfig::LoadHotkeySettings(IniFile& ini)
for (int i = 0; i < NUM_HOTKEYS; i++)
{
hotkeys->Get(g_HKData[i].IniText,
&m_LocalCoreStartupParameter.iHotkey[i], g_HKData[i].DefaultKey);
&m_LocalCoreStartupParameter.iHotkey[i], 0);
hotkeys->Get(std::string(g_HKData[i].IniText) + "Modifier",
&m_LocalCoreStartupParameter.iHotkeyModifier[i], g_HKData[i].DefaultModifier);
&m_LocalCoreStartupParameter.iHotkeyModifier[i], 0);
}
}

View File

@ -259,11 +259,62 @@ void HotkeyManager::GetInput(HotkeyStatus* const kb)
void HotkeyManager::LoadDefaults(const ControllerInterface& ciface)
{
for (int set = 0; set < 3; set++)
ControllerEmu::LoadDefaults(ciface);
#ifdef _WIN32
const std::string NON = "(!(LMENU | RMENU) & !(LSHIFT | RSHIFT) & !(LCONTROL | RCONTROL))";
const std::string ALT = "((LMENU | RMENU) & !(LSHIFT | RSHIFT) & !(LCONTROL | RCONTROL))";
const std::string SHIFT = "(!(LMENU | RMENU) & (LSHIFT | RSHIFT) & !(LCONTROL | RCONTROL))";
const std::string CTRL = "(!(LMENU | RMENU) & !(LSHIFT | RSHIFT) & (LCONTROL | RCONTROL))";
#else
const std::string NON = "(!`Alt_L` & !(`Shift_L` | `Shift_R`) & !(`Control_L` | `Control_R` ))";
const std::string ALT = "(`Alt_L` & !(`Shift_L` | `Shift_R`) & !(`Control_L` | `Control_R` ))";
const std::string SHIFT = "(!`Alt_L` & (`Shift_L` | `Shift_R`) & !(`Control_L` | `Control_R` ))";
const std::string CTRL = "(!`Alt_L` & !(`Shift_L` | `Shift_R`) & (`Control_L` | `Control_R` ))";
#endif
#define set_control(num, str) (m_keys[(num) / 32])->controls[(num) % 32]->control_ref->expression = (str)
// General hotkeys
set_control(HK_OPEN, CTRL + " & O");
set_control(HK_PLAY_PAUSE, "`F10`");
#ifdef _WIN32
set_control(HK_STOP, "ESCAPE");
set_control(HK_FULLSCREEN, ALT + " & RETURN");
#else
set_control(HK_STOP, "Escape");
set_control(HK_FULLSCREEN, ALT + " & Return");
#endif
set_control(HK_SCREENSHOT, NON + " & `F9`");
set_control(HK_WIIMOTE1_CONNECT, ALT + " & `F5`");
set_control(HK_WIIMOTE2_CONNECT, ALT + " & `F6`");
set_control(HK_WIIMOTE3_CONNECT, ALT + " & `F7`");
set_control(HK_WIIMOTE4_CONNECT, ALT + " & `F8`");
set_control(HK_BALANCEBOARD_CONNECT, ALT + " & `F9`");
#ifdef _WIN32
set_control(HK_TOGGLE_THROTTLE, "TAB");
#else
set_control(HK_TOGGLE_THROTTLE, "Tab");
#endif
// Freelook
set_control(HK_FREELOOK_DECREASE_SPEED, SHIFT + " & `1`");
set_control(HK_FREELOOK_INCREASE_SPEED, SHIFT + " & `2`");
set_control(HK_FREELOOK_RESET_SPEED, SHIFT + " & F");
set_control(HK_FREELOOK_UP, SHIFT + " & E");
set_control(HK_FREELOOK_DOWN, SHIFT + " & Q");
set_control(HK_FREELOOK_LEFT, SHIFT + " & A");
set_control(HK_FREELOOK_RIGHT, SHIFT + " & D");
set_control(HK_FREELOOK_ZOOM_IN, SHIFT + " & W");
set_control(HK_FREELOOK_ZOOM_OUT, SHIFT + " & S");
set_control(HK_FREELOOK_RESET, SHIFT + " & R");
// Savestates
for (int i = 0; i < 8; i++)
{
for (unsigned int key = 0; key < (m_keys[set])->controls.size(); key++)
{
(m_keys[set])->controls[key]->control_ref->expression = "";
}
set_control(HK_LOAD_STATE_SLOT_1 + i, StringFromFormat((NON + " & `F%d`").c_str(), i + 1));
set_control(HK_SAVE_STATE_SLOT_1 + i, StringFromFormat((SHIFT + " & `F%d`").c_str(), i + 1));
}
set_control(HK_UNDO_LOAD_STATE, NON + " & `F12`");
set_control(HK_UNDO_SAVE_STATE, SHIFT + " & `F12`");
}

View File

@ -1307,37 +1307,78 @@ void CFrame::PollHotkeys(wxTimerEvent& event)
void CFrame::ParseHotkeys(wxKeyEvent &event)
{
if (IsHotkey(event, HK_TOGGLE_THROTTLE, false))
{
Core::SetIsFramelimiterTempDisabled(false);
}
else if (IsHotkey(event, HK_TOGGLE_THROTTLE, true))
{
Core::SetIsFramelimiterTempDisabled(true);
}
unsigned int i = 0;
for (i = 0; i < NUM_HOTKEYS; i++)
{
bool held = false;
if (i == HK_FRAME_ADVANCE)
held = true;
if (IsHotkey(event, i, held))
switch (i)
{
int cmd = GetCmdForHotkey(i);
if (cmd >= 0)
{
wxCommandEvent evt(wxEVT_MENU, cmd);
wxMenuItem* item = GetMenuBar()->FindItem(cmd);
if (item && item->IsCheckable())
case HK_OPEN:
case HK_CHANGE_DISC:
case HK_REFRESH_LIST:
case HK_RESET:
case HK_FRAME_ADVANCE:
case HK_START_RECORDING:
case HK_PLAY_RECORDING:
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(event, i))
{
item->wxMenuItemBase::Toggle();
evt.SetInt(item->IsChecked());
int cmd = GetCmdForHotkey(i);
if (cmd >= 0)
{
wxCommandEvent evt(wxEVT_MENU, cmd);
wxMenuItem* item = GetMenuBar()->FindItem(cmd);
if (item && item->IsCheckable())
{
item->wxMenuItemBase::Toggle();
evt.SetInt(item->IsChecked());
}
GetEventHandler()->AddPendingEvent(evt);
}
}
GetEventHandler()->AddPendingEvent(evt);
default:
break;
}
// do nothing
}
}
// On OS X, we claim all keyboard events while
@ -1358,7 +1399,6 @@ void CFrame::ParseHotkeys(wxKeyEvent &event)
return;
}
int WiimoteId = -1;
// Toggle fullscreen
if (IsHotkey(event, HK_FULLSCREEN))
DoFullscreen(!RendererIsFullscreen());
@ -1379,7 +1419,9 @@ void CFrame::ParseHotkeys(wxKeyEvent &event)
AudioCommon::IncreaseVolume(3);
if (IsHotkey(event, HK_VOLUME_TOGGLE_MUTE))
AudioCommon::ToggleMuteVolume();
// Wiimote connect and disconnect hotkeys
int WiimoteId = -1;
if (IsHotkey(event, HK_WIIMOTE1_CONNECT))
WiimoteId = 0;
if (IsHotkey(event, HK_WIIMOTE2_CONNECT))
@ -1390,6 +1432,15 @@ void CFrame::ParseHotkeys(wxKeyEvent &event)
WiimoteId = 3;
if (IsHotkey(event, HK_BALANCEBOARD_CONNECT))
WiimoteId = 4;
// Actually perform the Wiimote connection or disconnection
if (WiimoteId >= 0 && SConfig::GetInstance().m_LocalCoreStartupParameter.bWii)
{
wxCommandEvent evt;
evt.SetId(IDM_CONNECT_WIIMOTE1 + WiimoteId);
OnConnectWiimote(evt);
}
if (IsHotkey(event, HK_TOGGLE_IR))
{
OSDChoice = 1;
@ -1425,6 +1476,14 @@ void CFrame::ParseHotkeys(wxKeyEvent &event)
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))
{
if (--SConfig::GetInstance().m_Framelimit > 0x19)
@ -1476,14 +1535,6 @@ void CFrame::ParseHotkeys(wxKeyEvent &event)
}
}
// Actually perform the Wiimote connection or disconnection
if (WiimoteId >= 0 && SConfig::GetInstance().m_LocalCoreStartupParameter.bWii)
{
wxCommandEvent evt;
evt.SetId(IDM_CONNECT_WIIMOTE1 + WiimoteId);
OnConnectWiimote(evt);
}
static float debugSpeed = 1.0f;
if (IsHotkey(event, HK_FREELOOK_DECREASE_SPEED, true))
debugSpeed /= 1.1f;