Make freelook hotkeys configurable.

This commit is contained in:
Rachel Bryk 2014-11-16 21:58:37 -05:00
parent 5143adac0e
commit ea11c446c2
6 changed files with 78 additions and 35 deletions

View File

@ -69,6 +69,18 @@ static const struct
{ "ToggleThrottle", 9 /* '\t' */, 0 /* wxMOD_NONE */ },
{ "IncreaseFrameLimit", 0, 0 /* wxMOD_NONE */ },
{ "DecreaseFrameLimit", 0, 0 /* wxMOD_NONE */ },
{ "FreelookIncreaseSpeed",49 /* '1' */, 4 /* wxMOD_SHIFT */ },
{ "FreelookDecreaseSpeed",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 */ },
{ "LoadStateSlot1", 340 /* WXK_F1 */, 0 /* wxMOD_NONE */ },
{ "LoadStateSlot2", 341 /* WXK_F2 */, 0 /* wxMOD_NONE */ },
{ "LoadStateSlot3", 342 /* WXK_F3 */, 0 /* wxMOD_NONE */ },

View File

@ -43,6 +43,17 @@ enum Hotkey
HK_INCREASE_FRAME_LIMIT,
HK_DECREASE_FRAME_LIMIT,
HK_FREELOOK_INCREASE_SPEED,
HK_FREELOOK_DECREASE_SPEED,
HK_FREELOOK_RESET_SPEED,
HK_FREELOOK_UP,
HK_FREELOOK_DOWN,
HK_FREELOOK_LEFT,
HK_FREELOOK_RIGHT,
HK_FREELOOK_ZOOM_IN,
HK_FREELOOK_ZOOM_OUT,
HK_FREELOOK_RESET,
HK_LOAD_STATE_SLOT_1,
HK_LOAD_STATE_SLOT_2,
HK_LOAD_STATE_SLOT_3,

View File

@ -972,6 +972,17 @@ int GetCmdForHotkey(unsigned int key)
case HK_SELECT_STATE_SLOT_10: return IDM_SELECTSLOT10;
case HK_SAVE_STATE_SLOT_SELECTED: return IDM_SAVESELECTEDSLOT;
case HK_LOAD_STATE_SLOT_SELECTED: return IDM_LOADSELECTEDSLOT;
case HK_FREELOOK_INCREASE_SPEED: return IDM_FREELOOK_INCREASE_SPEED;
case HK_FREELOOK_DECREASE_SPEED: return IDM_FREELOOK_DECREASE_SPEED;
case HK_FREELOOK_RESET_SPEED: return IDM_FREELOOK_RESET_SPEED;
case HK_FREELOOK_LEFT: return IDM_FREELOOK_LEFT;
case HK_FREELOOK_RIGHT: return IDM_FREELOOK_RIGHT;
case HK_FREELOOK_UP: return IDM_FREELOOK_UP;
case HK_FREELOOK_DOWN: return IDM_FREELOOK_DOWN;
case HK_FREELOOK_ZOOM_IN: return IDM_FREELOOK_ZOOM_IN;
case HK_FREELOOK_ZOOM_OUT: return IDM_FREELOOK_ZOOM_OUT;
case HK_FREELOOK_RESET: return IDM_FREELOOK_RESET;
}
return -1;
@ -1165,44 +1176,30 @@ void CFrame::OnKeyDown(wxKeyEvent& event)
ConnectWiimote(WiimoteId, connect);
}
if (g_Config.bFreeLook && event.GetModifiers() == wxMOD_SHIFT)
if (g_Config.bFreeLook)
{
static float debugSpeed = 1.0f;
switch (event.GetKeyCode())
{
case '1':
debugSpeed /= 2.0f;
break;
case '2':
if (IsHotkey(event, HK_FREELOOK_INCREASE_SPEED))
debugSpeed *= 2.0f;
break;
case 'W':
VertexShaderManager::TranslateView(0.0f, debugSpeed);
break;
case 'S':
VertexShaderManager::TranslateView(0.0f, -debugSpeed);
break;
case 'A':
VertexShaderManager::TranslateView(debugSpeed, 0.0f);
break;
case 'D':
VertexShaderManager::TranslateView(-debugSpeed, 0.0f);
break;
case 'Q':
VertexShaderManager::TranslateView(0.0f, 0.0f, debugSpeed);
break;
case 'E':
VertexShaderManager::TranslateView(0.0f, 0.0f, -debugSpeed);
break;
case 'R':
VertexShaderManager::ResetView();
break;
case 'F':
else if (IsHotkey(event, HK_FREELOOK_DECREASE_SPEED))
debugSpeed /= 2.0f;
else if (IsHotkey(event, HK_FREELOOK_RESET_SPEED))
debugSpeed = 1.0f;
break;
default:
break;
}
else if (IsHotkey(event, HK_FREELOOK_UP))
VertexShaderManager::TranslateView(0.0f, 0.0f, -debugSpeed);
else if (IsHotkey(event, HK_FREELOOK_DOWN))
VertexShaderManager::TranslateView(0.0f, 0.0f, debugSpeed);
else if (IsHotkey(event, HK_FREELOOK_LEFT))
VertexShaderManager::TranslateView(debugSpeed, 0.0f);
else if (IsHotkey(event, HK_FREELOOK_RIGHT))
VertexShaderManager::TranslateView(-debugSpeed, 0.0f);
else if (IsHotkey(event, HK_FREELOOK_ZOOM_IN))
VertexShaderManager::TranslateView(0.0f, debugSpeed);
else if (IsHotkey(event, HK_FREELOOK_ZOOM_OUT))
VertexShaderManager::TranslateView(0.0f, -debugSpeed);
else if (IsHotkey(event, HK_FREELOOK_RESET))
VertexShaderManager::ResetView();
}
}
else

View File

@ -1771,7 +1771,8 @@ void CFrame::UpdateGUI()
{
if (GetCmdForHotkey(i) == -1)
continue;
GetMenuBar()->FindItem(GetCmdForHotkey(i))->SetItemLabel(GetMenuLabel(i));
if (GetMenuBar()->FindItem(GetCmdForHotkey(i)))
GetMenuBar()->FindItem(GetCmdForHotkey(i))->SetItemLabel(GetMenuLabel(i));
}
GetMenuBar()->FindItem(IDM_LOADSTATE)->Enable(Initialized);

View File

@ -280,6 +280,17 @@ enum
IDM_MPANEL, ID_STATUSBAR,
IDM_FREELOOK_INCREASE_SPEED,
IDM_FREELOOK_DECREASE_SPEED,
IDM_FREELOOK_RESET_SPEED,
IDM_FREELOOK_UP,
IDM_FREELOOK_DOWN,
IDM_FREELOOK_LEFT,
IDM_FREELOOK_RIGHT,
IDM_FREELOOK_ZOOM_IN,
IDM_FREELOOK_ZOOM_OUT,
IDM_FREELOOK_RESET,
ID_TOOLBAR = 500,
};

View File

@ -227,6 +227,17 @@ void HotkeyConfigDialog::CreateHotkeyGUIControls()
_("Increase Frame limit"),
_("Decrease Frame limit"),
_("Freelook Increase Speed"),
_("Freelook Decrease Speed"),
_("Freelook Reset Speed"),
_("Freelook Move Up"),
_("Freelook Move Down"),
_("Freelook Move Left"),
_("Freelook Move Right"),
_("Freelook Zoom In"),
_("Freelook Zoom Out"),
_("Freelook Reset"),
_("Load State Slot 1"),
_("Load State Slot 2"),
_("Load State Slot 3"),