diff --git a/Source/Core/Core/Src/ConfigManager.cpp b/Source/Core/Core/Src/ConfigManager.cpp index d305c5f27c..8f88b00545 100644 --- a/Source/Core/Core/Src/ConfigManager.cpp +++ b/Source/Core/Core/Src/ConfigManager.cpp @@ -25,6 +25,20 @@ SConfig* SConfig::m_Instance; +static const struct { + const char* IniText; + const int DefaultKey; + const int DefaultModifier; +} g_HKData[] = { + { "ToggleFullscreen", 13 /* WXK_RETURN */, 0x0001 /* wxMOD_ALT */ }, + { "PlayPause", 349 /* WXK_F10 */, 0x0000 /* wxMOD_NONE */ }, + { "Stop", 27 /* WXK_ESCAPE */, 0x0000 /* wxMOD_NONE */ }, + { "Wiimote1Connect", 344 /* WXK_F5 */, 0x0001 /* wxMOD_ALT */ }, + { "Wiimote2Connect", 345 /* WXK_F6 */, 0x0001 /* wxMOD_ALT */ }, + { "Wiimote3Connect", 346 /* WXK_F7 */, 0x0001 /* wxMOD_ALT */ }, + { "Wiimote4Connect", 347 /* WXK_F8 */, 0x0001 /* wxMOD_ALT */ }, +}; + SConfig::SConfig() { // Make sure we have log manager @@ -90,12 +104,12 @@ void SConfig::SaveSettings() ini.Set("Interface", "ShowConsole", m_InterfaceConsole); // Hotkeys - ini.Set("Hotkeys", "ToggleFullscreen", m_LocalCoreStartupParameter.iHotkey[HK_FULLSCREEN]); - ini.Set("Hotkeys", "PlayPause", m_LocalCoreStartupParameter.iHotkey[HK_PLAY_PAUSE]); - ini.Set("Hotkeys", "Stop", m_LocalCoreStartupParameter.iHotkey[HK_STOP]); - ini.Set("Hotkeys", "ToggleFullscreenModifier", m_LocalCoreStartupParameter.iHotkeyModifier[HK_FULLSCREEN]); - ini.Set("Hotkeys", "PlayPauseModifier", m_LocalCoreStartupParameter.iHotkeyModifier[HK_PLAY_PAUSE]); - ini.Set("Hotkeys", "StopModifier", m_LocalCoreStartupParameter.iHotkeyModifier[HK_STOP]); + for (int i = HK_FULLSCREEN; i < NUM_HOTKEYS; i++) + { + ini.Set("Hotkeys", g_HKData[i].IniText, m_LocalCoreStartupParameter.iHotkey[i]); + ini.Set("Hotkeys", (std::string(g_HKData[i].IniText) + "Modifier").c_str(), + m_LocalCoreStartupParameter.iHotkeyModifier[i]); + } // Display ini.Set("Display", "FullscreenResolution", m_LocalCoreStartupParameter.strFullscreenResolution); @@ -216,12 +230,13 @@ void SConfig::LoadSettings() ini.Get("Interface", "ShowConsole", &m_InterfaceConsole, false); // Hotkeys - ini.Get("Hotkeys", "ToggleFullscreen", &m_LocalCoreStartupParameter.iHotkey[HK_FULLSCREEN], 13); // WXK_RETURN - ini.Get("Hotkeys", "PlayPause", &m_LocalCoreStartupParameter.iHotkey[HK_PLAY_PAUSE], 349); // WXK_F10 - ini.Get("Hotkeys", "Stop", &m_LocalCoreStartupParameter.iHotkey[HK_STOP], 27); // WXK_ESCAPE - ini.Get("Hotkeys", "ToggleFullscreenModifier", &m_LocalCoreStartupParameter.iHotkeyModifier[HK_FULLSCREEN], 0x0001); // wxMOD_ALT - ini.Get("Hotkeys", "PlayPauseModifier", &m_LocalCoreStartupParameter.iHotkeyModifier[HK_PLAY_PAUSE], 0x0000); // wxMOD_NONE - ini.Get("Hotkeys", "StopModifier", &m_LocalCoreStartupParameter.iHotkeyModifier[HK_STOP], 0x0000); // wxMOD_NONE + for (int i = HK_FULLSCREEN; i < NUM_HOTKEYS; i++) + { + ini.Get("Hotkeys", g_HKData[i].IniText, + &m_LocalCoreStartupParameter.iHotkey[i], g_HKData[i].DefaultKey); + ini.Get("Hotkeys", (std::string(g_HKData[i].IniText) + "Modifier").c_str(), + &m_LocalCoreStartupParameter.iHotkeyModifier[i], g_HKData[i].DefaultModifier); + } // Display ini.Get("Display", "Fullscreen", &m_LocalCoreStartupParameter.bFullscreen, false); @@ -302,4 +317,4 @@ void SConfig::LoadSettingsWii() sprintf(SectionName, "Wiimote%i", i + 1); ini.Get(SectionName, "AutoReconnectRealWiimote", &m_WiiAutoReconnect[i], false); } -} \ No newline at end of file +} diff --git a/Source/Core/Core/Src/CoreParameter.h b/Source/Core/Core/Src/CoreParameter.h index d82cd27086..463a9f882a 100644 --- a/Source/Core/Core/Src/CoreParameter.h +++ b/Source/Core/Core/Src/CoreParameter.h @@ -28,6 +28,10 @@ enum Hotkey { HK_FULLSCREEN, HK_PLAY_PAUSE, HK_STOP, + HK_WIIMOTE1_CONNECT, + HK_WIIMOTE2_CONNECT, + HK_WIIMOTE3_CONNECT, + HK_WIIMOTE4_CONNECT, NUM_HOTKEYS, }; diff --git a/Source/Core/DolphinWX/Src/Frame.cpp b/Source/Core/DolphinWX/Src/Frame.cpp index 682c032f34..29a14ada4e 100644 --- a/Source/Core/DolphinWX/Src/Frame.cpp +++ b/Source/Core/DolphinWX/Src/Frame.cpp @@ -817,6 +817,7 @@ void CFrame::OnKeyDown(wxKeyEvent& event) { if(Core::GetState() != Core::CORE_UNINITIALIZED) { + int WiimoteId = -1; // Toggle fullscreen if (IsHotkey(event, HK_FULLSCREEN)) DoFullscreen(!RendererIsFullscreen()); @@ -826,6 +827,15 @@ void CFrame::OnKeyDown(wxKeyEvent& event) // Stop else if (IsHotkey(event, HK_STOP)) DoStop(); + // 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; // state save and state load hotkeys else if (event.GetKeyCode() >= WXK_F1 && event.GetKeyCode() <= WXK_F8) { @@ -834,7 +844,8 @@ void CFrame::OnKeyDown(wxKeyEvent& event) State_Load(slot_number); else if (event.GetModifiers() == wxMOD_SHIFT) State_Save(slot_number); - else event.Skip(); + else + event.Skip(); } else if (event.GetKeyCode() == WXK_F11 && event.GetModifiers() == wxMOD_NONE) State_LoadLastSaved(); @@ -851,6 +862,17 @@ void CFrame::OnKeyDown(wxKeyEvent& event) Core::ScreenShot(); else event.Skip(); + // Actually perform the wiimote connection or disconnection + if (WiimoteId >= 0) + { + bNoWiimoteMsg = GetMenuBar()->IsChecked(IDM_CONNECT_WIIMOTE1 + WiimoteId); + GetMenuBar()->Check(IDM_CONNECT_WIIMOTE1 + WiimoteId, !bNoWiimoteMsg); + GetUsbPointer()->AccessWiiMote(WiimoteId | 0x100)->Activate(!bNoWiimoteMsg); + wxString msg(wxString::Format(wxT("Wiimote %i %s"), WiimoteId + 1, + bNoWiimoteMsg ? wxT("Disconnected") : wxT("Connected"))); + Core::DisplayMessage(msg.ToAscii(), 3000); + } + // Send the OSD hotkeys to the video plugin if (event.GetKeyCode() >= '3' && event.GetKeyCode() <= '7' && event.GetModifiers() == wxMOD_NONE) { diff --git a/Source/Core/DolphinWX/Src/FrameTools.cpp b/Source/Core/DolphinWX/Src/FrameTools.cpp index d84a08115b..756dc6bdd7 100644 --- a/Source/Core/DolphinWX/Src/FrameTools.cpp +++ b/Source/Core/DolphinWX/Src/FrameTools.cpp @@ -196,10 +196,10 @@ void CFrame::CreateMenu() toolsMenu->Append(IDM_LOAD_WII_MENU, _T("Load Wii Menu")); } toolsMenu->AppendSeparator(); - toolsMenu->AppendCheckItem(IDM_CONNECT_WIIMOTE1, _T("Connect Wiimote 1\tAlt+F5")); - toolsMenu->AppendCheckItem(IDM_CONNECT_WIIMOTE2, _T("Connect Wiimote 2\tAlt+F6")); - toolsMenu->AppendCheckItem(IDM_CONNECT_WIIMOTE3, _T("Connect Wiimote 3\tAlt+F7")); - toolsMenu->AppendCheckItem(IDM_CONNECT_WIIMOTE4, _T("Connect Wiimote 4\tAlt+F8")); + toolsMenu->AppendCheckItem(IDM_CONNECT_WIIMOTE1, GetMenuLabel(HK_WIIMOTE1_CONNECT)); + toolsMenu->AppendCheckItem(IDM_CONNECT_WIIMOTE2, GetMenuLabel(HK_WIIMOTE2_CONNECT)); + toolsMenu->AppendCheckItem(IDM_CONNECT_WIIMOTE3, GetMenuLabel(HK_WIIMOTE3_CONNECT)); + toolsMenu->AppendCheckItem(IDM_CONNECT_WIIMOTE4, GetMenuLabel(HK_WIIMOTE4_CONNECT)); m_MenuBar->Append(toolsMenu, _T("&Tools")); @@ -279,13 +279,21 @@ wxString CFrame::GetMenuLabel(int Id) Label = _T("&Fullscreen\t"); break; case HK_PLAY_PAUSE: - if (Core::GetState() == Core::CORE_UNINITIALIZED) - Label = _T("&Play\t"); + if (Core::GetState() == Core::CORE_RUN) + Label = _T("&Pause\t"); else Label = _T("&Play\t"); break; case HK_STOP: Label = _T("&Stop\t"); + case HK_WIIMOTE1_CONNECT: + Label = _T("Connect Wiimote 1\t"); + case HK_WIIMOTE2_CONNECT: + Label = _T("Connect Wiimote 2\t"); + case HK_WIIMOTE3_CONNECT: + Label = _T("Connect Wiimote 3\t"); + case HK_WIIMOTE4_CONNECT: + Label = _T("Connect Wiimote 4\t"); } wxString Modifier = InputCommon::WXKeymodToString @@ -1183,6 +1191,10 @@ void CFrame::UpdateGUI() GetMenuBar()->FindItem(IDM_TOGGLE_FULLSCREEN)->SetItemLabel(GetMenuLabel(HK_FULLSCREEN)); GetMenuBar()->FindItem(IDM_PLAY)->SetItemLabel(GetMenuLabel(HK_PLAY_PAUSE)); GetMenuBar()->FindItem(IDM_STOP)->SetItemLabel(GetMenuLabel(HK_STOP)); + GetMenuBar()->FindItem(IDM_CONNECT_WIIMOTE1)->SetItemLabel(GetMenuLabel(HK_WIIMOTE1_CONNECT)); + GetMenuBar()->FindItem(IDM_CONNECT_WIIMOTE2)->SetItemLabel(GetMenuLabel(HK_WIIMOTE2_CONNECT)); + GetMenuBar()->FindItem(IDM_CONNECT_WIIMOTE3)->SetItemLabel(GetMenuLabel(HK_WIIMOTE3_CONNECT)); + GetMenuBar()->FindItem(IDM_CONNECT_WIIMOTE4)->SetItemLabel(GetMenuLabel(HK_WIIMOTE4_CONNECT)); m_pSubMenuLoad->Enable(Initialized); m_pSubMenuSave->Enable(Initialized); diff --git a/Source/Core/DolphinWX/Src/HotkeyDlg.cpp b/Source/Core/DolphinWX/Src/HotkeyDlg.cpp index 774bcf76b5..20dfc20578 100644 --- a/Source/Core/DolphinWX/Src/HotkeyDlg.cpp +++ b/Source/Core/DolphinWX/Src/HotkeyDlg.cpp @@ -21,9 +21,8 @@ BEGIN_EVENT_TABLE(HotkeyConfigDialog,wxDialog) EVT_CLOSE(HotkeyConfigDialog::OnClose) EVT_BUTTON(ID_CLOSE, HotkeyConfigDialog::CloseClick) - EVT_BUTTON(ID_FULLSCREEN, HotkeyConfigDialog::OnButtonClick) - EVT_BUTTON(ID_PLAY_PAUSE, HotkeyConfigDialog::OnButtonClick) - EVT_BUTTON(ID_STOP, HotkeyConfigDialog::OnButtonClick) + EVT_COMMAND_RANGE(HK_FULLSCREEN, NUM_HOTKEYS - 1, + wxEVT_COMMAND_BUTTON_CLICKED, HotkeyConfigDialog::OnButtonClick) EVT_TIMER(IDTM_BUTTON, HotkeyConfigDialog::OnButtonTimer) END_EVENT_TABLE() @@ -191,6 +190,10 @@ void HotkeyConfigDialog::CreateHotkeyGUIControls(void) wxT("Toggle Fullscreen"), wxT("Play/Pause"), wxT("Stop"), + wxT("Connect Wiimote 1"), + wxT("Connect Wiimote 2"), + wxT("Connect Wiimote 3"), + wxT("Connect Wiimote 4") }; // Configuration controls sizes @@ -215,7 +218,7 @@ void HotkeyConfigDialog::CreateHotkeyGUIControls(void) wxStaticText *stHotkeys = new wxStaticText(this, wxID_ANY, hkText[i]); // Key selection button - m_Button_Hotkeys[i] = new wxButton(this, ID_FULLSCREEN + i, wxEmptyString, + m_Button_Hotkeys[i] = new wxButton(this, HK_FULLSCREEN + i, wxEmptyString, wxDefaultPosition, size); m_Button_Hotkeys[i]->SetFont(m_SmallFont); SetButtonText(i, diff --git a/Source/Core/DolphinWX/Src/HotkeyDlg.h b/Source/Core/DolphinWX/Src/HotkeyDlg.h index f1532b7c40..dedfe45387 100644 --- a/Source/Core/DolphinWX/Src/HotkeyDlg.h +++ b/Source/Core/DolphinWX/Src/HotkeyDlg.h @@ -29,6 +29,7 @@ #include "Config.h" #endif +#include "CoreParameter.h" #include "WXInputBase.h" #if defined(HAVE_X11) && HAVE_X11 @@ -55,10 +56,6 @@ class HotkeyConfigDialog : public wxDialog enum { - ID_FULLSCREEN, - ID_PLAY_PAUSE, - ID_STOP, - NUM_HOTKEYS, ID_CLOSE = 1000, IDTM_BUTTON, // Timer ID_APPLY diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/GLUtil.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/GLUtil.cpp index c970bb302c..b56926ab63 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/GLUtil.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/GLUtil.cpp @@ -461,7 +461,6 @@ void OpenGL_Shutdown() hDC = NULL; // Set DC To NULL } #elif defined(HAVE_X11) && HAVE_X11 - printf ("Unmapping window\n"); if (GLWin.ctx) { if (!glXMakeCurrent(GLWin.dpy, None, NULL))