diff --git a/pcsx2/Counters.cpp b/pcsx2/Counters.cpp index ac6cc28f27..c6292e6190 100644 --- a/pcsx2/Counters.cpp +++ b/pcsx2/Counters.cpp @@ -29,11 +29,6 @@ #include "VUmicro.h" #include "ps2/HwInternal.h" -#ifdef _WIN32 -#include "PAD/Windows/PAD.h" -#else -#include "PAD/Linux/PAD.h" -#endif #include "Sio.h" #ifndef DISABLE_RECORDING diff --git a/pcsx2/Dump.cpp b/pcsx2/Dump.cpp index 94e53ac08c..fd36502d68 100644 --- a/pcsx2/Dump.cpp +++ b/pcsx2/Dump.cpp @@ -247,7 +247,7 @@ void iDumpBlock(u32 ee_pc, u32 ee_size, uptr x86_pc, u32 x86_size) // handy but slow solution (system call) #ifdef __linux__ - wxString obj_filename = Path::Combine(g_Conf->Folders.Logs, wxString(L"objdump_tmp.o")); + wxString obj_filename = Path::Combine(EmuConfig.Folders.Logs, wxString(L"objdump_tmp.o")); wxFFile objdump(obj_filename , L"wb"); objdump.Write(x86, x86_size); objdump.Close(); diff --git a/pcsx2/GS/GS.cpp b/pcsx2/GS/GS.cpp index 8a1120fdc7..1adf2d6a8b 100644 --- a/pcsx2/GS/GS.cpp +++ b/pcsx2/GS/GS.cpp @@ -658,7 +658,7 @@ uint32 GSmakeSnapshot(char* path) } } -void GSkeyEvent(GSKeyEventData* e) +void GSkeyEvent(const HostKeyEvent& e) { try { diff --git a/pcsx2/GS/GS.h b/pcsx2/GS/GS.h index 3d712bb8d3..f0498a338a 100644 --- a/pcsx2/GS/GS.h +++ b/pcsx2/GS/GS.h @@ -1711,16 +1711,6 @@ struct GSPrivRegSet #pragma pack(pop) -enum -{ - KEYPRESS = 1, - KEYRELEASE = 2 -}; -struct GSKeyEventData -{ - uint32 key, type; -}; - // ST_WRITE is defined in libc, avoid this enum stateType { @@ -1774,6 +1764,8 @@ enum class CRCHackLevel : int8 Aggressive }; +struct HostKeyEvent; + #ifdef ENABLE_ACCURATE_BUFFER_EMULATION const GSVector2i default_rt_size(2048, 2048); #else @@ -1802,7 +1794,7 @@ void GSgifTransfer2(uint8* mem, uint32 size); void GSgifTransfer3(uint8* mem, uint32 size); void GSvsync(int field); uint32 GSmakeSnapshot(char* path); -void GSkeyEvent(GSKeyEventData* e); +void GSkeyEvent(const HostKeyEvent& e); int GSfreeze(FreezeAction mode, freezeData* data); void GSconfigure(); int GStest(); diff --git a/pcsx2/GS/Renderers/Common/GSRenderer.cpp b/pcsx2/GS/Renderers/Common/GSRenderer.cpp index 50c3d7650b..229cfb7b4e 100644 --- a/pcsx2/GS/Renderers/Common/GSRenderer.cpp +++ b/pcsx2/GS/Renderers/Common/GSRenderer.cpp @@ -15,6 +15,7 @@ #include "PrecompiledHeader.h" #include "GSRenderer.h" +#include "Host.h" #include "pcsx2/Config.h" #if defined(__unix__) #include @@ -595,27 +596,27 @@ void GSRenderer::EndCapture() m_capture.EndCapture(); } -void GSRenderer::KeyEvent(GSKeyEventData* e) +void GSRenderer::KeyEvent(const HostKeyEvent& e) { #ifndef __APPLE__ // TODO: Add hotkey support on macOS #ifdef _WIN32 m_shift_key = !!(::GetAsyncKeyState(VK_SHIFT) & 0x8000); m_control_key = !!(::GetAsyncKeyState(VK_CONTROL) & 0x8000); #else - switch (e->key) + switch (e.key) { case XK_Shift_L: case XK_Shift_R: - m_shift_key = (e->type == KEYPRESS); + m_shift_key = (e.type == HostKeyEvent::Type::KeyPressed); return; case XK_Control_L: case XK_Control_R: - m_control_key = (e->type == KEYPRESS); + m_control_key = (e.type == HostKeyEvent::Type::KeyReleased); return; } #endif - if (e->type == KEYPRESS) + if (e.type == HostKeyEvent::Type::KeyPressed) { int step = m_shift_key ? -1 : 1; @@ -630,7 +631,7 @@ void GSRenderer::KeyEvent(GSKeyEventData* e) #define VK_HOME XK_Home #endif - switch (e->key) + switch (e.key) { case VK_F5: m_interlace = (m_interlace + s_interlace_nb + step) % s_interlace_nb; diff --git a/pcsx2/GS/Renderers/Common/GSRenderer.h b/pcsx2/GS/Renderers/Common/GSRenderer.h index 31fc87cdd1..27c1061001 100644 --- a/pcsx2/GS/Renderers/Common/GSRenderer.h +++ b/pcsx2/GS/Renderers/Common/GSRenderer.h @@ -20,6 +20,8 @@ #include "GS/GSState.h" #include "GS/GSCapture.h" +struct HostKeyEvent; + class GSRenderer : public GSState { GSCapture m_capture; @@ -57,7 +59,7 @@ public: virtual void ResetDevice(); virtual void VSync(int field); virtual bool MakeSnapshot(const std::string& path); - virtual void KeyEvent(GSKeyEventData* e); + virtual void KeyEvent(const HostKeyEvent& e); virtual bool CanUpscale() { return false; } virtual int GetUpscaleMultiplier() { return 1; } virtual GSVector2i GetCustomResolution() { return GSVector2i(0, 0); } diff --git a/pcsx2/Host.h b/pcsx2/Host.h new file mode 100644 index 0000000000..48d876b606 --- /dev/null +++ b/pcsx2/Host.h @@ -0,0 +1,31 @@ +/* PCSX2 - PS2 Emulator for PCs + * Copyright (C) 2002-2021 PCSX2 Dev Team + * + * PCSX2 is free software: you can redistribute it and/or modify it under the terms + * of the GNU Lesser General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * PCSX2 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 for more details. + * + * You should have received a copy of the GNU General Public License along with PCSX2. + * If not, see . + */ + +#pragma once + +#include "common/Pcsx2Defs.h" + +struct HostKeyEvent +{ + enum class Type + { + NoEvent = 0, + KeyPressed = 1, + KeyReleased = 2 + }; + + Type type; + u32 key; +}; diff --git a/pcsx2/MTGS.cpp b/pcsx2/MTGS.cpp index 6e1a613eb2..affe3f747d 100644 --- a/pcsx2/MTGS.cpp +++ b/pcsx2/MTGS.cpp @@ -24,11 +24,6 @@ #include "MTVU.h" #include "Elfheader.h" #include "gui/Dialogs/ModalPopups.h" -#ifdef _WIN32 -#include "PAD/Windows/PAD.h" -#else -#include "PAD/Linux/PAD.h" -#endif // Uncomment this to enable profiling of the GS RingBufferCopy function. diff --git a/pcsx2/PAD/Linux/Global.h b/pcsx2/PAD/Linux/Global.h index 4b7702ff9e..71e4a8a52c 100644 --- a/pcsx2/PAD/Linux/Global.h +++ b/pcsx2/PAD/Linux/Global.h @@ -31,7 +31,6 @@ #include "common/pxStreams.h" #include "common/Console.h" #include "DebugTools/Debug.h" -#include "gui/App.h" #define PADdefs diff --git a/pcsx2/PAD/Linux/PAD.cpp b/pcsx2/PAD/Linux/PAD.cpp index ff634297a9..6806caaf18 100644 --- a/pcsx2/PAD/Linux/PAD.cpp +++ b/pcsx2/PAD/Linux/PAD.cpp @@ -35,16 +35,16 @@ const u32 build = 0; // increase that with each version #define PAD_SAVE_STATE_VERSION ((revision << 8) | (build << 0)) PADconf g_conf; -keyEvent event; +HostKeyEvent event; -static keyEvent s_event; +static HostKeyEvent s_event; std::string s_padstrLogPath("logs/"); FILE* padLog = NULL; KeyStatus g_key_status; -MtQueue g_ev_fifo; +MtQueue g_ev_fifo; void __LogToConsole(const char* fmt, ...) @@ -240,7 +240,7 @@ u8 PADpoll(u8 value) } // PADkeyEvent is called every vsync (return NULL if no event) -keyEvent* PADkeyEvent() +HostKeyEvent* PADkeyEvent() { #ifdef SDL_BUILD // Take the opportunity to handle hot plugging here @@ -263,7 +263,7 @@ keyEvent* PADkeyEvent() { // PAD_LOG("No events in queue, returning empty event\n"); s_event = event; - event.evt = 0; + event.type = HostKeyEvent::Type::NoEvent; event.key = 0; return &s_event; } @@ -274,14 +274,14 @@ keyEvent* PADkeyEvent() return &s_event; #else // MacOS s_event = event; - event.evt = 0; + event.type = HostKeyEvent::Type::NoEvent; event.key = 0; return &s_event; #endif } #if defined(__unix__) -void PADWriteEvent(keyEvent& evt) +void PADWriteEvent(HostKeyEvent& evt) { // if (evt.evt != 6) { // Skip mouse move events for logging // PAD_LOG("Pushing Event. Event Type: %d, Key: %d\n", evt.evt, evt.key); diff --git a/pcsx2/PAD/Linux/PAD.h b/pcsx2/PAD/Linux/PAD.h index 81e7b6a83a..ed96008853 100644 --- a/pcsx2/PAD/Linux/PAD.h +++ b/pcsx2/PAD/Linux/PAD.h @@ -16,7 +16,9 @@ #pragma once #include "Global.h" +#include "Host.h" #include "common/mt_queue.h" +#include "SaveState.h" enum PadOptions { @@ -32,8 +34,8 @@ enum PadOptions extern FILE* padLog; extern void initLogging(); -extern keyEvent event; -extern MtQueue g_ev_fifo; +extern HostKeyEvent event; +extern MtQueue g_ev_fifo; s32 _PADopen(void* pDsp); void _PADclose(); @@ -50,10 +52,10 @@ s32 PADsetSlot(u8 port, u8 slot); s32 PADfreeze(FreezeAction mode, freezeData* data); u8 PADstartPoll(int pad); u8 PADpoll(u8 value); -keyEvent* PADkeyEvent(); +HostKeyEvent* PADkeyEvent(); void PADupdate(int pad); void PADconfigure(); #if defined(__unix__) -void PADWriteEvent(keyEvent& evt); +void PADWriteEvent(HostKeyEvent& evt); #endif diff --git a/pcsx2/PAD/Linux/keyboard.cpp b/pcsx2/PAD/Linux/keyboard.cpp index 25e4d30f2e..0339f5e1d1 100644 --- a/pcsx2/PAD/Linux/keyboard.cpp +++ b/pcsx2/PAD/Linux/keyboard.cpp @@ -20,10 +20,7 @@ #include "Global.h" #include "keyboard.h" - -#include "common/mt_queue.h" -extern keyEvent event; -extern MtQueue g_ev_fifo; +#include "PAD.h" /// g_key_status.press but with proper handling for analog buttons static void PressButton(u32 pad, u32 button) @@ -117,7 +114,7 @@ static bool s_Shift = false; static unsigned int s_previous_mouse_x = 0; static unsigned int s_previous_mouse_y = 0; -void AnalyzeKeyEvent(keyEvent& evt) +void AnalyzeKeyEvent(HostKeyEvent& evt) { KeySym key = (KeySym)evt.key; int pad = 0; @@ -133,7 +130,7 @@ void AnalyzeKeyEvent(keyEvent& evt) } } - switch (evt.evt) + switch (static_cast(evt.type)) { case KeyPress: // Shift F12 is not yet use by pcsx2. So keep it to grab/ungrab input @@ -164,7 +161,7 @@ void AnalyzeKeyEvent(keyEvent& evt) //PAD_LOG("Key pressed:%d\n", index); - event.evt = KEYPRESS; + event.type = HostKeyEvent::Type::KeyPressed; event.key = key; break; @@ -175,7 +172,7 @@ void AnalyzeKeyEvent(keyEvent& evt) if (index != -1) g_key_status.release(pad, index); - event.evt = KEYRELEASE; + event.type = HostKeyEvent::Type::KeyReleased; event.key = key; break; @@ -258,7 +255,7 @@ void AnalyzeKeyEvent(keyEvent& evt) void UpdateKeyboardInput() { - keyEvent evt = {0}; + HostKeyEvent evt = {}; XEvent E = {0}; // Keyboard input send by PCSX2 @@ -271,7 +268,7 @@ void UpdateKeyboardInput() // Change the format of the structure to be compatible with GSOpen2 // mode (event come from pcsx2 not X) - evt.evt = E.type; + evt.type = static_cast(E.type); switch (E.type) { case MotionNotify: diff --git a/pcsx2/PAD/Linux/keyboard.h b/pcsx2/PAD/Linux/keyboard.h index fbe632d5b5..3896a08bb0 100644 --- a/pcsx2/PAD/Linux/keyboard.h +++ b/pcsx2/PAD/Linux/keyboard.h @@ -16,7 +16,7 @@ #pragma once #include "common/Pcsx2Defs.h" -#include "gui/App.h" +#include "Host.h" #if defined(__unix__) || defined(__APPLE__) @@ -29,7 +29,7 @@ #undef DisableScreenSaver #endif -extern void AnalyzeKeyEvent(keyEvent& evt); +extern void AnalyzeKeyEvent(HostKeyEvent& evt); extern void UpdateKeyboardInput(); extern bool PollForNewKeyboardKeys(u32& pkey); #endif diff --git a/pcsx2/PAD/Windows/InputManager.cpp b/pcsx2/PAD/Windows/InputManager.cpp index afd9a4d3f5..d9c22c5a3c 100644 --- a/pcsx2/PAD/Windows/InputManager.cpp +++ b/pcsx2/PAD/Windows/InputManager.cpp @@ -18,6 +18,7 @@ #include "InputManager.h" #include "KeyboardQueue.h" #include "PADConfig.h" +#include "Host.h" InputDeviceManager* dm = 0; @@ -235,9 +236,9 @@ void Device::CalcVirtualState() if (i < numPhysicalControls) continue; } - int event = KEYPRESS; + HostKeyEvent::Type event = HostKeyEvent::Type::KeyPressed; if (!(virtualControlState[index] >> 15)) - event = KEYRELEASE; + event = HostKeyEvent::Type::KeyReleased; QueueKeyEvent(c->vkey, event); } } diff --git a/pcsx2/PAD/Windows/KeyboardQueue.cpp b/pcsx2/PAD/Windows/KeyboardQueue.cpp index 215e4d0f17..46a0b63e1c 100644 --- a/pcsx2/PAD/Windows/KeyboardQueue.cpp +++ b/pcsx2/PAD/Windows/KeyboardQueue.cpp @@ -24,9 +24,9 @@ static std::mutex cSection; // Actually points one beyond the last queued event. static u8 lastQueuedEvent = 0; static u8 nextQueuedEvent = 0; -static keyEvent queuedEvents[EVENT_QUEUE_LEN]; +static HostKeyEvent queuedEvents[EVENT_QUEUE_LEN]; -void QueueKeyEvent(int key, int event) +void QueueKeyEvent(u32 key, HostKeyEvent::Type event) { std::lock_guard lock(cSection); @@ -34,17 +34,17 @@ void QueueKeyEvent(int key, int event) // purposes when a game is killing the emulator for whatever reason. if (nextQueuedEvent == lastQueuedEvent || queuedEvents[nextQueuedEvent].key != VK_ESCAPE || - queuedEvents[nextQueuedEvent].evt != KEYPRESS) + queuedEvents[nextQueuedEvent].type != HostKeyEvent::Type::KeyPressed) { // Clear queue on escape down, bringing escape to front. May do something // with shift/ctrl/alt and F-keys, later. - if (event == KEYPRESS && key == VK_ESCAPE) + if (event == HostKeyEvent::Type::KeyPressed && key == VK_ESCAPE) { nextQueuedEvent = lastQueuedEvent; } queuedEvents[lastQueuedEvent].key = key; - queuedEvents[lastQueuedEvent].evt = event; + queuedEvents[lastQueuedEvent].type = event; lastQueuedEvent = (lastQueuedEvent + 1) % EVENT_QUEUE_LEN; // If queue wrapped around, remove last element. @@ -55,7 +55,7 @@ void QueueKeyEvent(int key, int event) } } -int GetQueuedKeyEvent(keyEvent* event) +int GetQueuedKeyEvent(HostKeyEvent* event) { if (lastQueuedEvent == nextQueuedEvent) return 0; diff --git a/pcsx2/PAD/Windows/KeyboardQueue.h b/pcsx2/PAD/Windows/KeyboardQueue.h index e422ffc626..b352814eb8 100644 --- a/pcsx2/PAD/Windows/KeyboardQueue.h +++ b/pcsx2/PAD/Windows/KeyboardQueue.h @@ -17,14 +17,16 @@ // This entire thing isn't really needed, // but takes little enough effort to be safe... -void QueueKeyEvent(int key, int event); -int GetQueuedKeyEvent(keyEvent* event); +#include "Host.h" + +void QueueKeyEvent(u32 key, HostKeyEvent::Type event); +int GetQueuedKeyEvent(HostKeyEvent* event); // Cleans up as well as clears queue. void ClearKeyQueue(); #ifdef __linux__ -void R_QueueKeyEvent(const keyEvent& event); -int R_GetQueuedKeyEvent(keyEvent* event); +void R_QueueKeyEvent(const HostKeyEvent& event); +int R_GetQueuedKeyEvent(HostKeyEvent* event); void R_ClearKeyQueue(); #endif diff --git a/pcsx2/PAD/Windows/PAD.cpp b/pcsx2/PAD/Windows/PAD.cpp index 0c8cec8c5c..2c6e161403 100644 --- a/pcsx2/PAD/Windows/PAD.cpp +++ b/pcsx2/PAD/Windows/PAD.cpp @@ -24,6 +24,7 @@ #include "InputManager.h" #include "PADConfig.h" #include "PAD.h" +#include "Host.h" #include "DeviceEnumerator.h" #ifdef _MSC_VER @@ -33,6 +34,8 @@ #include "KeyboardQueue.h" #include "DualShock3.h" +#include "gui/AppCoreThread.h" + #define WMA_FORCE_UPDATE (WM_APP + 0x537) #define FORCE_UPDATE_WPARAM ((WPARAM)0x74328943) #define FORCE_UPDATE_LPARAM ((LPARAM)0x89437437) @@ -222,9 +225,9 @@ u8 Cap(int i) inline void ReleaseModifierKeys() { - QueueKeyEvent(VK_SHIFT, KEYRELEASE); - QueueKeyEvent(VK_MENU, KEYRELEASE); - QueueKeyEvent(VK_CONTROL, KEYRELEASE); + QueueKeyEvent(VK_SHIFT, HostKeyEvent::Type::KeyReleased); + QueueKeyEvent(VK_MENU, HostKeyEvent::Type::KeyReleased); + QueueKeyEvent(VK_CONTROL, HostKeyEvent::Type::KeyReleased); } // RefreshEnabledDevices() enables everything that can potentially @@ -387,7 +390,7 @@ void ProcessButtonBinding(Binding* b, ButtonSum* sum, int value) unsigned int t = timeGetTime(); if (t - LastCheck < 300) return; - QueueKeyEvent(VK_TAB, KEYPRESS); + QueueKeyEvent(VK_TAB, HostKeyEvent::Type::KeyPressed); LastCheck = t; } @@ -945,7 +948,7 @@ ExtraWndProcResult StatusWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPa PrepareActivityState(LOWORD(wParam) != WA_INACTIVE); break; case WM_DESTROY: - QueueKeyEvent(VK_ESCAPE, KEYPRESS); + QueueKeyEvent(VK_ESCAPE, HostKeyEvent::Type::KeyPressed); break; case WM_KILLFOCUS: PrepareActivityState(false); @@ -1463,7 +1466,7 @@ u8 PADpoll(u8 value) } } -keyEvent* PADkeyEvent() +HostKeyEvent* PADkeyEvent() { // If running both pads, ignore every other call. So if two keys pressed in same interval... static char eventCount = 0; @@ -1475,7 +1478,7 @@ keyEvent* PADkeyEvent() eventCount = 0; Update(2, 0); - static keyEvent ev; + static HostKeyEvent ev; if (!GetQueuedKeyEvent(&ev)) return 0; @@ -1485,7 +1488,7 @@ keyEvent* PADkeyEvent() if (!activeWindow) altDown = shiftDown = 0; - if (miceEnabled && (ev.key == VK_ESCAPE || (int)ev.key == -2) && ev.evt == KEYPRESS) + if (miceEnabled && (ev.key == VK_ESCAPE || (int)ev.key == -2) && ev.type == HostKeyEvent::Type::KeyPressed) { // Disable mouse/KB hooks on escape (before going into paused mode). // This is a hack, since PADclose (which is called on pause) should enevtually also deactivate the @@ -1507,7 +1510,7 @@ keyEvent* PADkeyEvent() if (ev.key == VK_LSHIFT || ev.key == VK_RSHIFT || ev.key == VK_SHIFT) { ev.key = VK_SHIFT; - shiftDown = (ev.evt == KEYPRESS); + shiftDown = (ev.type == HostKeyEvent::Type::KeyReleased); } else if (ev.key == VK_LCONTROL || ev.key == VK_RCONTROL) { @@ -1516,7 +1519,7 @@ keyEvent* PADkeyEvent() else if (ev.key == VK_LMENU || ev.key == VK_RMENU || ev.key == VK_SHIFT) { ev.key = VK_MENU; - altDown = (ev.evt == KEYPRESS); + altDown = (ev.type == HostKeyEvent::Type::KeyPressed); } #endif return &ev; diff --git a/pcsx2/PAD/Windows/PAD.h b/pcsx2/PAD/Windows/PAD.h index ecb49fb925..98f1808d64 100644 --- a/pcsx2/PAD/Windows/PAD.h +++ b/pcsx2/PAD/Windows/PAD.h @@ -33,17 +33,18 @@ #include #include -#include "gui/App.h" #include "SaveState.h" -typedef struct +struct HostKeyEvent; + +struct PadDataS { unsigned char controllerType; unsigned short buttonStatus; unsigned char rightJoyX, rightJoyY, leftJoyX, leftJoyY; unsigned char moveX, moveY; unsigned char reserved[91]; -} PadDataS; +}; void PADupdate(int pad); void PADshutdown(); @@ -52,7 +53,7 @@ s32 PADopen(void* pDsp); void PADclose(); u8 PADstartPoll(int pad); u8 PADpoll(u8 value); -keyEvent* PADkeyEvent(); +HostKeyEvent* PADkeyEvent(); void PADconfigure(); s32 PADfreeze(FreezeAction mode, freezeData* data); s32 PADsetSlot(u8 port, u8 slot); diff --git a/pcsx2/PAD/Windows/WindowsKeyboard.cpp b/pcsx2/PAD/Windows/WindowsKeyboard.cpp index 0466062295..7a2a606a47 100644 --- a/pcsx2/PAD/Windows/WindowsKeyboard.cpp +++ b/pcsx2/PAD/Windows/WindowsKeyboard.cpp @@ -51,9 +51,9 @@ void WindowsKeyboard::UpdateKey(int vkey, int state) // Check for alt-F4 to avoid toggling skip mode incorrectly. if (vkey != VK_F4 || !(physicalControlState[VK_MENU] || physicalControlState[VK_RMENU] || physicalControlState[VK_LMENU])) { - int event = KEYPRESS; + HostKeyEvent::Type event = HostKeyEvent::Type::KeyPressed; if (!newState) - event = KEYRELEASE; + event = HostKeyEvent::Type::KeyReleased; QueueKeyEvent(vkey, event); } } diff --git a/pcsx2/gui/App.h b/pcsx2/gui/App.h index 9c42071cf7..fd11031761 100644 --- a/pcsx2/gui/App.h +++ b/pcsx2/gui/App.h @@ -33,17 +33,11 @@ #endif class DisassemblyDialog; - -#include "System.h" -#include "System/SysThreads.h" +struct HostKeyEvent; #include "GS.h" - -typedef struct _keyEvent -{ - u32 key; - u32 evt; -} keyEvent; +#include "System.h" +#include "System/SysThreads.h" extern uptr pDsp[2]; @@ -641,7 +635,7 @@ protected: bool TryOpenConfigCwd(); void CleanupOnExit(); void OpenWizardConsole(); - void PadKeyDispatch(const keyEvent& ev); + void PadKeyDispatch(const HostKeyEvent& ev); protected: void HandleEvent(wxEvtHandler* handler, wxEventFunction func, wxEvent& event) const; diff --git a/pcsx2/gui/AppMain.cpp b/pcsx2/gui/AppMain.cpp index 018daadce4..80e43213b6 100644 --- a/pcsx2/gui/AppMain.cpp +++ b/pcsx2/gui/AppMain.cpp @@ -18,6 +18,7 @@ #include "MainFrame.h" #include "GSFrame.h" #include "GS.h" +#include "Host.h" #include "AppSaveStates.h" #include "AppGameDatabase.h" #include "AppAccelerators.h" @@ -202,9 +203,9 @@ extern int TranslateVKToWXK( u32 keysym ); extern int TranslateGDKtoWXK( u32 keysym ); #endif -void Pcsx2App::PadKeyDispatch( const keyEvent& ev ) +void Pcsx2App::PadKeyDispatch(const HostKeyEvent& ev) { - m_kevt.SetEventType( ( ev.evt == KEYPRESS ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ); + m_kevt.SetEventType( ( ev.type == HostKeyEvent::Type::KeyPressed ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ); //returns 0 for normal keys and a WXK_* value for special keys #ifdef __WXMSW__ @@ -489,7 +490,7 @@ void Pcsx2App::LogicalVsync() if( (wxGetApp().GetGsFramePtr() != NULL) ) PADupdate(0); - while( const keyEvent* ev = PADkeyEvent() ) + while( const HostKeyEvent* ev = PADkeyEvent() ) { if( ev->key == 0 ) break; @@ -498,7 +499,7 @@ void Pcsx2App::LogicalVsync() // sucked and we had multiple components battling for input processing. I managed to make // most of them go away during the plugin merge but GS still needs to process the inputs, // we might want to move all the input handling in a frontend-specific file in the future -- govanify - GSkeyEvent((GSKeyEventData*)ev); + GSkeyEvent(*ev); PadKeyDispatch( *ev ); } } @@ -540,7 +541,7 @@ void Pcsx2App::HandleEvent(wxEvtHandler* handler, wxEventFunction func, wxEvent& // When the GSFrame CoreThread is paused, so is the logical VSync // Meaning that we have to grab the user-input through here to potentially // resume emulation. - if (const keyEvent* ev = PADkeyEvent() ) + if (const HostKeyEvent* ev = PADkeyEvent() ) { if( ev->key != 0 ) { diff --git a/pcsx2/gui/FrameForGS.cpp b/pcsx2/gui/FrameForGS.cpp index e17f3998c5..9ec13903bc 100644 --- a/pcsx2/gui/FrameForGS.cpp +++ b/pcsx2/gui/FrameForGS.cpp @@ -274,21 +274,21 @@ void GSPanel::OnMouseEvent( wxMouseEvent& evt ) #if defined(__unix__) // HACK2: In gsopen2 there is one event buffer read by both wx/gui and pad. Wx deletes // the event before the pad see it. So you send key event directly to the pad. - keyEvent event; + HostKeyEvent event; // FIXME how to handle double click ??? if (evt.ButtonDown()) { - event.evt = 4; // X equivalent of ButtonPress + event.type = static_cast(4); // X equivalent of ButtonPress event.key = evt.GetButton(); } else if (evt.ButtonUp()) { - event.evt = 5; // X equivalent of ButtonRelease + event.type = static_cast(5); // X equivalent of ButtonRelease event.key = evt.GetButton(); } else if (evt.Moving() || evt.Dragging()) { - event.evt = 6; // X equivalent of MotionNotify + event.type = static_cast(6); // X equivalent of MotionNotify long x, y; evt.GetPosition(&x, &y); @@ -314,7 +314,7 @@ void GSPanel::OnMouseEvent( wxMouseEvent& evt ) else { event.key = 0; - event.evt = 0; + event.type = HostKeyEvent::Type::NoEvent; } PADWriteEvent(event); @@ -341,14 +341,14 @@ void GSPanel::OnKeyDownOrUp( wxKeyEvent& evt ) #if defined(__unix__) // HACK2: In gsopen2 there is one event buffer read by both wx/gui and pad. Wx deletes // the event before the pad see it. So you send key event directly to the pad. - keyEvent event; + HostKeyEvent event; event.key = evt.GetRawKeyCode(); if (evt.GetEventType() == wxEVT_KEY_UP) - event.evt = 3; // X equivalent of KEYRELEASE; + event.type = static_cast(3); // X equivalent of KEYRELEASE; else if (evt.GetEventType() == wxEVT_KEY_DOWN) - event.evt = 2; // X equivalent of KEYPRESS; + event.type = static_cast(2); // X equivalent of KEYPRESS; else - event.evt = 0; + event.type = HostKeyEvent::Type::NoEvent; PADWriteEvent(event); #endif @@ -424,7 +424,7 @@ void GSPanel::OnFocus( wxFocusEvent& evt ) #if defined(__unix__) // HACK2: In gsopen2 there is one event buffer read by both wx/gui and pad. Wx deletes // the event before the pad see it. So you send key event directly to the pad. - keyEvent event = {0, 9}; // X equivalent of FocusIn; + HostKeyEvent event = {static_cast(9), 0}; // X equivalent of FocusIn; PADWriteEvent(event); #endif //Console.Warning("GS frame > focus set"); @@ -440,7 +440,7 @@ void GSPanel::OnFocusLost( wxFocusEvent& evt ) #if defined(__unix__) // HACK2: In gsopen2 there is one event buffer read by both wx/gui and pad. Wx deletes // the event before the pad see it. So you send key event directly to the pad. - keyEvent event = {0, 10}; // X equivalent of FocusOut + HostKeyEvent event = {static_cast(9), 0}; // X equivalent of FocusOut PADWriteEvent(event); #endif //Console.Warning("GS frame > focus lost"); diff --git a/pcsx2/pcsx2.vcxproj b/pcsx2/pcsx2.vcxproj index 2a8100789f..6e22520c23 100644 --- a/pcsx2/pcsx2.vcxproj +++ b/pcsx2/pcsx2.vcxproj @@ -769,6 +769,7 @@ + diff --git a/pcsx2/pcsx2.vcxproj.filters b/pcsx2/pcsx2.vcxproj.filters index 6288065600..8dbb9e1759 100644 --- a/pcsx2/pcsx2.vcxproj.filters +++ b/pcsx2/pcsx2.vcxproj.filters @@ -2767,6 +2767,9 @@ System\Ps2\Iop + + System\Include +