diff --git a/Source/Core/Core/Src/ConfigManager.cpp b/Source/Core/Core/Src/ConfigManager.cpp index 14baf13eeb..93512ed18f 100644 --- a/Source/Core/Core/Src/ConfigManager.cpp +++ b/Source/Core/Core/Src/ConfigManager.cpp @@ -85,8 +85,6 @@ void SConfig::SaveSettings() ini.Set("Interface", "MainWindowPosY", m_LocalCoreStartupParameter.iPosY); ini.Set("Interface", "MainWindowWidth", m_LocalCoreStartupParameter.iWidth); ini.Set("Interface", "MainWindowHeight", m_LocalCoreStartupParameter.iHeight); - ini.Set("Interface", "ShowWiimoteLeds", m_LocalCoreStartupParameter.bWiiLeds); - ini.Set("Interface", "ShowWiimoteSpeakers", m_LocalCoreStartupParameter.bWiiSpeakers); ini.Set("Interface", "Language", m_InterfaceLanguage); ini.Set("Interface", "ShowToolbar", m_InterfaceToolbar); ini.Set("Interface", "ShowStatusbar", m_InterfaceStatusbar); @@ -197,8 +195,6 @@ void SConfig::LoadSettings() ini.Get("Interface", "MainWindowPosY", &m_LocalCoreStartupParameter.iPosY, 100); ini.Get("Interface", "MainWindowWidth", &m_LocalCoreStartupParameter.iWidth, 800); ini.Get("Interface", "MainWindowHeight", &m_LocalCoreStartupParameter.iHeight, 600); - ini.Get("Interface", "ShowWiimoteLeds", &m_LocalCoreStartupParameter.bWiiLeds, false); - ini.Get("Interface", "ShowWiimoteSpeakers", &m_LocalCoreStartupParameter.bWiiSpeakers, false); ini.Get("Interface", "Language", (int*)&m_InterfaceLanguage, 0); ini.Get("Interface", "ShowToolbar", &m_InterfaceToolbar, true); ini.Get("Interface", "ShowStatusbar", &m_InterfaceStatusbar, true); diff --git a/Source/Core/Core/Src/Core.cpp b/Source/Core/Core/Src/Core.cpp index 95a1a592ed..45333463f5 100644 --- a/Source/Core/Core/Src/Core.cpp +++ b/Source/Core/Core/Src/Core.cpp @@ -29,11 +29,6 @@ #include "MathUtil.h" #include "MemoryUtil.h" -#if defined(HAVE_X11) && HAVE_X11 -#include -#include -#endif - #include "Console.h" #include "Core.h" #include "CPUDetect.h" @@ -252,45 +247,6 @@ void Stop() // - Hammertime! g_EmuThread = 0; } -#if defined(HAVE_X11) && HAVE_X11 -void ProcessXEvents(void) -{ - if (GetState() == CORE_PAUSE) - { - Display *dpy = (Display *)g_pWindowHandle; - XEvent event; - KeySym key; - int num_events; - for (num_events = XPending(dpy);num_events > 0;num_events--) - { - XNextEvent(dpy, &event); - switch(event.type) { - case KeyPress: - key = XLookupKeysym((XKeyEvent*)&event, 0); - if (key == XK_Escape) - Host_Message(WM_USER_PAUSE); - case ClientMessage: - if ((ulong) event.xclient.data.l[0] == XInternAtom(dpy, "WM_DELETE_WINDOW", False)) - Host_Message(WM_USER_STOP); - break; - default: - break; - } - } - } -} - -THREAD_RETURN XEventThread(void *pArg) -{ - while (PowerPC::GetState() != PowerPC::CPU_POWERDOWN) - { - ProcessXEvents(); - Common::SleepCurrentThread(200); - } - return 0; -} -#endif - // Create the CPU thread. which would be a CPU + Video thread in Single Core mode. THREAD_RETURN CpuThread(void *pArg) @@ -366,6 +322,9 @@ THREAD_RETURN EmuThread(void *pArg) VideoInitialize.pScheduleEvent_Threadsafe = CoreTiming::ScheduleEvent_Threadsafe; // This is first the m_Panel handle, then it is updated to have the new window handle VideoInitialize.pWindowHandle = _CoreParameter.hMainWindow; +#if defined(HAVE_X11) && HAVE_X11 && defined(HAVE_GTK2) && HAVE_GTK2 + VideoInitialize.pPanel = _CoreParameter.hMainWindow; +#endif VideoInitialize.pLog = Callback_VideoLog; VideoInitialize.pSysMessage = Host_SysMessage; VideoInitialize.pRequestWindowSize = NULL; //Callback_VideoRequestWindowSize; @@ -386,7 +345,7 @@ THREAD_RETURN EmuThread(void *pArg) // Under linux, this is an X11 Display, not a HWND! g_pWindowHandle = (HWND)VideoInitialize.pWindowHandle; #if defined(HAVE_X11) && HAVE_X11 - g_pXWindow = (Window *)VideoInitialize.pXWindow; + g_pXWindow = (void *)VideoInitialize.pXWindow; #endif Callback_PeekMessages = VideoInitialize.pPeekMessages; g_pUpdateFPSDisplay = VideoInitialize.pUpdateFPSDisplay; @@ -415,6 +374,9 @@ THREAD_RETURN EmuThread(void *pArg) PADInitialize.hWnd = g_pWindowHandle; #if defined(HAVE_X11) && HAVE_X11 PADInitialize.pXWindow = g_pXWindow; +#if defined(HAVE_GTK2) && HAVE_GTK2 + PADInitialize.pPanel = VideoInitialize.pPanel; +#endif #endif PADInitialize.pLog = Callback_PADLog; // This is may be needed to avoid a SDL problem @@ -427,6 +389,9 @@ THREAD_RETURN EmuThread(void *pArg) SWiimoteInitialize WiimoteInitialize; WiimoteInitialize.hWnd = g_pWindowHandle; #if defined(HAVE_X11) && HAVE_X11 +#if defined(HAVE_GTK2) && HAVE_GTK2 + WiimoteInitialize.pPanel = VideoInitialize.pPanel; +#endif WiimoteInitialize.pXWindow = g_pXWindow; #endif WiimoteInitialize.ISOId = Ascii2Hex(_CoreParameter.m_strUniqueID); @@ -457,10 +422,6 @@ THREAD_RETURN EmuThread(void *pArg) // Spawn the CPU thread Common::Thread *cpuThread = NULL; -#if defined(HAVE_X11) && HAVE_X11 - Common::Thread *xEventThread = NULL; -#endif - // ENTER THE VIDEO THREAD LOOP if (_CoreParameter.bCPUThread) { @@ -469,9 +430,6 @@ THREAD_RETURN EmuThread(void *pArg) Plugins.GetVideo()->Video_Prepare(); // wglMakeCurrent cpuThread = new Common::Thread(CpuThread, pArg); -#if defined(HAVE_X11) && HAVE_X11 - xEventThread = new Common::Thread(XEventThread, pArg); -#endif Common::SetCurrentThreadName("Video thread"); if (g_pUpdateFPSDisplay != NULL) @@ -506,9 +464,6 @@ THREAD_RETURN EmuThread(void *pArg) { if (Callback_PeekMessages) Callback_PeekMessages(); -#if defined(HAVE_X11) && HAVE_X11 - ProcessXEvents(); -#endif Common::SleepCurrentThread(20); } @@ -815,11 +770,15 @@ void Callback_KeyPress(int key, bool shift, bool control) State_UndoLoadState(); } #if defined(HAVE_X11) && HAVE_X11 + if (key == 0) + Host_Message(WM_USER_CREATE); // 0x1b == VK_ESCAPE if (key == 0x1b) Host_Message(WM_USER_STOP); if (key == 0x1c) Host_Message(WM_USER_PAUSE); + if (key == 0x1d) + Host_Message(TOGGLE_FULLSCREEN); #endif } diff --git a/Source/Core/Core/Src/CoreParameter.cpp b/Source/Core/Core/Src/CoreParameter.cpp index 21816d42f9..56d89b5f3d 100644 --- a/Source/Core/Core/Src/CoreParameter.cpp +++ b/Source/Core/Core/Src/CoreParameter.cpp @@ -47,7 +47,7 @@ SCoreStartupParameter::SCoreStartupParameter() bEnableCheats(false), bEnableIsoCache(false), bRunCompareServer(false), bRunCompareClient(false), iTLBHack(0), SelectedLanguage(0), - bWii(false), bWiiLeds(false), bWiiSpeakers(false), + bWii(false), bConfirmStop(false), bHideCursor(false), bAutoHideCursor(false), bUsePanicHandlers(true), iTheme(0), diff --git a/Source/Core/Core/Src/CoreParameter.h b/Source/Core/Core/Src/CoreParameter.h index 06d4147d97..c6d85df1e8 100644 --- a/Source/Core/Core/Src/CoreParameter.h +++ b/Source/Core/Core/Src/CoreParameter.h @@ -73,8 +73,7 @@ struct SCoreStartupParameter int SelectedLanguage; - // Wii settings - bool bWii, bWiiLeds, bWiiSpeakers; + bool bWii; // Interface settings bool bConfirmStop, bHideCursor, bAutoHideCursor, bUsePanicHandlers; diff --git a/Source/Core/Core/Src/Host.h b/Source/Core/Core/Src/Host.h index 17d866650d..d429aa3bc1 100644 --- a/Source/Core/Core/Src/Host.h +++ b/Source/Core/Core/Src/Host.h @@ -53,8 +53,4 @@ void Host_UpdateStatusBar(const char* _pText, int Filed = 0); void Host_SysMessage(const char *fmt, ...); void Host_SetWiiMoteConnectionState(int _State); -void Host_UpdateLeds(int bits); -void Host_UpdateSpeakerStatus(int index, int bits); -void Host_UpdateStatus(); - #endif diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp index d66bd09290..39aef08d98 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp @@ -146,75 +146,10 @@ bool CWII_IPC_HLE_WiiMote::LinkChannel() } m_Connected = 3; - UpdateStatus(); return false; } -// =================================================== -/* Send a status report to the status bar. */ -// ---------------- -void CWII_IPC_HLE_WiiMote::ShowStatus(const void* _pData) -{ - // Check if it's enabled - SCoreStartupParameter& StartUp = SConfig::GetInstance().m_LocalCoreStartupParameter; - bool LedsOn = StartUp.bWiiLeds; - bool SpeakersOn = StartUp.bWiiSpeakers; - - const u8* data = (const u8*)_pData; - - // Get the last four bits with LED info - if (LedsOn) - { - if (data[1] == 0x11) - { - int led_bits = (data[2] >> 4); - Host_UpdateLeds(led_bits); - } - } - - int speaker_bits = 0; - - if (SpeakersOn) - { - u8 Bits = 0; - switch (data[1]) - { - case 0x14: // Enable and disable speakers - if (data[2] == 0x02) // Off - Bits = 0; - else if (data[2] == 0x06) // On - Bits = 1; - Host_UpdateSpeakerStatus(0, Bits); - break; - - case 0x19: // Mute and unmute - // Get the value - if (data[2] == 0x02) // Unmute - Bits = 1; - else if (data[2] == 0x06) // Mute - Bits = 0; - Host_UpdateSpeakerStatus(1, Bits); - break; - // Write to speaker registry, or write sound - case 0x16: - case 0x18: - // Turn on the activity light - Host_UpdateSpeakerStatus(2, 1); - break; - } - } -} - -// Turn off the activity icon again -void CWII_IPC_HLE_WiiMote::UpdateStatus() -{ - // Check if it's enabled - if (!SConfig::GetInstance().m_LocalCoreStartupParameter.bWiiSpeakers) - return; - Host_UpdateStatus(); -} - // // // @@ -335,13 +270,10 @@ void CWII_IPC_HLE_WiiMote::ExecuteL2capCmd(u8* _pData, u32 _Size) case HID_CONTROL_CHANNEL: mote->Wiimote_ControlChannel(m_ConnectionHandle & 0xFF, pHeader->CID, pData, DataSize); - // Call Wiimote Plugin break; case HID_INTERRUPT_CHANNEL: - ShowStatus(pData); mote->Wiimote_InterruptChannel(m_ConnectionHandle & 0xFF, pHeader->CID, pData, DataSize); - // Call Wiimote Plugin break; default: diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.h b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.h index 735c61dd25..7edba78858 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.h +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.h @@ -130,66 +130,33 @@ struct SL2CAP_CommandDisconnectionResponse // 0x07 #pragma pack(pop) + class CBigEndianBuffer { public: - CBigEndianBuffer(u8* pBuffer) - : m_pBuffer(pBuffer) - { - } + CBigEndianBuffer(u8* pBuffer) : m_pBuffer(pBuffer) {} - u8 Read8(u32 offset) - { - return m_pBuffer[offset]; - } + u8 Read8(u32 offset) { return m_pBuffer[offset]; } + u16 Read16(u32 offset) { return Common::swap16(*(u16*)&m_pBuffer[offset]); } + u32 Read32(u32 offset) { return Common::swap32(*(u32*)&m_pBuffer[offset]); } - u16 Read16(u32 offset) - { - return Common::swap16(*(u16*)&m_pBuffer[offset]); - } + void Write8(u32 offset, u8 data) { m_pBuffer[offset] = data; } + void Write16(u32 offset, u16 data) { *(u16*)&m_pBuffer[offset] = Common::swap16(data); } + void Write32(u32 offset, u32 data) { *(u32*)&m_pBuffer[offset] = Common::swap32(data); } - u32 Read32(u32 offset) - { - return Common::swap32(*(u32*)&m_pBuffer[offset]); - } - - void Write8(u32 offset, u8 data) - { - m_pBuffer[offset] = data; - } - - void Write16(u32 offset, u16 data) - { - *(u16*)&m_pBuffer[offset] = Common::swap16(data); - } - - void Write32(u32 offset, u32 data) - { - *(u32*)&m_pBuffer[offset] = Common::swap32(data); - } - - u8* GetPointer(u32 offset) - { - return &m_pBuffer[offset]; - } + u8* GetPointer(u32 offset) { return &m_pBuffer[offset]; } private: - u8* m_pBuffer; - }; - - class CWII_IPC_HLE_WiiMote { public: - CWII_IPC_HLE_WiiMote(CWII_IPC_HLE_Device_usb_oh1_57e_305* _pHost, int _Number, bool ready = false); - virtual ~CWII_IPC_HLE_WiiMote() - {} + virtual ~CWII_IPC_HLE_WiiMote() {} void DoState(PointerWrap &p); @@ -200,8 +167,6 @@ public: bool LinkChannel(); void ResetChannels(); void Activate(bool ready); - void ShowStatus(const void* _pData); // Show status - void UpdateStatus(); // Update status void ExecuteL2capCmd(u8* _pData, u32 _Size); // From CPU void ReceiveL2capData(u16 scid, const void* _pData, u32 _Size); // From wiimote @@ -220,7 +185,6 @@ public: const u8* GetLinkKey() const { return m_LinkKey; } private: - // -1: inactive, 0: ready, 1: connecting 2: linking 3: connected & linked int m_Connected; @@ -277,9 +241,7 @@ private: void ReceiveConfigurationResponse(u8 _Ident, u8* _pData, u32 _Size); // some new ugly stuff - // // should be inside the plugin - // void HandleSDP(u16 _SCID, u8* _pData, u32 _Size); void SDPSendServiceSearchResponse(u16 _SCID, u16 _TransactionID, u8* _pServiceSearchPattern, u16 _MaximumServiceRecordCount); diff --git a/Source/Core/DiscIO/Src/DriveBlob.cpp b/Source/Core/DiscIO/Src/DriveBlob.cpp index ff9a5551c4..cd68e8b078 100644 --- a/Source/Core/DiscIO/Src/DriveBlob.cpp +++ b/Source/Core/DiscIO/Src/DriveBlob.cpp @@ -56,6 +56,7 @@ DriveReader::DriveReader(const char *drive) 0, &dwNotUsed, NULL); #endif #else + SectorReader::SetSectorSize(2048); file_ = fopen(drive, "rb"); if (file_) { @@ -83,7 +84,8 @@ DriveReader::~DriveReader() hDisc = INVALID_HANDLE_VALUE; } #else - fclose(file_); + if (file_) + fclose(file_); file_ = 0; #endif } diff --git a/Source/Core/DolphinWX/DolphinWX.vcproj b/Source/Core/DolphinWX/DolphinWX.vcproj index 72ad005282..6ca7c349e6 100644 --- a/Source/Core/DolphinWX/DolphinWX.vcproj +++ b/Source/Core/DolphinWX/DolphinWX.vcproj @@ -855,10 +855,6 @@ RelativePath=".\Src\FrameTools.cpp" > - - diff --git a/Source/Core/DolphinWX/Src/BootManager.cpp b/Source/Core/DolphinWX/Src/BootManager.cpp index 03fce5a1e7..a3ae334358 100644 --- a/Source/Core/DolphinWX/Src/BootManager.cpp +++ b/Source/Core/DolphinWX/Src/BootManager.cpp @@ -139,9 +139,6 @@ bool BootCore(const std::string& _rFilename) { // Save the window handle of the eventual parent to the rendering window StartUp.hMainWindow = main_frame->GetRenderHandle(); - - // Now that we know if we have a Wii game we can run this - main_frame->ModifyStatusBar(); } #endif // Init the core diff --git a/Source/Core/DolphinWX/Src/ConfigMain.cpp b/Source/Core/DolphinWX/Src/ConfigMain.cpp index 32ad7cfb39..1bb77de529 100644 --- a/Source/Core/DolphinWX/Src/ConfigMain.cpp +++ b/Source/Core/DolphinWX/Src/ConfigMain.cpp @@ -56,8 +56,6 @@ EVT_CHECKBOX(ID_INTERFACE_HIDECURSOR, CConfigMain::CoreSettingsChanged) EVT_CHECKBOX(ID_INTERFACE_AUTOHIDECURSOR, CConfigMain::CoreSettingsChanged) #endif EVT_RADIOBOX(ID_INTERFACE_THEME, CConfigMain::CoreSettingsChanged) -EVT_CHECKBOX(ID_INTERFACE_WIIMOTE_LEDS, CConfigMain::CoreSettingsChanged) -EVT_CHECKBOX(ID_INTERFACE_WIIMOTE_SPEAKERS, CConfigMain::CoreSettingsChanged) EVT_CHOICE(ID_INTERFACE_LANG, CConfigMain::CoreSettingsChanged) EVT_CHECKBOX(ID_ALWAYS_HLE_BS2, CConfigMain::CoreSettingsChanged) @@ -229,8 +227,6 @@ void CConfigMain::InitializeGUIValues() AutoHideCursor->SetValue(SConfig::GetInstance().m_LocalCoreStartupParameter.bAutoHideCursor); HideCursor->SetValue(SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor); #endif - WiimoteStatusLEDs->SetValue(SConfig::GetInstance().m_LocalCoreStartupParameter.bWiiLeds); - WiimoteStatusSpeakers->SetValue(SConfig::GetInstance().m_LocalCoreStartupParameter.bWiiSpeakers); Theme->SetSelection(SConfig::GetInstance().m_LocalCoreStartupParameter.iTheme); // need redesign InterfaceLang->SetSelection(SConfig::GetInstance().m_InterfaceLanguage); @@ -289,8 +285,6 @@ void CConfigMain::InitializeGUITooltips() HideCursor->SetToolTip(wxT("This will always hide the cursor when it's over the rendering window.") wxT("\nIt can be convenient in a Wii game that already has a cursor.")); #endif - WiimoteStatusLEDs->SetToolTip(wxT("Show which wiimotes are connected in the statusbar.")); - WiimoteStatusSpeakers->SetToolTip(wxT("Show wiimote speaker status in the statusbar.")); InterfaceLang->SetToolTip(wxT("For the time being this will only change the text shown in") wxT("\nthe game list of PAL GC games.")); // Themes: Copyright notice @@ -352,11 +346,6 @@ void CConfigMain::CreateGUIControls() AutoHideCursor = new wxCheckBox(GeneralPage, ID_INTERFACE_AUTOHIDECURSOR, wxT("Auto")); HideCursor = new wxCheckBox(GeneralPage, ID_INTERFACE_HIDECURSOR, wxT("Always")); #endif - // Wiimote status in statusbar - wxStaticText *WiimoteStatusText = new wxStaticText(GeneralPage, ID_INTERFACE_WIIMOTE_TEXT, wxT("Show wiimote status:"), wxDefaultPosition, wxDefaultSize); - WiimoteStatusLEDs = new wxCheckBox(GeneralPage, ID_INTERFACE_WIIMOTE_LEDS, wxT("LEDs"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); - WiimoteStatusSpeakers = new wxCheckBox(GeneralPage, ID_INTERFACE_WIIMOTE_SPEAKERS, wxT("Speakers"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); - // Interface Language // At the moment this only changes the language displayed in m_gamelistctrl // If someone wants to control the whole GUI's language, it should be set here too @@ -396,11 +385,6 @@ void CConfigMain::CreateGUIControls() sHideCursor->Add(HideCursor, 0, wxLEFT, 5); sbInterface->Add(sHideCursor, 0, wxALL, 5); #endif - wxBoxSizer *sWiimoteStatus = new wxBoxSizer(wxHORIZONTAL); - sWiimoteStatus->Add(WiimoteStatusText); - sWiimoteStatus->Add(WiimoteStatusLEDs, 0, wxLEFT, 5); - sWiimoteStatus->Add(WiimoteStatusSpeakers, 0, wxLEFT, 5); - sbInterface->Add(sWiimoteStatus, 0, wxALL, 5); sbInterface->Add(Theme, 0, wxEXPAND | wxALL, 5); wxBoxSizer *sInterfaceLanguage = new wxBoxSizer(wxHORIZONTAL); sInterfaceLanguage->Add(InterfaceLangText, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); @@ -725,12 +709,6 @@ void CConfigMain::CoreSettingsChanged(wxCommandEvent& event) SConfig::GetInstance().m_LocalCoreStartupParameter.iTheme = Theme->GetSelection(); main_frame->InitBitmaps(); break; - case ID_INTERFACE_WIIMOTE_LEDS: - SConfig::GetInstance().m_LocalCoreStartupParameter.bWiiLeds = WiimoteStatusLEDs->IsChecked(); - break; - case ID_INTERFACE_WIIMOTE_SPEAKERS: - SConfig::GetInstance().m_LocalCoreStartupParameter.bWiiSpeakers = WiimoteStatusSpeakers->IsChecked(); - break; case ID_INTERFACE_LANG: SConfig::GetInstance().m_InterfaceLanguage = (INTERFACE_LANGUAGE)InterfaceLang->GetSelection(); bRefreshList = true; diff --git a/Source/Core/DolphinWX/Src/ConfigMain.h b/Source/Core/DolphinWX/Src/ConfigMain.h index 19fbceddee..a647f299bf 100644 --- a/Source/Core/DolphinWX/Src/ConfigMain.h +++ b/Source/Core/DolphinWX/Src/ConfigMain.h @@ -52,7 +52,6 @@ private: #if wxUSE_TIMER && defined _WIN32 wxCheckBox* HideCursor, *AutoHideCursor; #endif - wxCheckBox* WiimoteStatusLEDs, * WiimoteStatusSpeakers; wxChoice* InterfaceLang; wxChoice* Framelimit; wxRadioBox* Theme; @@ -175,7 +174,6 @@ private: #if wxUSE_TIMER && defined _WIN32 ID_INTERFACE_HIDECURSOR_TEXT, ID_INTERFACE_HIDECURSOR, ID_INTERFACE_AUTOHIDECURSOR, #endif - ID_INTERFACE_WIIMOTE_TEXT, ID_INTERFACE_WIIMOTE_LEDS, ID_INTERFACE_WIIMOTE_SPEAKERS, ID_INTERFACE_LANG_TEXT, ID_INTERFACE_LANG, ID_INTERFACE_THEME, ID_FRAMELIMIT_TEXT, ID_FRAMELIMIT, diff --git a/Source/Core/DolphinWX/Src/Frame.cpp b/Source/Core/DolphinWX/Src/Frame.cpp index f038f0926b..333c5d4f46 100644 --- a/Source/Core/DolphinWX/Src/Frame.cpp +++ b/Source/Core/DolphinWX/Src/Frame.cpp @@ -173,7 +173,7 @@ CPanel::CPanel( main_frame->bNoWiimoteMsg = false; else { - // The Wiimote has been disconnect, we offer reconnect here + // The Wiimote has been disconnected, we offer reconnect here wxMessageDialog *dlg = new wxMessageDialog( this, wxString::Format(wxT("Wiimote %i has been disconnected by system.\n") @@ -321,7 +321,6 @@ CFrame::CFrame(wxFrame* parent, , g_pCodeWindow(NULL) , m_MenuBar(NULL) , bRenderToMain(false), bNoWiimoteMsg(false) - , HaveLeds(false), HaveSpeakers(false) , m_ToolBar(NULL), m_ToolBarDebug(NULL), m_ToolBarAui(NULL) , bFloatLogWindow(false), bFloatConsoleWindow(false) , m_pStatusBar(NULL), m_GameListCtrl(NULL), m_Panel(NULL) @@ -523,10 +522,54 @@ void CFrame::OnQuit(wxCommandEvent& WXUNUSED (event)) Close(true); } +#if defined HAVE_X11 && HAVE_X11 +void CFrame::X11_SendClientEvent(const char *message) +{ + XEvent event; + Display *dpy = (Display *)Core::GetWindowHandle(); + Window win = *(Window *)Core::GetXWindow(); + + // Init X event structure for client message + event.xclient.type = ClientMessage; + event.xclient.format = 32; + event.xclient.data.l[0] = XInternAtom(dpy, message, False); + + // Send the event + if (!XSendEvent(dpy, win, False, False, &event)) + ERROR_LOG(VIDEO, "Failed to send message %s to the emulator window.\n", message); +} + +void X11_SendKeyEvent(int key) +{ + XEvent event; + Display *dpy = (Display *)Core::GetWindowHandle(); + Window win = *(Window *)Core::GetXWindow(); + + // Init X event structure for key press event + event.xkey.type = KeyPress; + // WARNING: This works for '3' to '7'. If in the future other keys are needed + // convert with InputCommon::wxCharCodeWXToX from X11InputBase.cpp. + event.xkey.keycode = XKeysymToKeycode(dpy, key); + + // Send the event + if (!XSendEvent(dpy, win, False, False, &event)) + ERROR_LOG(VIDEO, "Failed to send key press event to the emulator window.\n"); +} +#endif + // -------- // Events void CFrame::OnActive(wxActivateEvent& event) { +#if defined(HAVE_X11) && HAVE_X11 && defined(HAVE_GTK2) && HAVE_GTK2 && defined(wxGTK) + if (Core::GetState() == Core::CORE_RUN || Core::GetState() == Core::CORE_PAUSE) + { + if (event.GetActive()) + X11_SendClientEvent("FOCUSIN"); + else + X11_SendClientEvent("FOCUSOUT"); + } +#endif event.Skip(); } @@ -582,18 +625,21 @@ void CFrame::OnMove(wxMoveEvent& event) SConfig::GetInstance().m_LocalCoreStartupParameter.iPosX = GetPosition().x; SConfig::GetInstance().m_LocalCoreStartupParameter.iPosY = GetPosition().y; } + void CFrame::OnResize(wxSizeEvent& event) { event.Skip(); SConfig::GetInstance().m_LocalCoreStartupParameter.iWidth = GetSize().GetWidth(); SConfig::GetInstance().m_LocalCoreStartupParameter.iHeight = GetSize().GetHeight(); - - DoMoveIcons(); // In FrameWiimote.cpp } void CFrame::OnResizeAll(wxSizeEvent& event) { event.Skip(); +#if defined(HAVE_X11) && HAVE_X11 && defined(HAVE_GTK2) && HAVE_GTK2 && defined(wxGTK) + if (Core::GetState() == Core::CORE_RUN || Core::GetState() == Core::CORE_PAUSE) + X11_SendClientEvent("RESIZE"); +#endif //wxWindow * Win = (wxWindow*)event.GetEventObject(); //NOTICE_LOG(CONSOLE, "OnResizeAll: %i", (HWND)Win->GetHWND()); } @@ -649,11 +695,17 @@ void CFrame::OnHostMessage(wxCommandEvent& event) } break; #if defined(HAVE_X11) && HAVE_X11 + case WM_USER_CREATE: + bRenderToMain = true; + break; + case TOGGLE_FULLSCREEN: + DoFullscreen(!IsFullScreen()); + break; case WM_USER_STOP: - main_frame->DoStop(); + DoStop(); break; case WM_USER_PAUSE: - main_frame->OnPlay(event); + DoPause(); break; #endif } @@ -761,8 +813,14 @@ void CFrame::OnKeyDown(wxKeyEvent& event) { PostMessage((HWND)Core::GetWindowHandle(), WM_USER, WM_USER_KEYDOWN, event.GetKeyCode()); } +#elif defined(HAVE_X11) && HAVE_X11 && defined(HAVE_GTK2) && HAVE_GTK2 && defined(wxGTK) + if (event.GetKeyCode() >= '3' && event.GetKeyCode() <= '7') // Send this to the video plugin + { + X11_SendKeyEvent(event.GetKeyCode()); + } #endif + // Send the keyboard status to the Input plugin if(Core::GetState() != Core::CORE_UNINITIALIZED) CPluginManager::GetInstance().GetPad(0)->PAD_Input(event.GetKeyCode(), 1); // 1 = Down @@ -910,66 +968,48 @@ wxAuiNotebook* CFrame::CreateEmptyNotebook() return NB; } -#if defined HAVE_X11 && HAVE_X11 -void X11_ShowFullScreen(bool bF) -{ - XEvent event; - Display *dpy = (Display *)Core::GetWindowHandle(); - Window win = *(Window *)Core::GetXWindow(); - - // Init X event structure for TOGGLE_FULLSCREEN client message - event.xclient.type = ClientMessage; - event.xclient.format = 32; - event.xclient.data.l[0] = XInternAtom(dpy, "TOGGLE_FULLSCREEN", False);; - - // Send the event - if (!XSendEvent(dpy, win, False, False, &event)) - { - ERROR_LOG(VIDEO, "Failed to switch fullscreen/windowed mode.\n"); - } -} -#endif - void CFrame::DoFullscreen(bool bF) { -#if defined HAVE_X11 && HAVE_X11 - if ((Core::GetState() == Core::CORE_RUN)) - X11_ShowFullScreen(bF); -#endif // Only switch this to fullscreen if we're rendering to main AND if we're running a game // plus if a modal dialog is open, this will still process the keyboard events, and may cause // the main window to become unresponsive, so we have to avoid that. - if ((bRenderToMain && Core::GetState() == Core::CORE_RUN)) + if ((Core::GetState() == Core::CORE_RUN) || (Core::GetState() == Core::CORE_PAUSE)) { - ShowFullScreen(bF); + if (bRenderToMain) + { + ShowFullScreen(bF); - if (bF) - { - // Save the current mode before going to fullscreen - AuiCurrent = m_Mgr->SavePerspective(); - m_Mgr->LoadPerspective(AuiFullscreen, true); - } - else - { - // Restore saved perspective - m_Mgr->LoadPerspective(AuiCurrent, true); - } + if (bF) + { + // Save the current mode before going to fullscreen + AuiCurrent = m_Mgr->SavePerspective(); + m_Mgr->LoadPerspective(AuiFullscreen, true); + } + else + { + // Restore saved perspective + m_Mgr->LoadPerspective(AuiCurrent, true); + } - // Show the cursor again, in case it was hidden - if (IsFullScreen()) - { - #ifdef _WIN32 - MSWSetCursor(true); - #endif - } - } #ifdef _WIN32 - else // Post the message to the separate rendering window which will then handle it. - { - BringWindowToTop((HWND)Core::GetWindowHandle()); - PostMessage((HWND)Core::GetWindowHandle(), WM_USER, TOGGLE_FULLSCREEN, 0); - } + // Show the cursor again, in case it was hidden + if (IsFullScreen()) + { + MSWSetCursor(true); + } #endif + } +#ifdef _WIN32 + else // Post the message to the separate rendering window which will then handle it. + { + BringWindowToTop((HWND)Core::GetWindowHandle()); + PostMessage((HWND)Core::GetWindowHandle(), WM_USER, TOGGLE_FULLSCREEN, 0); + } +#elif defined HAVE_X11 && HAVE_X11 + else // Send the event to the separate rendering window which will then handle it. + X11_SendClientEvent("TOGGLE_FULLSCREEN"); +#endif + } } // Debugging, show loose windows @@ -1060,4 +1100,4 @@ void CFrame::ListTopWindows() j++; } NOTICE_LOG(CONSOLE, "\n"); -} \ No newline at end of file +} diff --git a/Source/Core/DolphinWX/Src/Frame.h b/Source/Core/DolphinWX/Src/Frame.h index 6d228a8618..c4e21c1a06 100644 --- a/Source/Core/DolphinWX/Src/Frame.h +++ b/Source/Core/DolphinWX/Src/Frame.h @@ -64,6 +64,8 @@ class CFrame : public wxFrame { #ifdef _WIN32 return(m_Panel->GetHandle()); + #elif defined(HAVE_X11) && HAVE_X11 + return m_Panel; #else return this; #endif @@ -91,23 +93,6 @@ class CFrame : public wxFrame void OnCustomHostMessage(int Id); void StartGame(const std::string& filename); - // --------------------------------------- - // Wiimote leds - // -------------------- - void ModifyStatusBar(); - void CreateDestroy(int Case); - void CreateLeds(); void CreateSpeakers(); - void UpdateLeds(); void UpdateSpeakers(); - wxBitmap CreateBitmapForLeds(bool On); - wxBitmap CreateBitmapForSpeakers(int BitmapType, bool On); - void DoMoveIcons(); void MoveLeds(); void MoveSpeakers(); - bool HaveLeds; bool HaveSpeakers; - - wxStaticBitmap *m_StatBmp[7]; - u8 g_Leds[4]; u8 g_Leds_[4]; - u8 g_Speakers[3]; u8 g_Speakers_[3]; - // --------------- - // AUI wxAuiManager *m_Mgr; wxAuiToolBar *m_ToolBar, *m_ToolBarDebug, *m_ToolBarAui; @@ -233,14 +218,6 @@ class CFrame : public wxFrame THEMES_MAX }; - enum WiimoteBitmaps // Wiimote speaker bitmaps - { - CREATELEDS, - DESTROYLEDS, - CREATESPEAKERS, - DESTROYSPEAKERS - }; - wxBitmap m_Bitmaps[EToolbar_Max]; wxBitmap m_BitmapsMenu[EToolbar_Max]; @@ -326,6 +303,9 @@ class CFrame : public wxFrame void OnGameListCtrl_ItemActivated(wxListEvent& event); void DoFullscreen(bool _F); +#if defined HAVE_X11 && HAVE_X11 + void X11_SendClientEvent(const char *message); +#endif // MenuBar // File - Drive diff --git a/Source/Core/DolphinWX/Src/FrameTools.cpp b/Source/Core/DolphinWX/Src/FrameTools.cpp index f4eaae698b..06d5a08641 100644 --- a/Source/Core/DolphinWX/Src/FrameTools.cpp +++ b/Source/Core/DolphinWX/Src/FrameTools.cpp @@ -470,6 +470,7 @@ bool game_loading = false; // 3. Boot last selected game void CFrame::BootGame(const std::string& filename) { + bool success = false; SCoreStartupParameter& StartUp = SConfig::GetInstance().m_LocalCoreStartupParameter; if (Core::GetState() != Core::CORE_UNINITIALIZED) @@ -479,23 +480,23 @@ void CFrame::BootGame(const std::string& filename) // Start the selected ISO, or try one of the saved paths. // If all that fails, ask to add a dir and don't boot if (!filename.empty()) - BootManager::BootCore(filename); + success = BootManager::BootCore(filename); else if (m_GameListCtrl->GetSelectedISO() != NULL) { if (m_GameListCtrl->GetSelectedISO()->IsValid()) - BootManager::BootCore(m_GameListCtrl->GetSelectedISO()->GetFileName()); + success = BootManager::BootCore(m_GameListCtrl->GetSelectedISO()->GetFileName()); } else if (!StartUp.m_strDefaultGCM.empty() && wxFileExists(wxString(StartUp.m_strDefaultGCM.c_str(), wxConvUTF8))) { - BootManager::BootCore(StartUp.m_strDefaultGCM); + success = BootManager::BootCore(StartUp.m_strDefaultGCM); } else { if (!SConfig::GetInstance().m_LastFilename.empty() && wxFileExists(wxString(SConfig::GetInstance().m_LastFilename.c_str(), wxConvUTF8))) { - BootManager::BootCore(SConfig::GetInstance().m_LastFilename); + success = BootManager::BootCore(SConfig::GetInstance().m_LastFilename); } else { @@ -506,6 +507,12 @@ void CFrame::BootGame(const std::string& filename) return; } } + if (!success) + { + game_loading = false; + m_GameListCtrl->Enable(); + m_GameListCtrl->Show(); + } } // Open file to boot @@ -546,13 +553,7 @@ void CFrame::DoOpen(bool Boot) { if (!fileChosen) return; - BootManager::BootCore(std::string(path.mb_str())); - // Game has been started, hide the game list - if (m_GameListCtrl->IsShown()) - { - m_GameListCtrl->Disable(); - m_GameListCtrl->Hide(); - } + StartGame(std::string(path.mb_str())); } else { @@ -629,16 +630,11 @@ void CFrame::OnPlay(wxCommandEvent& WXUNUSED (event)) wxThread::Sleep(20); g_pCodeWindow->JumpToAddress(PC); g_pCodeWindow->Update(); + // Update toolbar with Play/Pause status + UpdateGUI(); } else - { - if (Core::GetState() == Core::CORE_RUN) - Core::SetState(Core::CORE_PAUSE); - else - Core::SetState(Core::CORE_RUN); - } - // Update toolbar with Play/Pause status - UpdateGUI(); + DoPause(); } else // Core is uninitialized, start the game @@ -666,7 +662,7 @@ void CFrame::StartGame(const std::string& filename) void CFrame::OnBootDrive(wxCommandEvent& event) { - BootManager::BootCore(drives[event.GetId()-IDM_DRIVE1].c_str()); + StartGame(drives[event.GetId()-IDM_DRIVE1]); } @@ -691,7 +687,20 @@ void CFrame::OnScreenshot(wxCommandEvent& WXUNUSED (event)) // Pause the emulation void CFrame::DoPause() { - Core::SetState(Core::CORE_PAUSE); + if (Core::GetState() == Core::CORE_RUN) + { +#if defined(HAVE_X11) && HAVE_X11 + X11_SendClientEvent("PAUSE"); +#endif + Core::SetState(Core::CORE_PAUSE); + } + else + { +#if defined(HAVE_X11) && HAVE_X11 + X11_SendClientEvent("RESUME"); +#endif + Core::SetState(Core::CORE_RUN); + } UpdateGUI(); } diff --git a/Source/Core/DolphinWX/Src/FrameWiimote.cpp b/Source/Core/DolphinWX/Src/FrameWiimote.cpp deleted file mode 100644 index b11d824954..0000000000 --- a/Source/Core/DolphinWX/Src/FrameWiimote.cpp +++ /dev/null @@ -1,485 +0,0 @@ -// Copyright (C) 2003 Dolphin Project. - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, version 2.0. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License 2.0 for more details. - -// A copy of the GPL 2.0 should have been included with the program. -// If not, see http://www.gnu.org/licenses/ - -// Official SVN repository and contact information can be found at -// http://code.google.com/p/dolphin-emu/ - - - -// Include -// ------------- -#include "Globals.h" -#include "Frame.h" -#include "FileUtil.h" -#include "StringUtil.h" - -#include "GameListCtrl.h" -#include "BootManager.h" - -#include "Common.h" -#include "Setup.h" -#include "ConfigManager.h" -#include "Core.h" -#include "State.h" -#include "ConfigMain.h" -#include "PluginManager.h" -#include "MemcardManager.h" -#include "CheatsWindow.h" -#include "AboutDolphin.h" - -#include - - - -namespace WiimoteLeds -{ - int LED_SIZE_X = 8; - int LED_SIZE_Y = 8; - int SPEAKER_SIZE_X = 8; - int SPEAKER_SIZE_Y = 8; - - int ConnectionStatusWidth = 103; // These widths need to be revised, for vista at least - int ConnectionStatusOnlyAdj = 7; - int RightmostMargin = 6; - int SpIconMargin = 11; - int LedIconMargin = 11; - - // The necessary recording status width, allow Frame to be at last of the form 100,000 - #ifdef RERECORDING - static const int RerecordingStatusWidth = 340; - #endif - - // Leds only - static const int LdWidthsOn[] = - { - -1, - #ifdef RERECORDING - RerecordingStatusWidth, - #endif - ConnectionStatusWidth, - (LedIconMargin + LED_SIZE_X) * 4 + RightmostMargin - }; - static const int StylesFieldOn[] = { wxSB_NORMAL, wxSB_NORMAL, wxSB_NORMAL }; - - // Speakers only - static const int SpWidthsOn[] = - { - -1, - #ifdef RERECORDING - RerecordingStatusWidth, - #endif - ConnectionStatusWidth, - ( SpIconMargin + SPEAKER_SIZE_X ) * 3 + RightmostMargin - }; - static const int SpStylesFieldOn[] = { wxSB_NORMAL, - #ifdef RERECORDING - wxSB_NORMAL, - #endif - wxSB_NORMAL, wxSB_NORMAL }; - - // Both - static const int LdSpWidthsOn[] = - { - -1, - #ifdef RERECORDING - RerecordingStatusWidth, - #endif - ConnectionStatusWidth, - (SpIconMargin + SPEAKER_SIZE_X) * 3, - (LedIconMargin + LED_SIZE_X) * 4 + RightmostMargin - }; - static const int LdSpStylesFieldOn[] = { wxSB_NORMAL, - #ifdef RERECORDING - wxSB_NORMAL, - #endif - wxSB_NORMAL, wxSB_NORMAL }; - - // Only the Wiimote connection Status - static const int WidthsOff[] = - { - -1, - #ifdef RERECORDING - RerecordingStatusWidth, - #endif - ConnectionStatusWidth + ConnectionStatusOnlyAdj + RightmostMargin - }; - static const int StylesFieldOff[] = { wxSB_NORMAL, - #ifdef RERECORDING - wxSB_NORMAL, - #endif - wxSB_NORMAL }; - - // GC mode - static const int WidthsOffGC[] = { -1 - #ifdef RERECORDING - , RerecordingStatusWidth - #endif - }; - static const int StylesFieldOffGC[] = { wxSB_NORMAL - #ifdef RERECORDING - , wxSB_NORMAL - #endif - }; -}; - -// ======================================================= -// Modify status bar -// ------------- -void CFrame::ModifyStatusBar() -{ - // Get settings - bool LedsOn = SConfig::GetInstance().m_LocalCoreStartupParameter.bWiiLeds; - bool SpeakersOn = SConfig::GetInstance().m_LocalCoreStartupParameter.bWiiSpeakers; - - // Don't use this for GC games, or before a game is loaded - if(!SConfig::GetInstance().m_LocalCoreStartupParameter.bWii) - { LedsOn = false; SpeakersOn = false; } - - // Declarations - int Fields = 0; - int *Widths = 0; - int *StylesFields = 0; - - // --------------------------------------- - // Leds only - // ------------- - if(LedsOn && !SpeakersOn) - { - Fields = 3; - Widths = (int*)WiimoteLeds::LdWidthsOn; - StylesFields = (int*)WiimoteLeds::StylesFieldOn; - } - // --------------------------------------- - // Speaker only - // ------------- - else if(!LedsOn && SpeakersOn) - { - Fields = 3; - Widths = (int*)WiimoteLeds::SpWidthsOn; - StylesFields = (int*)WiimoteLeds::SpStylesFieldOn; - } - // --------------------------------------- - // Both on - // ------------- - else if(LedsOn && SpeakersOn) - { - Fields = 4; - Widths = (int*)WiimoteLeds::LdSpWidthsOn; - StylesFields = (int*)WiimoteLeds::LdSpStylesFieldOn; - } - // --------------------------------------- - // Both off - // ------------- - else if(!LedsOn && !SpeakersOn) - { - Fields = 2; - Widths = (int*)WiimoteLeds::WidthsOff; - StylesFields = (int*)WiimoteLeds::StylesFieldOff; - - // Maybe we should even go down to one field - if(!SConfig::GetInstance().m_LocalCoreStartupParameter.bWii) - { - Fields = 1; - Widths = (int*)WiimoteLeds::WidthsOffGC; - StylesFields = (int*)WiimoteLeds::StylesFieldOffGC; - } - } - - // Add a filed for the rerecording status - #ifdef RERECORDING - Fields++; - #endif - - // Update the settings - m_pStatusBar->SetFieldsCount(Fields); - m_pStatusBar->SetStatusWidths(Fields, Widths); - m_pStatusBar->SetStatusStyles(Fields, StylesFields); - - /* Destroy and create all, and check for HaveLeds and HaveSpeakers in case we have - gotten a confirmed on or off setting, in which case we don't do anything */ - if(!LedsOn && HaveLeds) CreateDestroy(DESTROYLEDS); - if(!SpeakersOn && HaveSpeakers) CreateDestroy(DESTROYSPEAKERS); - if(LedsOn && !HaveLeds) CreateDestroy(CREATELEDS); - if(SpeakersOn && !HaveSpeakers) CreateDestroy(CREATESPEAKERS); - - DoMoveIcons(); - m_pStatusBar->Refresh(); // avoid small glitches that can occur -} - - -// ======================================================= -// Create and destroy leds and speakers icons -// ------------- -void CFrame::CreateDestroy(int Case) -{ - switch(Case) - { - case CREATELEDS: - { - CreateLeds(); - UpdateLeds(); - HaveLeds = true; - break; - } - case DESTROYLEDS: - { - for(int i = 0; i < 4; i++) - { - m_StatBmp[i]->Destroy(); - } - HaveLeds = false; - break; - } - case CREATESPEAKERS: - { - CreateSpeakers(); - HaveSpeakers = true; - break; - } - - case DESTROYSPEAKERS: - { - for(int i = 4; i < 7; i++) - { - m_StatBmp[i]->Destroy(); - } - HaveSpeakers = false; - break; - } - } // end of switch - - DoMoveIcons(); -} -// ============= - - -// ======================================================= -// Create and update leds -// ------------- -void CFrame::CreateLeds() -{ - // Begin with blank ones - memset(&g_Leds, 0, sizeof(g_Leds)); - for(int i = 0; i < 4; i++) - { - m_StatBmp[i] = new wxStaticBitmap(m_pStatusBar, wxID_ANY, - CreateBitmapForLeds(g_Leds[i] == 1)); - } -} -// Update leds -void CFrame::UpdateLeds() -{ - for(int i = 0; i < 4; i++) - { - m_StatBmp[i]->SetBitmap(CreateBitmapForLeds(g_Leds[i] != 0)); - } -} -// ============== - - -// ======================================================= -// Create and speaker icons -// ------------- -void CFrame::CreateSpeakers() -{ - // Begin with blank ones - memset(&g_Speakers, 0, sizeof(g_Speakers)); - memset(&g_Speakers_, 0, sizeof(g_Speakers_)); - for(int i = 0; i < 3; i++) - { - m_StatBmp[i+4] = new wxStaticBitmap(m_pStatusBar, wxID_ANY, - CreateBitmapForSpeakers(i, g_Speakers[i] != 0)); - } -} -// Update icons -void CFrame::UpdateSpeakers() -{ - /*if(!SConfig::GetInstance().m_LocalCoreStartupParameter.bNTSC) - { PanicAlert("Not NTSC");} - - if(!SConfig::GetInstance().m_LocalCoreStartupParameter.bWii) - { PanicAlert("Not Wii");}*/ - for(int i = 0; i < 3; i++) - { - m_StatBmp[i+4]->SetBitmap(CreateBitmapForSpeakers(i, g_Speakers[i] != 0)); - } -} -// ============== - - -// ======================================================= -// Create the Leds bitmap -// ------------- -wxBitmap CFrame::CreateBitmapForLeds(bool On) -{ - wxBitmap bitmap(WiimoteLeds::LED_SIZE_X, WiimoteLeds::LED_SIZE_Y); - wxMemoryDC dc; - dc.SelectObject(bitmap); - - // Set outline and fill colors - wxBrush LightBlueBrush(_T("#0383f0")); - wxPen LightBluePen(_T("#80c5fd")); - wxPen LightGrayPen(_T("#909090")); - dc.SetPen(On ? LightBluePen : LightGrayPen); - dc.SetBrush(On ? LightBlueBrush : *wxWHITE_BRUSH); - - dc.Clear(); - dc.DrawRectangle(0, 0, WiimoteLeds::LED_SIZE_X, WiimoteLeds::LED_SIZE_Y); - dc.SelectObject(wxNullBitmap); - return bitmap; -} - - -// ======================================================= -// Create the Speaker bitmap -// ------------- -wxBitmap CFrame::CreateBitmapForSpeakers(int BitmapType, bool On) -{ - wxBitmap bitmap(WiimoteLeds::LED_SIZE_X, WiimoteLeds::LED_SIZE_Y); - wxMemoryDC dc; - dc.SelectObject(bitmap); - wxBrush BackgroundGrayBrush(_T("#ece9d8")); // the right color in windows - - switch(BitmapType) - { - case 0: // Speaker on - { - // Set outline and fill colors - dc.SetPen(On ? *wxMEDIUM_GREY_PEN : *wxMEDIUM_GREY_PEN); - dc.SetBrush(On ? *wxGREEN_BRUSH : *wxWHITE_BRUSH); - dc.SetBackground(BackgroundGrayBrush); - dc.Clear(); - dc.DrawEllipse(0, 0, WiimoteLeds::SPEAKER_SIZE_X, WiimoteLeds::SPEAKER_SIZE_Y); - dc.SelectObject(wxNullBitmap); - return bitmap; - } - case 1: // Speaker unmuted - { - // Set outline and fill colors - dc.SetPen(On ? *wxMEDIUM_GREY_PEN : *wxMEDIUM_GREY_PEN); - dc.SetBrush(On ? *wxBLUE_BRUSH : *wxWHITE_BRUSH); - dc.SetBackground(BackgroundGrayBrush); - dc.Clear(); - dc.DrawEllipse(0, 0, WiimoteLeds::SPEAKER_SIZE_X, WiimoteLeds::SPEAKER_SIZE_Y); - dc.SelectObject(wxNullBitmap); - return bitmap; - } - case 2: // Speaker activity - { - // Set outline and fill colors - dc.SetPen(On ? *wxMEDIUM_GREY_PEN : *wxMEDIUM_GREY_PEN); - dc.SetBrush(On ? *wxGREEN_BRUSH : *wxWHITE_BRUSH); - dc.SetBackground(BackgroundGrayBrush); - dc.Clear(); - dc.DrawEllipse(0, 0, WiimoteLeds::SPEAKER_SIZE_X, WiimoteLeds::SPEAKER_SIZE_Y); - dc.SelectObject(wxNullBitmap); - return bitmap; - } - } - - return bitmap; -} - - -// ======================================================= -// Move the bitmaps -// ------------- -void CFrame::DoMoveIcons() -{ - if (!m_pStatusBar) return; - - if(HaveLeds) MoveLeds(); - if(HaveSpeakers) MoveSpeakers(); - - // If there is not room for the led icons hide them - if(m_pStatusBar->GetFieldsCount() >= 2 && HaveLeds) - { - wxRect Rect; - #ifdef RERECORDING - m_pStatusBar->GetFieldRect((HaveLeds && HaveSpeakers) ? 4 : 3, Rect); - #else - m_pStatusBar->GetFieldRect((HaveLeds && HaveSpeakers) ? 3 : 2, Rect); - #endif - if(Rect.GetWidth() < 20) - for (int i = 0; i < 4; i++) m_StatBmp[i]->Hide(); - else // if(!m_StatBmp[0]->IsShown()) - for (int i = 0; i < 4; i++) m_StatBmp[i]->Show(); - //INFO_LOG(CONSOLE, "LED: %i ", Rect.GetWidth()); - } - - // If there is not room for the speaker icons hide them - if(m_pStatusBar->GetFieldsCount() >= 2 && HaveSpeakers) - { - wxRect Rect; - #ifdef RERECORDING - m_pStatusBar->GetFieldRect(3, Rect); - #else - m_pStatusBar->GetFieldRect(2, Rect); - #endif - if(Rect.GetWidth() < 20) - for(int i = 0; i < 3; i++) m_StatBmp[i + 4]->Hide(); - else // if(!m_StatBmp[4]->IsShown()) - for (int i = 0; i < 3; i++) m_StatBmp[i + 4]->Show(); - //INFO_LOG(CONSOLE, "Speaker: %i\n", Rect.GetWidth()); - } -} - -void CFrame::MoveLeds() -{ - wxRect Rect; - // Get the bitmap field coordinates - #ifdef RERECORDING - m_pStatusBar->GetFieldRect((HaveLeds && HaveSpeakers) ? 4 : 3, Rect); - #else - m_pStatusBar->GetFieldRect((HaveLeds && HaveSpeakers) ? 3 : 2, Rect); - #endif - wxSize Size = m_StatBmp[0]->GetSize(); // Get the bitmap size - - //wxMessageBox(wxString::Format("%i", Rect.x)); - int x = Rect.x + 10; - int Dist = WiimoteLeds::LED_SIZE_X + 7; - int y = Rect.y + (Rect.height - Size.y) / 2; - - for(int i = 0; i < 4; i++) - { - if(i > 0) x = m_StatBmp[i-1]->GetPosition().x + Dist; - m_StatBmp[i]->Move(x, y); - } -} - -void CFrame::MoveSpeakers() -{ - wxRect Rect; - // Get the bitmap field coordinates - #ifdef RERECORDING - m_pStatusBar->GetFieldRect(3, Rect); - #else - m_pStatusBar->GetFieldRect(2, Rect); - #endif - - // Get the actual bitmap size, currently it's the same as SPEAKER_SIZE_Y - wxSize Size = m_StatBmp[4]->GetSize(); - - //wxMessageBox(wxString::Format("%i", Rect.x)); - int x = Rect.x + 9; - int Dist = WiimoteLeds::SPEAKER_SIZE_X + 7; - int y = Rect.y + (Rect.height - Size.y) / 2; - - for(int i = 0; i < 3; i++) - { - if(i > 0) x = m_StatBmp[i-1+4]->GetPosition().x + Dist; - m_StatBmp[i + 4]->Move(x, y); - } -} -// ============== diff --git a/Source/Core/DolphinWX/Src/Main.cpp b/Source/Core/DolphinWX/Src/Main.cpp index 8d622b617a..8be3a8dc70 100644 --- a/Source/Core/DolphinWX/Src/Main.cpp +++ b/Source/Core/DolphinWX/Src/Main.cpp @@ -533,6 +533,8 @@ void Host_Message(int Id) #if defined(HAVE_X11) && HAVE_X11 switch(Id) { + case WM_USER_CREATE: + case TOGGLE_FULLSCREEN: case WM_USER_STOP: case WM_USER_PAUSE: { @@ -613,55 +615,12 @@ void Host_UpdateBreakPointView() } } - - -// Update Wiimote status bar - -void Host_UpdateLeds(int led_bits) -{ - // Convert it to a simpler byte format - main_frame->g_Leds[0] = led_bits >> 0; - main_frame->g_Leds[1] = led_bits >> 1; - main_frame->g_Leds[2] = led_bits >> 2; - main_frame->g_Leds[3] = led_bits >> 3; - - main_frame->UpdateLeds(); -} - -void Host_UpdateSpeakerStatus(int index, int speaker_bits) -{ - main_frame->g_Speakers[index] = speaker_bits; - main_frame->UpdateSpeakers(); -} - -void Host_UpdateStatus() -{ - // Debugging - //std::string Tmp = ArrayToString(main_frame->g_Speakers, sizeof(main_frame->g_Speakers)); - //std::string Tmp2 = ArrayToString(main_frame->g_Speakers_, sizeof(main_frame->g_Speakers_)); - //LOGV(CONSOLE, 0, "Tmp: %s", Tmp.c_str()); - //LOGV(CONSOLE, 0, "Tmp2: %s", Tmp2.c_str()); - // Don't do a lot of CreateBitmap() if we don't need to - if(memcmp(main_frame->g_Speakers_, main_frame->g_Speakers, - sizeof(main_frame->g_Speakers))) - { - // Turn off the activity light again - main_frame->g_Speakers[2] = 0; - main_frame->UpdateSpeakers(); - memcpy(main_frame->g_Speakers_, main_frame->g_Speakers, sizeof(main_frame->g_Speakers)); - } -} - - - void Host_UpdateMemoryView() {} - void Host_SetDebugMode(bool) {} - void Host_SetWaitCursor(bool enable) { #ifdef _WIN32 diff --git a/Source/Core/DolphinWX/Src/MainNoGUI.cpp b/Source/Core/DolphinWX/Src/MainNoGUI.cpp index 344cd4e1db..8bd017d960 100644 --- a/Source/Core/DolphinWX/Src/MainNoGUI.cpp +++ b/Source/Core/DolphinWX/Src/MainNoGUI.cpp @@ -32,6 +32,10 @@ #include #endif +#if defined HAVE_X11 && HAVE_X11 +#include +#endif + #if defined(HAVE_COCOA) && HAVE_COCOA #import "cocoaApp.h" #endif @@ -54,7 +58,48 @@ void Host_NotifyMapLoaded(){} void Host_ShowJitResults(unsigned int address){} -void Host_Message(int Id){} +#if defined(HAVE_X11) && HAVE_X11 +void X11_SendClientEvent(const char *message) +{ + XEvent event; + Display *dpy = (Display *)Core::GetWindowHandle(); + Window win = *(Window *)Core::GetXWindow(); + + // Init X event structure for client message + event.xclient.type = ClientMessage; + event.xclient.format = 32; + event.xclient.data.l[0] = XInternAtom(dpy, message, False); + + // Send the event + if (!XSendEvent(dpy, win, False, False, &event)) + ERROR_LOG(VIDEO, "Failed to send message %s to the emulator window.\n", message); +} +#endif + +Common::Event updateMainFrameEvent; +void Host_Message(int Id) +{ +#if defined(HAVE_X11) && HAVE_X11 + switch (Id) + { + case WM_USER_STOP: + updateMainFrameEvent.Set(); + break; + case WM_USER_PAUSE: + if (Core::GetState() == Core::CORE_RUN) + { + X11_SendClientEvent("PAUSE"); + Core::SetState(Core::CORE_PAUSE); + } + else + { + X11_SendClientEvent("RESUME"); + Core::SetState(Core::CORE_RUN); + } + break; + } +#endif +} void Host_UpdateLogDisplay(){} @@ -62,7 +107,6 @@ void Host_UpdateLogDisplay(){} void Host_UpdateDisasmDialog(){} -Common::Event updateMainFrameEvent; void Host_UpdateMainFrame() { updateMainFrameEvent.Set(); @@ -99,16 +143,6 @@ void Host_SysMessage(const char *fmt, ...) fprintf(stderr, "%s", msg); } -void Host_UpdateLeds(int led_bits) -{ -} -void Host_UpdateSpeakerStatus(int index, int speaker_bits) -{ -} -void Host_UpdateStatus() -{ -} - void Host_SetWiiMoteConnectionState(int _State) {} @@ -239,13 +273,23 @@ int main(int argc, char* argv[]) CPluginManager::GetInstance().ScanForPlugins(); +#if defined HAVE_X11 && HAVE_X11 + XInitThreads(); +#endif + if (BootManager::BootCore(bootFile)) //no use running the loop when booting fails { - while (PowerPC::GetState() != PowerPC::CPU_POWERDOWN) - { +#if defined(HAVE_X11) && HAVE_X11 + while (Core::GetState() == Core::CORE_UNINITIALIZED) updateMainFrameEvent.Wait(); - } + updateMainFrameEvent.Wait(); + Core::Stop(); +#else + while (PowerPC::GetState() != PowerPC::CPU_POWERDOWN) + updateMainFrameEvent.Wait(); +#endif } + updateMainFrameEvent.Shutdown(); CPluginManager::Shutdown(); SConfig::Shutdown(); diff --git a/Source/Core/DolphinWX/Src/SConscript b/Source/Core/DolphinWX/Src/SConscript index 2605c736fb..e5baf72fd1 100644 --- a/Source/Core/DolphinWX/Src/SConscript +++ b/Source/Core/DolphinWX/Src/SConscript @@ -23,7 +23,6 @@ if wxenv['HAVE_WX']: 'Frame.cpp', 'FrameAui.cpp', 'FrameTools.cpp', - 'FrameWiimote.cpp', 'LuaWindow.cpp', 'LogWindow.cpp', 'GameListCtrl.cpp', diff --git a/Source/PluginSpecs/pluginspecs_pad.h b/Source/PluginSpecs/pluginspecs_pad.h index 4a0ef29c6a..3c6f50ba13 100644 --- a/Source/PluginSpecs/pluginspecs_pad.h +++ b/Source/PluginSpecs/pluginspecs_pad.h @@ -35,6 +35,9 @@ typedef struct { HWND hWnd; #if defined HAVE_X11 && HAVE_X11 +#if defined(HAVE_GTK2) && HAVE_GTK2 + void *pPanel; +#endif void *pXWindow; #endif TLog pLog; diff --git a/Source/PluginSpecs/pluginspecs_video.h b/Source/PluginSpecs/pluginspecs_video.h index c11b8b4db7..ab0950901f 100644 --- a/Source/PluginSpecs/pluginspecs_video.h +++ b/Source/PluginSpecs/pluginspecs_video.h @@ -72,6 +72,9 @@ typedef struct { void *pWindowHandle; #if defined(HAVE_X11) && HAVE_X11 +#if defined(HAVE_GTK2) && HAVE_GTK2 + void *pPanel; +#endif void *pXWindow; #endif diff --git a/Source/PluginSpecs/pluginspecs_wiimote.h b/Source/PluginSpecs/pluginspecs_wiimote.h index f3900afef6..b473edfca7 100644 --- a/Source/PluginSpecs/pluginspecs_wiimote.h +++ b/Source/PluginSpecs/pluginspecs_wiimote.h @@ -20,6 +20,9 @@ typedef struct { HWND hWnd; #if defined HAVE_X11 && HAVE_X11 +#if defined(HAVE_GTK2) && HAVE_GTK2 + void *pPanel; +#endif void *pXWindow; #endif u32 ISOId; diff --git a/Source/Plugins/Plugin_GCPad/Src/ConfigBox.cpp b/Source/Plugins/Plugin_GCPad/Src/ConfigBox.cpp index 77bdbdb755..748ec6d7a4 100644 --- a/Source/Plugins/Plugin_GCPad/Src/ConfigBox.cpp +++ b/Source/Plugins/Plugin_GCPad/Src/ConfigBox.cpp @@ -129,10 +129,6 @@ GCPadConfigDialog::GCPadConfigDialog(wxWindow *parent, wxWindowID id, const wxSt #endif UpdateGUI(); - - wxTheApp->Connect(wxID_ANY, wxEVT_KEY_DOWN, // Keyboard - wxKeyEventHandler(GCPadConfigDialog::OnKeyDown), - (wxObject*)0, this); } GCPadConfigDialog::~GCPadConfigDialog() @@ -245,10 +241,7 @@ void GCPadConfigDialog::OnKeyDown(wxKeyEvent& event) SaveButtonMapping(ClickedButton->GetId(), XKey); #endif } - m_ButtonMappingTimer->Stop(); - GetButtonWaitingTimer = 0; - GetButtonWaitingID = 0; - ClickedButton = NULL; + EndGetButtons(); } } @@ -262,6 +255,10 @@ void GCPadConfigDialog::OnButtonClick(wxCommandEvent& event) if (m_ButtonMappingTimer->IsRunning()) return; + wxTheApp->Connect(wxID_ANY, wxEVT_KEY_DOWN, // Keyboard + wxKeyEventHandler(GCPadConfigDialog::OnKeyDown), + (wxObject*)0, this); + // Create the button object ClickedButton = (wxButton *)event.GetEventObject(); // Save old label so we can revert back diff --git a/Source/Plugins/Plugin_GCPad/Src/ConfigBox.h b/Source/Plugins/Plugin_GCPad/Src/ConfigBox.h index 2ac4e5ad98..6c9c1e4e06 100644 --- a/Source/Plugins/Plugin_GCPad/Src/ConfigBox.h +++ b/Source/Plugins/Plugin_GCPad/Src/ConfigBox.h @@ -235,6 +235,7 @@ class GCPadConfigDialog : public wxDialog void ToBlank(bool ToBlank, int Id); void DoGetButtons(int _GetId); + void EndGetButtons(); void SetButtonText(int id, const wxString &str); wxString GetButtonText(int id); }; diff --git a/Source/Plugins/Plugin_GCPad/Src/ConfigJoypad.cpp b/Source/Plugins/Plugin_GCPad/Src/ConfigJoypad.cpp index 074ada733c..383359ca84 100644 --- a/Source/Plugins/Plugin_GCPad/Src/ConfigJoypad.cpp +++ b/Source/Plugins/Plugin_GCPad/Src/ConfigJoypad.cpp @@ -208,10 +208,7 @@ void GCPadConfigDialog::DoGetButtons(int _GetId) { DEBUG_LOG(PAD, "Timer Stopped for Pad:%i _GetId:%i", GCMapping[m_Page].ID, _GetId); - m_ButtonMappingTimer->Stop(); - GetButtonWaitingTimer = 0; - GetButtonWaitingID = 0; - ClickedButton = NULL; + EndGetButtons(); } // If we got a bad button @@ -227,6 +224,17 @@ void GCPadConfigDialog::DoGetButtons(int _GetId) } } +void GCPadConfigDialog::EndGetButtons(void) +{ + wxTheApp->Disconnect(wxID_ANY, wxEVT_KEY_DOWN, // Keyboard + wxKeyEventHandler(GCPadConfigDialog::OnKeyDown), + (wxObject*)0, this); + m_ButtonMappingTimer->Stop(); + GetButtonWaitingTimer = 0; + GetButtonWaitingID = 0; + ClickedButton = NULL; +} + // Convert the 0x8000 range values to BoxW and BoxH for the plot void GCPadConfigDialog::Convert2Box(int &x) { diff --git a/Source/Plugins/Plugin_GCPad/Src/GCPad.cpp b/Source/Plugins/Plugin_GCPad/Src/GCPad.cpp index f583dc273c..40988afc70 100644 --- a/Source/Plugins/Plugin_GCPad/Src/GCPad.cpp +++ b/Source/Plugins/Plugin_GCPad/Src/GCPad.cpp @@ -658,12 +658,14 @@ bool IsFocus() return false; #elif defined HAVE_X11 && HAVE_X11 Window GLWin = *(Window *)g_PADInitialize->pXWindow; + bool bFocus = False; +#if defined(HAVE_GTK2) && HAVE_GTK2 && defined(wxGTK) + bFocus = (wxPanel *)g_PADInitialize->pPanel == wxWindow::FindFocus(); +#endif Window FocusWin; int Revert; XGetInputFocus(GCdisplay, &FocusWin, &Revert); - XWindowAttributes WinAttribs; - XGetWindowAttributes (GCdisplay, GLWin, &WinAttribs); - return (GLWin != 0 && (GLWin == FocusWin || WinAttribs.override_redirect)); + return (GLWin == FocusWin || bFocus); #else return true; #endif diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp index 522b98adb2..3259ad6ad2 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp @@ -118,53 +118,90 @@ void UpdateFPSDisplay(const char *text) } #if defined(HAVE_X11) && HAVE_X11 +THREAD_RETURN XEventThread(void *pArg); + +void X11_EWMH_Fullscreen(int action) +{ + _assert_(action == _NET_WM_STATE_REMOVE || action == _NET_WM_STATE_ADD + || action == _NET_WM_STATE_TOGGLE); + + // Init X event structure for _NET_WM_STATE_FULLSCREEN client message + XEvent event; + event.xclient.type = ClientMessage; + event.xclient.message_type = XInternAtom(GLWin.dpy, "_NET_WM_STATE", False); + event.xclient.window = GLWin.win; + event.xclient.format = 32; + event.xclient.data.l[0] = action; + event.xclient.data.l[1] = XInternAtom(GLWin.dpy, "_NET_WM_STATE_FULLSCREEN", False); + + // Send the event + if (!XSendEvent(GLWin.dpy, DefaultRootWindow(GLWin.dpy), False, + SubstructureRedirectMask | SubstructureNotifyMask, &event)) + ERROR_LOG(VIDEO, "Failed to switch fullscreen/windowed mode.\n"); +} + void CreateXWindow (void) { Atom wmProtocols[3]; - int width, height; + Window parent; - if (GLWin.fs) - { -#if defined(HAVE_XRANDR) && HAVE_XRANDR - if (GLWin.fullSize >= 0) - XRRSetScreenConfig(GLWin.dpy, GLWin.screenConfig, RootWindow(GLWin.dpy, GLWin.screen), - GLWin.fullSize, GLWin.screenRotation, CurrentTime); +#if defined(HAVE_GTK2) && HAVE_GTK2 && defined(wxGTK) + wxMutexGuiEnter(); #endif - GLWin.attr.override_redirect = True; - width = GLWin.fullWidth; - height = GLWin.fullHeight; +#if defined(HAVE_XRANDR) && HAVE_XRANDR + if (GLWin.fs && !GLWin.renderToMain) + XRRSetScreenConfig(GLWin.dpy, GLWin.screenConfig, RootWindow(GLWin.dpy, GLWin.screen), + GLWin.fullSize, GLWin.screenRotation, CurrentTime); +#endif +#if defined(HAVE_GTK2) && HAVE_GTK2 && defined(wxGTK) + if (GLWin.renderToMain) + { + GLWin.panel->GetSize((int *)&GLWin.width, (int *)&GLWin.height); + GLWin.panel->GetPosition(&GLWin.x, &GLWin.y); + parent = GDK_WINDOW_XID(GTK_WIDGET(GLWin.panel->GetHandle())->window); + GLWin.panel->SetFocus(); } else +#endif { - GLWin.attr.override_redirect = False; - width = GLWin.winWidth; - height = GLWin.winHeight; + GLWin.x = 0; + GLWin.y = 0; + GLWin.width = GLWin.winWidth; + GLWin.height = GLWin.winHeight; + parent = RootWindow(GLWin.dpy, GLWin.vi->screen); } // Control window size and picture scaling - s_backbuffer_width = width; - s_backbuffer_height = height; + s_backbuffer_width = GLWin.width; + s_backbuffer_height = GLWin.height; // create the window - GLWin.attr.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask | - StructureNotifyMask | ResizeRedirectMask; - GLWin.win = XCreateWindow(GLWin.dpy, RootWindow(GLWin.dpy, GLWin.vi->screen), - 0, 0, width, height, 0, GLWin.vi->depth, InputOutput, GLWin.vi->visual, - CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect, &GLWin.attr); + GLWin.win = XCreateWindow(GLWin.dpy, parent, + GLWin.x, GLWin.y, GLWin.width, GLWin.height, 0, GLWin.vi->depth, InputOutput, GLWin.vi->visual, + CWBorderPixel | CWBackPixel | CWColormap | CWEventMask, &GLWin.attr); wmProtocols[0] = XInternAtom(GLWin.dpy, "WM_DELETE_WINDOW", True); - wmProtocols[1] = XInternAtom(GLWin.dpy, "WM_TAKE_FOCUS", True); - wmProtocols[2] = XInternAtom(GLWin.dpy, "TOGGLE_FULLSCREEN", False); + wmProtocols[1] = XInternAtom(GLWin.dpy, "_NET_WM_STATE", False); + wmProtocols[2] = XInternAtom(GLWin.dpy, "_NET_WM_STATE_FULLSCREEN", False); XSetWMProtocols(GLWin.dpy, GLWin.win, wmProtocols, 3); XSetStandardProperties(GLWin.dpy, GLWin.win, "GPU", "GPU", None, NULL, 0, NULL); XMapRaised(GLWin.dpy, GLWin.win); - if (GLWin.fs) - { - XGrabKeyboard(GLWin.dpy, GLWin.win, True, GrabModeAsync, GrabModeAsync, CurrentTime); - XGrabPointer(GLWin.dpy, GLWin.win, True, NULL, - GrabModeAsync, GrabModeAsync, GLWin.win, None, CurrentTime); - XSetInputFocus(GLWin.dpy, GLWin.win, RevertToPointerRoot, CurrentTime); - } XSync(GLWin.dpy, True); +#if defined(HAVE_GTK2) && HAVE_GTK2 && defined(wxGTK) + wxMutexGuiLeave(); +#endif + + if (g_Config.bHideCursor) + { + // make a blank cursor + Pixmap Blank; + XColor DummyColor; + char ZeroData[1] = {0}; + Blank = XCreateBitmapFromData (GLWin.dpy, GLWin.win, ZeroData, 1, 1); + GLWin.blankCursor = XCreatePixmapCursor(GLWin.dpy, Blank, Blank, &DummyColor, &DummyColor, 0, 0); + XFreePixmap (GLWin.dpy, Blank); + } + + GLWin.xEventThread = new Common::Thread(XEventThread, NULL); } void DestroyXWindow(void) @@ -179,25 +216,180 @@ void DestroyXWindow(void) /* switch back to original desktop resolution if we were in fullscreen */ if( GLWin.fs ) { - XUngrabKeyboard (GLWin.dpy, CurrentTime); - XUngrabPointer (GLWin.dpy, CurrentTime); #if defined(HAVE_XRANDR) && HAVE_XRANDR - if (GLWin.fullSize >= 0) - XRRSetScreenConfig(GLWin.dpy, GLWin.screenConfig, RootWindow(GLWin.dpy, GLWin.screen), - GLWin.deskSize, GLWin.screenRotation, CurrentTime); + XRRSetScreenConfig(GLWin.dpy, GLWin.screenConfig, RootWindow(GLWin.dpy, GLWin.screen), + GLWin.deskSize, GLWin.screenRotation, CurrentTime); +#if defined(HAVE_GTK2) && HAVE_GTK2 && defined(wxGTK) + if (!GLWin.renderToMain) +#endif + X11_EWMH_Fullscreen(_NET_WM_STATE_REMOVE); #endif } XUndefineCursor(GLWin.dpy, GLWin.win); XUnmapWindow(GLWin.dpy, GLWin.win); - XSync(GLWin.dpy, True); + GLWin.win = 0; } void ToggleFullscreenMode (void) { - DestroyXWindow(); GLWin.fs = !GLWin.fs; - CreateXWindow(); - OpenGL_MakeCurrent(); +#if defined(HAVE_XRANDR) && HAVE_XRANDR + if (GLWin.fs) + XRRSetScreenConfig(GLWin.dpy, GLWin.screenConfig, RootWindow(GLWin.dpy, GLWin.screen), + GLWin.fullSize, GLWin.screenRotation, CurrentTime); + else + XRRSetScreenConfig(GLWin.dpy, GLWin.screenConfig, RootWindow(GLWin.dpy, GLWin.screen), + GLWin.deskSize, GLWin.screenRotation, CurrentTime); +#endif +#if defined(HAVE_GTK2) && HAVE_GTK2 && defined(wxGTK) + if (!GLWin.renderToMain) +#endif + { + X11_EWMH_Fullscreen(_NET_WM_STATE_TOGGLE); + XRaiseWindow(GLWin.dpy, GLWin.win); + XSetInputFocus(GLWin.dpy, GLWin.win, RevertToPointerRoot, CurrentTime); + } + XSync(GLWin.dpy, False); +} + +THREAD_RETURN XEventThread(void *pArg) +{ + bool bPaused = False; + while (GLWin.win) + { + XEvent event; + KeySym key; + for (int num_events = XPending(GLWin.dpy); num_events > 0; num_events--) { + XNextEvent(GLWin.dpy, &event); + switch(event.type) { + case KeyPress: + key = XLookupKeysym((XKeyEvent*)&event, 0); + switch (key) + { + case XK_F1: case XK_F2: case XK_F3: case XK_F4: case XK_F5: case XK_F6: + case XK_F7: case XK_F8: case XK_F9: case XK_F11: case XK_F12: + g_VideoInitialize.pKeyPress(key - 0xff4e, + event.xkey.state & ShiftMask, + event.xkey.state & ControlMask); + break; + case XK_Escape: + if (GLWin.fs && !bPaused) + { + printf("toggling fullscreen\n"); + ToggleFullscreenMode(); + } + g_VideoInitialize.pKeyPress(0x1c, False, False); + break; + case XK_Return: + if (event.xkey.state & Mod1Mask) + ToggleFullscreenMode(); + break; + case XK_3: + OSDChoice = 1; + // Toggle native resolution + if (!(g_Config.bNativeResolution || g_Config.b2xResolution)) + g_Config.bNativeResolution = true; + else if (g_Config.bNativeResolution && Renderer::AllowCustom()) + { g_Config.bNativeResolution = false; if (Renderer::Allow2x()) {g_Config.b2xResolution = true;} } + else if (Renderer::AllowCustom()) + g_Config.b2xResolution = false; + break; + case XK_4: + OSDChoice = 2; + // Toggle aspect ratio + g_Config.iAspectRatio = (g_Config.iAspectRatio + 1) & 3; + break; + case XK_5: + OSDChoice = 3; + // Toggle EFB copy + if (g_Config.bEFBCopyDisable || g_Config.bCopyEFBToTexture) + { + g_Config.bEFBCopyDisable = !g_Config.bEFBCopyDisable; + g_Config.bCopyEFBToTexture = false; + } + else + { + g_Config.bCopyEFBToTexture = !g_Config.bCopyEFBToTexture; + } + break; + case XK_6: + OSDChoice = 4; + g_Config.bDisableFog = !g_Config.bDisableFog; + break; + case XK_7: + OSDChoice = 5; + g_Config.bDisableLighting = !g_Config.bDisableLighting; + break; + default: + break; + } + break; + case FocusIn: + if (g_Config.bHideCursor && !bPaused && !GLWin.renderToMain) + XDefineCursor(GLWin.dpy, GLWin.win, GLWin.blankCursor); + break; + case FocusOut: + if (g_Config.bHideCursor && !bPaused && !GLWin.renderToMain) + XUndefineCursor(GLWin.dpy, GLWin.win); + break; + case ConfigureNotify: + Window winDummy; + unsigned int borderDummy; + XGetGeometry(GLWin.dpy, GLWin.win, &winDummy, &GLWin.x, &GLWin.y, + &GLWin.width, &GLWin.height, &borderDummy, &GLWin.depth); + s_backbuffer_width = GLWin.width; + s_backbuffer_height = GLWin.height; + // Save windowed mode size for return from fullscreen + if (!GLWin.fs) + { + GLWin.winWidth = GLWin.width; + GLWin.winHeight = GLWin.height; + } + break; + case ClientMessage: + if ((ulong) event.xclient.data.l[0] == XInternAtom(GLWin.dpy, "WM_DELETE_WINDOW", False)) + g_VideoInitialize.pKeyPress(0x1b, False, False); + if ((ulong) event.xclient.data.l[0] == XInternAtom(GLWin.dpy, "TOGGLE_FULLSCREEN", False)) + ToggleFullscreenMode(); + if (g_Config.bHideCursor && + (ulong) event.xclient.data.l[0] == XInternAtom(GLWin.dpy, "PAUSE", False)) + { + bPaused = True; + XUndefineCursor(GLWin.dpy, GLWin.win); + } + if (g_Config.bHideCursor && + (ulong) event.xclient.data.l[0] == XInternAtom(GLWin.dpy, "RESUME", False)) + { + bPaused = False; + XDefineCursor(GLWin.dpy, GLWin.win, GLWin.blankCursor); + } +#if defined(HAVE_GTK2) && HAVE_GTK2 && defined(wxGTK) + if (GLWin.renderToMain && + (ulong) event.xclient.data.l[0] == XInternAtom(GLWin.dpy, "RESIZE", False)) + { + GLWin.panel->GetSize((int *)&GLWin.width, (int *)&GLWin.height); + GLWin.panel->GetPosition(&GLWin.x, &GLWin.y); + XMoveResizeWindow(GLWin.dpy, GLWin.win, GLWin.x, GLWin.y, GLWin.width, GLWin.height); + } + if (GLWin.renderToMain && + (ulong) event.xclient.data.l[0] == XInternAtom(GLWin.dpy, "FOCUSIN", False)) + { + GLWin.panel->SetFocus(); + if (g_Config.bHideCursor) + XDefineCursor(GLWin.dpy, GLWin.win, GLWin.blankCursor); + } + if (GLWin.renderToMain && g_Config.bHideCursor && + (ulong) event.xclient.data.l[0] == XInternAtom(GLWin.dpy, "FOCUSOUT", False)) + XUndefineCursor(GLWin.dpy, GLWin.win); +#endif + break; + default: + break; + } + } + Common::SleepCurrentThread(20); + } + return 0; } #endif @@ -352,7 +544,6 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight // -------------------------------------- #elif defined(HAVE_X11) && HAVE_X11 - Colormap cmap; int glxMajorVersion, glxMinorVersion; int vidModeMajorVersion, vidModeMinorVersion; @@ -375,11 +566,20 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight GLWin.dpy = XOpenDisplay(0); - g_VideoInitialize.pWindowHandle = (HWND)GLWin.dpy; +#if defined(HAVE_GTK2) && HAVE_GTK2 && defined(wxGTK) + GLWin.panel = (wxPanel *)g_VideoInitialize.pPanel; +#endif + g_VideoInitialize.pWindowHandle = (Display *)GLWin.dpy; GLWin.screen = DefaultScreen(GLWin.dpy); // Fullscreen option. GLWin.fs = g_Config.bFullscreen; //Set to setting in Options + // Render to main option. +#if defined(HAVE_GTK2) && HAVE_GTK2 && defined(wxGTK) + GLWin.renderToMain = g_Config.RenderToMainframe; +#else + GLWin.renderToMain = False; +#endif /* get an appropriate visual */ GLWin.vi = glXChooseVisual(GLWin.dpy, GLWin.screen, attrListDbl); @@ -402,9 +602,12 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight PanicAlert("Couldn't Create GLX context.Quit"); exit(0); // TODO: Don't bring down entire Emu } - // Create a color map. - cmap = XCreateColormap(GLWin.dpy, RootWindow(GLWin.dpy, GLWin.vi->screen), GLWin.vi->visual, AllocNone); - GLWin.attr.colormap = cmap; + // Create a color map and set the event masks + GLWin.attr.colormap = XCreateColormap(GLWin.dpy, + RootWindow(GLWin.dpy, GLWin.vi->screen), GLWin.vi->visual, AllocNone); + GLWin.attr.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask | + StructureNotifyMask | ResizeRedirectMask; + GLWin.attr.background_pixel = BlackPixel(GLWin.dpy, GLWin.screen); GLWin.attr.border_pixel = 0; XkbSetDetectableAutoRepeat(GLWin.dpy, True, NULL); @@ -459,19 +662,14 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight GLWin.fullHeight = DisplayHeight(GLWin.dpy, GLWin.screen); #endif +#if defined(HAVE_GTK2) && HAVE_GTK2 && defined(wxGTK) + if (GLWin.renderToMain) + g_VideoInitialize.pKeyPress(0, False, False); +#endif + CreateXWindow(); g_VideoInitialize.pXWindow = (Window *) &GLWin.win; - if (g_Config.bHideCursor) - { - // make a blank cursor - Pixmap Blank; - XColor DummyColor; - char ZeroData[1] = {0}; - Blank = XCreateBitmapFromData (GLWin.dpy, GLWin.win, ZeroData, 1, 1); - GLWin.blankCursor = XCreatePixmapCursor(GLWin.dpy, Blank, Blank, &DummyColor, &DummyColor, 0, 0); - XFreePixmap (GLWin.dpy, Blank); - } #endif return true; } @@ -501,6 +699,19 @@ bool OpenGL_MakeCurrent() ERROR_LOG(VIDEO, "no Direct Rendering possible!"); } + if (GLWin.fs) + { +#if defined(HAVE_GTK2) && HAVE_GTK2 && defined(wxGTK) + if (GLWin.renderToMain) + { + GLWin.fs = False; + g_VideoInitialize.pKeyPress(0x1d, False, False); + } + else +#endif + X11_EWMH_Fullscreen(_NET_WM_STATE_ADD); + } + // Hide the cursor now if (g_Config.bHideCursor) XDefineCursor (GLWin.dpy, GLWin.win, GLWin.blankCursor); @@ -557,118 +768,6 @@ void OpenGL_Update() s_backbuffer_height = height; #elif defined(HAVE_X11) && HAVE_X11 - // We just check all of our events here - XEvent event; - KeySym key; - int num_events; - for (num_events = XPending(GLWin.dpy);num_events > 0;num_events--) { - XNextEvent(GLWin.dpy, &event); - switch(event.type) { - case KeyPress: - key = XLookupKeysym((XKeyEvent*)&event, 0); - switch (key) - { - case XK_F4: - if(event.xkey.state & Mod1Mask) - { - g_VideoInitialize.pKeyPress(0x1b, False, False); - break; - } - case XK_F1: case XK_F2: case XK_F3: case XK_F5: - case XK_F6: case XK_F7: case XK_F8: case XK_F9: - g_VideoInitialize.pKeyPress(key - 0xff4e, - event.xkey.state & ShiftMask, - event.xkey.state & ControlMask); - break; - case XK_Escape: - if (GLWin.fs) - { - ToggleFullscreenMode(); - XEvent mapevent; - do { - XMaskEvent(GLWin.dpy, StructureNotifyMask, &mapevent); - } while ( (mapevent.type != MapNotify) || (mapevent.xmap.event != GLWin.win) ); - } - g_VideoInitialize.pKeyPress(0x1c, False, False); - break; - case XK_Return: - if (event.xkey.state & Mod1Mask) - ToggleFullscreenMode(); - break; - case XK_3: - OSDChoice = 1; - // Toggle native resolution - if (!(g_Config.bNativeResolution || g_Config.b2xResolution)) - g_Config.bNativeResolution = true; - else if (g_Config.bNativeResolution && Renderer::AllowCustom()) - { g_Config.bNativeResolution = false; if (Renderer::Allow2x()) {g_Config.b2xResolution = true;} } - else if (Renderer::AllowCustom()) - g_Config.b2xResolution = false; - break; - case XK_4: - OSDChoice = 2; - // Toggle aspect ratio - g_Config.iAspectRatio = (g_Config.iAspectRatio + 1) & 3; - break; - case XK_5: - OSDChoice = 3; - // Toggle EFB copy - if (g_Config.bEFBCopyDisable || g_Config.bCopyEFBToTexture) - { - g_Config.bEFBCopyDisable = !g_Config.bEFBCopyDisable; - g_Config.bCopyEFBToTexture = false; - } - else - { - g_Config.bCopyEFBToTexture = !g_Config.bCopyEFBToTexture; - } - break; - case XK_6: - OSDChoice = 4; - g_Config.bDisableFog = !g_Config.bDisableFog; - break; - case XK_7: - OSDChoice = 5; - g_Config.bDisableLighting = !g_Config.bDisableLighting; - break; - - default: - break; - } - case FocusIn: - if (g_Config.bHideCursor) - XDefineCursor(GLWin.dpy, GLWin.win, GLWin.blankCursor); - break; - case FocusOut: - if (g_Config.bHideCursor && !GLWin.fs) - XUndefineCursor(GLWin.dpy, GLWin.win); - break; - case ConfigureNotify: - Window winDummy; - unsigned int borderDummy; - XGetGeometry(GLWin.dpy, GLWin.win, &winDummy, &GLWin.x, &GLWin.y, - &GLWin.width, &GLWin.height, &borderDummy, &GLWin.depth); - s_backbuffer_width = GLWin.width; - s_backbuffer_height = GLWin.height; - // Save windowed mode size for return from fullscreen - if (!GLWin.fs) - { - GLWin.winWidth = GLWin.width; - GLWin.winHeight = GLWin.height; - } - break; - case ClientMessage: - if ((ulong) event.xclient.data.l[0] == XInternAtom(GLWin.dpy, "WM_DELETE_WINDOW", False)) - g_VideoInitialize.pKeyPress(0x1b, False, False); - if ((ulong) event.xclient.data.l[0] == XInternAtom(GLWin.dpy, "TOGGLE_FULLSCREEN", False)) - ToggleFullscreenMode(); - return; - break; - default: - break; - } - } - return; #endif } @@ -708,6 +807,9 @@ void OpenGL_Shutdown() } #elif defined(HAVE_X11) && HAVE_X11 DestroyXWindow(); + if (GLWin.xEventThread) + GLWin.xEventThread->WaitForDeath(); + GLWin.xEventThread = NULL; #if defined(HAVE_XRANDR) && HAVE_XRANDR if (GLWin.fullSize >= 0) XRRFreeScreenConfigInfo(GLWin.screenConfig); @@ -717,6 +819,7 @@ void OpenGL_Shutdown() if (GLWin.ctx) { glXDestroyContext(GLWin.dpy, GLWin.ctx); + XFreeColormap(GLWin.dpy, GLWin.attr.colormap); XCloseDisplay(GLWin.dpy); GLWin.ctx = NULL; } diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.h b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.h index 4bff0c4efa..61d12abc66 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.h @@ -31,19 +31,38 @@ #include #include -#else // linux basic definitions +#else // linux and apple basic definitions #if defined(USE_WX) && USE_WX #include #include "wx/wx.h" #include "wx/glcanvas.h" + #elif defined(HAVE_X11) && HAVE_X11 -#define I_NEED_OS2_H // HAXXOR #include #include +#if defined(HAVE_GTK2) && HAVE_GTK2 // Needed for render to main +#include +#include +#include +#endif +#include +#include +#include +#include "Thread.h" +#if defined(HAVE_XRANDR) && HAVE_XRANDR +#include +#endif // XRANDR +// EWMH state actions, see +// http://freedesktop.org/wiki/Specifications/wm-spec?action=show&redirect=Standards%2Fwm-spec +#define _NET_WM_STATE_REMOVE 0 /* remove/unset property */ +#define _NET_WM_STATE_ADD 1 /* add/set property */ +#define _NET_WM_STATE_TOGGLE 2 /* toggle property */ + #elif defined(USE_SDL) && USE_SDL #include #include + #elif defined(HAVE_COCOA) && HAVE_COCOA #include #include "cocoaGL.h" @@ -65,15 +84,6 @@ #endif #ifndef _WIN32 -#if defined(HAVE_X11) && HAVE_X11 -#include -#include -#include - -#if defined(HAVE_XRANDR) && HAVE_XRANDR -#include -#endif // XRANDR -#endif // X11 #include #include @@ -85,6 +95,9 @@ typedef struct { NSOpenGLContext *cocoaCtx; #elif defined(HAVE_X11) && HAVE_X11 Window win; +#if defined(HAVE_GTK2) && HAVE_GTK2 && defined(wxGTK) + wxPanel *panel; +#endif Display *dpy; XVisualInfo *vi; GLXContext ctx; @@ -94,6 +107,8 @@ typedef struct { Bool doubleBuffered; int fullWidth, fullHeight; int winWidth, winHeight; + Common::Thread *xEventThread; + Bool renderToMain; #if defined(HAVE_XRANDR) && HAVE_XRANDR XRRScreenConfiguration *screenConfig; Rotation screenRotation; diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.cpp b/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.cpp index 13550b1a7d..d99b66f4fd 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.cpp @@ -833,8 +833,10 @@ void GFXConfigDialogOGL::UpdateGUI() m_AutoScale->Enable(!g_Config.bUseXFB); // These options are for the separate rendering window +#if !defined(HAVE_GTK2) || !HAVE_GTK2 || !defined(wxGTK) m_Fullscreen->Enable(!g_Config.RenderToMainframe); if (g_Config.RenderToMainframe) m_Fullscreen->SetValue(false); +#endif // Resolution settings //disable native/2x choice when real xfb is on. native simply looks best, as ector noted above. @@ -842,7 +844,11 @@ void GFXConfigDialogOGL::UpdateGUI() m_NativeResolution->Enable(!g_Config.bUseXFB); m_2xResolution->Enable(!g_Config.bUseXFB && (!g_Config.bRunning || Renderer::Allow2x())); m_WindowResolutionCB->Enable(!g_Config.bRunning); +#if defined(HAVE_GTK2) && HAVE_GTK2 && defined(wxGTK) + m_WindowFSResolutionCB->Enable(!g_Config.bRunning); +#else m_WindowFSResolutionCB->Enable(!g_Config.bRunning && !g_Config.RenderToMainframe); +#endif // Disable the Copy to options when EFBCopy is disabled m_Radio_CopyEFBToRAM->Enable(!(g_Config.bEFBCopyDisable)); diff --git a/Source/Plugins/Plugin_VideoOGL/Src/SConscript b/Source/Plugins/Plugin_VideoOGL/Src/SConscript index a782fe46cb..c3806c9e34 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/SConscript +++ b/Source/Plugins/Plugin_VideoOGL/Src/SConscript @@ -105,6 +105,10 @@ gfxenv['HAVE_XRANDR'] = gfxenv['HAVE_X11'] and conf.CheckPKG('xrandr') conf.Define('HAVE_XRANDR', gfxenv['HAVE_XRANDR']) +# check for libgtk2.0 +gfxenv['HAVE_GTK2'] = gfxenv['HAVE_WX'] and conf.CheckPKG('gtk+-2.0') +conf.Define('HAVE_GTK2', gfxenv['HAVE_GTK2']) + conf.Finish() # Sanity check diff --git a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp index bcc6e4f1e1..7b07f8cfac 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp @@ -208,12 +208,18 @@ void Win32AddResolutions() } #elif defined(HAVE_X11) && HAVE_X11 && defined(HAVE_XRANDR) && HAVE_XRANDR void X11AddResolutions() { - GLWin.dpy = XOpenDisplay(0); + // Don't modify GLWin.dpy here. + // If the emulator is running that is bad. + Display *dpy; + int screen; + dpy = XOpenDisplay(0); + screen = DefaultScreen(dpy); //Get all full screen resos for the config dialog XRRScreenSize *sizes = NULL; int modeNum = 0; - sizes = XRRSizes(GLWin.dpy, GLWin.screen, &modeNum); + sizes = XRRSizes(dpy, screen, &modeNum); + XCloseDisplay(dpy); if (modeNum > 0 && sizes != NULL) { for (int i = 0; i < modeNum; i++) @@ -349,8 +355,8 @@ void Initialize(void *init) } void DoState(unsigned char **ptr, int mode) { -#ifndef _WIN32 - // WHY is this here?? +#if !defined(_WIN32) && !defined(__linux__) + // WHY is this here?? If macs don't need this it should be removed. OpenGL_MakeCurrent(); #endif // Clear all caches that touch RAM diff --git a/Source/Plugins/Plugin_Wiimote/Src/ConfigGamepad.cpp b/Source/Plugins/Plugin_Wiimote/Src/ConfigGamepad.cpp index c3faef67f9..7a38d7f8af 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/ConfigGamepad.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/ConfigGamepad.cpp @@ -222,10 +222,7 @@ void WiimotePadConfigDialog::DoGetButtons(int _GetId) DEBUG_LOG(WIIMOTE, "Timer Stopped for Pad:%i _GetId:%i", WiiMoteEmu::WiiMapping[m_Page].ID, _GetId); - m_ButtonMappingTimer->Stop(); - GetButtonWaitingTimer = 0; - GetButtonWaitingID = 0; - ClickedButton = NULL; + EndGetButtons(); } // If we got a bad button @@ -241,6 +238,17 @@ void WiimotePadConfigDialog::DoGetButtons(int _GetId) } } +void WiimotePadConfigDialog::EndGetButtons(void) +{ + wxTheApp->Disconnect(wxID_ANY, wxEVT_KEY_DOWN, // Keyboard + wxKeyEventHandler(WiimotePadConfigDialog::OnKeyDown), + (wxObject*)0, this); + m_ButtonMappingTimer->Stop(); + GetButtonWaitingTimer = 0; + GetButtonWaitingID = 0; + ClickedButton = NULL; +} + // Convert the 0x8000 range values to BoxW and BoxH for the plot void WiimotePadConfigDialog::Convert2Box(int &x) { diff --git a/Source/Plugins/Plugin_Wiimote/Src/ConfigPadDlg.cpp b/Source/Plugins/Plugin_Wiimote/Src/ConfigPadDlg.cpp index 417ded3b5e..934446e8f7 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/ConfigPadDlg.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/ConfigPadDlg.cpp @@ -135,10 +135,6 @@ WiimotePadConfigDialog::WiimotePadConfigDialog(wxWindow *parent, wxWindowID id, m_Notebook->ChangeSelection(m_Page); // Set control values UpdateGUI(); - - wxTheApp->Connect(wxID_ANY, wxEVT_KEY_DOWN, // Keyboard - wxKeyEventHandler(WiimotePadConfigDialog::OnKeyDown), - (wxObject*)0, this); } WiimotePadConfigDialog::~WiimotePadConfigDialog() @@ -247,10 +243,7 @@ void WiimotePadConfigDialog::OnKeyDown(wxKeyEvent& event) SaveButtonMapping(ClickedButton->GetId(), XKey); #endif } - m_ButtonMappingTimer->Stop(); - GetButtonWaitingTimer = 0; - GetButtonWaitingID = 0; - ClickedButton = NULL; + EndGetButtons(); } } @@ -264,6 +257,10 @@ void WiimotePadConfigDialog::OnButtonClick(wxCommandEvent& event) if (m_ButtonMappingTimer->IsRunning()) return; + wxTheApp->Connect(wxID_ANY, wxEVT_KEY_DOWN, // Keyboard + wxKeyEventHandler(WiimotePadConfigDialog::OnKeyDown), + (wxObject*)0, this); + // Create the button object ClickedButton = (wxButton *)event.GetEventObject(); // Save old label so we can revert back diff --git a/Source/Plugins/Plugin_Wiimote/Src/ConfigPadDlg.h b/Source/Plugins/Plugin_Wiimote/Src/ConfigPadDlg.h index aecdce9874..c89f9db6fe 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/ConfigPadDlg.h +++ b/Source/Plugins/Plugin_Wiimote/Src/ConfigPadDlg.h @@ -288,6 +288,7 @@ class WiimotePadConfigDialog : public wxDialog wxString GetButtonText(int id); void DoGetButtons(int id); + void EndGetButtons(); void UpdatePadInfo(wxTimerEvent& WXUNUSED(event)); void ToBlank(bool ToBlank, int Id); void DoChangeDeadZone(); diff --git a/Source/Plugins/Plugin_Wiimote/Src/main.cpp b/Source/Plugins/Plugin_Wiimote/Src/main.cpp index f6b26a2f03..1ab892cda3 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/main.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/main.cpp @@ -397,12 +397,14 @@ bool IsFocus() return false; #elif defined HAVE_X11 && HAVE_X11 Window GLWin = *(Window *)g_WiimoteInitialize.pXWindow; + bool bFocus = False; +#if defined(HAVE_GTK2) && HAVE_GTK2 && defined(wxGTK) + bFocus = (wxPanel *)g_WiimoteInitialize.pPanel == wxWindow::FindFocus(); +#endif Window FocusWin; int Revert; XGetInputFocus(WMdisplay, &FocusWin, &Revert); - XWindowAttributes WinAttribs; - XGetWindowAttributes (WMdisplay, GLWin, &WinAttribs); - return (GLWin != 0 && (GLWin == FocusWin || WinAttribs.override_redirect)); + return (GLWin == FocusWin || bFocus); #else return true; #endif