void CFrame::OnConnectWiimote(wxCommandEvent& event) { if (SConfig::GetInstance().m_bt_passthrough_enabled) return; bool was_unpaused = Core::PauseAndLock(true); ConnectWiimote(event.GetId() - IDM_CONNECT_WIIMOTE1, !GetUsbPointer() ->AccessWiiMote((event.GetId() - IDM_CONNECT_WIIMOTE1) | 0x100) ->IsConnected()); Core::PauseAndLock(false, was_unpaused); }
void CFrame::OnKeyDown(wxKeyEvent& event) { if(Core::GetState() != Core::CORE_UNINITIALIZED && (RendererHasFocus() || g_TASInputDlg->HasFocus())) { int WiimoteId = -1; // 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(); // 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) { int slot_number = event.GetKeyCode() - WXK_F1 + 1; if (event.GetModifiers() == wxMOD_NONE) State::Load(slot_number); else if (event.GetModifiers() == wxMOD_SHIFT) State::Save(slot_number); else event.Skip(); }*/ else if (event.GetKeyCode() == WXK_F11 && event.GetModifiers() == wxMOD_NONE) State::LoadLastSaved(); else if (event.GetKeyCode() == WXK_F12) { if (event.GetModifiers() == wxMOD_NONE) State::UndoSaveState(); else if (event.GetModifiers() == wxMOD_SHIFT) State::UndoLoadState(); else event.Skip(); } else { unsigned int i = NUM_HOTKEYS; if (!SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain || g_TASInputDlg->HasFocus()) { for (i = 0; i < NUM_HOTKEYS; i++) { if (IsHotkey(event, i)) { int cmd = GetCmdForHotkey(i); if (cmd >= 0) { wxCommandEvent evt(wxEVT_COMMAND_MENU_SELECTED, cmd); wxMenuItem *item = GetMenuBar()->FindItem(cmd); if (item && item->IsCheckable()) { item->wxMenuItemBase::Toggle(); evt.SetInt(item->IsChecked()); } GetEventHandler()->AddPendingEvent(evt); break; } } } } // 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 } // Actually perform the wiimote connection or disconnection if (WiimoteId >= 0) { bool connect = !GetMenuBar()->IsChecked(IDM_CONNECT_WIIMOTE1 + WiimoteId); ConnectWiimote(WiimoteId, connect); } // Send the OSD hotkeys to the video backend if (event.GetKeyCode() >= '3' && event.GetKeyCode() <= '7' && event.GetModifiers() == wxMOD_NONE) { #ifdef _WIN32 PostMessage((HWND)Core::GetWindowHandle(), WM_USER, WM_USER_KEYDOWN, event.GetKeyCode()); #elif defined(HAVE_X11) && HAVE_X11 X11Utils::SendKeyEvent(X11Utils::XDisplayFromHandle(GetHandle()), event.GetKeyCode()); #endif } // Send the freelook hotkeys to the video backend if ((event.GetKeyCode() == ')' || event.GetKeyCode() == '(' || event.GetKeyCode() == '0' || event.GetKeyCode() == '9' || event.GetKeyCode() == 'W' || event.GetKeyCode() == 'S' || event.GetKeyCode() == 'A' || event.GetKeyCode() == 'D' || event.GetKeyCode() == 'R') && event.GetModifiers() == wxMOD_SHIFT) { #ifdef _WIN32 PostMessage((HWND)Core::GetWindowHandle(), WM_USER, WM_USER_KEYDOWN, event.GetKeyCode()); #elif defined(HAVE_X11) && HAVE_X11 X11Utils::SendKeyEvent(X11Utils::XDisplayFromHandle(GetHandle()), event.GetKeyCode()); #endif } } else event.Skip(); }