Rename keyEvent to HostKeyEvent

This commit is contained in:
Connor McLaughlin 2021-09-18 11:31:36 +10:00 committed by Kojin
parent c234f83ca6
commit 3fdab1222b
24 changed files with 128 additions and 108 deletions

View File

@ -29,11 +29,6 @@
#include "VUmicro.h" #include "VUmicro.h"
#include "ps2/HwInternal.h" #include "ps2/HwInternal.h"
#ifdef _WIN32
#include "PAD/Windows/PAD.h"
#else
#include "PAD/Linux/PAD.h"
#endif
#include "Sio.h" #include "Sio.h"
#ifndef DISABLE_RECORDING #ifndef DISABLE_RECORDING

View File

@ -247,7 +247,7 @@ void iDumpBlock(u32 ee_pc, u32 ee_size, uptr x86_pc, u32 x86_size)
// handy but slow solution (system call) // handy but slow solution (system call)
#ifdef __linux__ #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"); wxFFile objdump(obj_filename , L"wb");
objdump.Write(x86, x86_size); objdump.Write(x86, x86_size);
objdump.Close(); objdump.Close();

View File

@ -658,7 +658,7 @@ uint32 GSmakeSnapshot(char* path)
} }
} }
void GSkeyEvent(GSKeyEventData* e) void GSkeyEvent(const HostKeyEvent& e)
{ {
try try
{ {

View File

@ -1711,16 +1711,6 @@ struct GSPrivRegSet
#pragma pack(pop) #pragma pack(pop)
enum
{
KEYPRESS = 1,
KEYRELEASE = 2
};
struct GSKeyEventData
{
uint32 key, type;
};
// ST_WRITE is defined in libc, avoid this // ST_WRITE is defined in libc, avoid this
enum stateType enum stateType
{ {
@ -1774,6 +1764,8 @@ enum class CRCHackLevel : int8
Aggressive Aggressive
}; };
struct HostKeyEvent;
#ifdef ENABLE_ACCURATE_BUFFER_EMULATION #ifdef ENABLE_ACCURATE_BUFFER_EMULATION
const GSVector2i default_rt_size(2048, 2048); const GSVector2i default_rt_size(2048, 2048);
#else #else
@ -1802,7 +1794,7 @@ void GSgifTransfer2(uint8* mem, uint32 size);
void GSgifTransfer3(uint8* mem, uint32 size); void GSgifTransfer3(uint8* mem, uint32 size);
void GSvsync(int field); void GSvsync(int field);
uint32 GSmakeSnapshot(char* path); uint32 GSmakeSnapshot(char* path);
void GSkeyEvent(GSKeyEventData* e); void GSkeyEvent(const HostKeyEvent& e);
int GSfreeze(FreezeAction mode, freezeData* data); int GSfreeze(FreezeAction mode, freezeData* data);
void GSconfigure(); void GSconfigure();
int GStest(); int GStest();

View File

@ -15,6 +15,7 @@
#include "PrecompiledHeader.h" #include "PrecompiledHeader.h"
#include "GSRenderer.h" #include "GSRenderer.h"
#include "Host.h"
#include "pcsx2/Config.h" #include "pcsx2/Config.h"
#if defined(__unix__) #if defined(__unix__)
#include <X11/keysym.h> #include <X11/keysym.h>
@ -595,27 +596,27 @@ void GSRenderer::EndCapture()
m_capture.EndCapture(); m_capture.EndCapture();
} }
void GSRenderer::KeyEvent(GSKeyEventData* e) void GSRenderer::KeyEvent(const HostKeyEvent& e)
{ {
#ifndef __APPLE__ // TODO: Add hotkey support on macOS #ifndef __APPLE__ // TODO: Add hotkey support on macOS
#ifdef _WIN32 #ifdef _WIN32
m_shift_key = !!(::GetAsyncKeyState(VK_SHIFT) & 0x8000); m_shift_key = !!(::GetAsyncKeyState(VK_SHIFT) & 0x8000);
m_control_key = !!(::GetAsyncKeyState(VK_CONTROL) & 0x8000); m_control_key = !!(::GetAsyncKeyState(VK_CONTROL) & 0x8000);
#else #else
switch (e->key) switch (e.key)
{ {
case XK_Shift_L: case XK_Shift_L:
case XK_Shift_R: case XK_Shift_R:
m_shift_key = (e->type == KEYPRESS); m_shift_key = (e.type == HostKeyEvent::Type::KeyPressed);
return; return;
case XK_Control_L: case XK_Control_L:
case XK_Control_R: case XK_Control_R:
m_control_key = (e->type == KEYPRESS); m_control_key = (e.type == HostKeyEvent::Type::KeyReleased);
return; return;
} }
#endif #endif
if (e->type == KEYPRESS) if (e.type == HostKeyEvent::Type::KeyPressed)
{ {
int step = m_shift_key ? -1 : 1; int step = m_shift_key ? -1 : 1;
@ -630,7 +631,7 @@ void GSRenderer::KeyEvent(GSKeyEventData* e)
#define VK_HOME XK_Home #define VK_HOME XK_Home
#endif #endif
switch (e->key) switch (e.key)
{ {
case VK_F5: case VK_F5:
m_interlace = (m_interlace + s_interlace_nb + step) % s_interlace_nb; m_interlace = (m_interlace + s_interlace_nb + step) % s_interlace_nb;

View File

@ -20,6 +20,8 @@
#include "GS/GSState.h" #include "GS/GSState.h"
#include "GS/GSCapture.h" #include "GS/GSCapture.h"
struct HostKeyEvent;
class GSRenderer : public GSState class GSRenderer : public GSState
{ {
GSCapture m_capture; GSCapture m_capture;
@ -57,7 +59,7 @@ public:
virtual void ResetDevice(); virtual void ResetDevice();
virtual void VSync(int field); virtual void VSync(int field);
virtual bool MakeSnapshot(const std::string& path); virtual bool MakeSnapshot(const std::string& path);
virtual void KeyEvent(GSKeyEventData* e); virtual void KeyEvent(const HostKeyEvent& e);
virtual bool CanUpscale() { return false; } virtual bool CanUpscale() { return false; }
virtual int GetUpscaleMultiplier() { return 1; } virtual int GetUpscaleMultiplier() { return 1; }
virtual GSVector2i GetCustomResolution() { return GSVector2i(0, 0); } virtual GSVector2i GetCustomResolution() { return GSVector2i(0, 0); }

31
pcsx2/Host.h Normal file
View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "common/Pcsx2Defs.h"
struct HostKeyEvent
{
enum class Type
{
NoEvent = 0,
KeyPressed = 1,
KeyReleased = 2
};
Type type;
u32 key;
};

View File

@ -24,11 +24,6 @@
#include "MTVU.h" #include "MTVU.h"
#include "Elfheader.h" #include "Elfheader.h"
#include "gui/Dialogs/ModalPopups.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. // Uncomment this to enable profiling of the GS RingBufferCopy function.

View File

@ -31,7 +31,6 @@
#include "common/pxStreams.h" #include "common/pxStreams.h"
#include "common/Console.h" #include "common/Console.h"
#include "DebugTools/Debug.h" #include "DebugTools/Debug.h"
#include "gui/App.h"
#define PADdefs #define PADdefs

View File

@ -35,16 +35,16 @@ const u32 build = 0; // increase that with each version
#define PAD_SAVE_STATE_VERSION ((revision << 8) | (build << 0)) #define PAD_SAVE_STATE_VERSION ((revision << 8) | (build << 0))
PADconf g_conf; PADconf g_conf;
keyEvent event; HostKeyEvent event;
static keyEvent s_event; static HostKeyEvent s_event;
std::string s_padstrLogPath("logs/"); std::string s_padstrLogPath("logs/");
FILE* padLog = NULL; FILE* padLog = NULL;
KeyStatus g_key_status; KeyStatus g_key_status;
MtQueue<keyEvent> g_ev_fifo; MtQueue<HostKeyEvent> g_ev_fifo;
void __LogToConsole(const char* fmt, ...) void __LogToConsole(const char* fmt, ...)
@ -240,7 +240,7 @@ u8 PADpoll(u8 value)
} }
// PADkeyEvent is called every vsync (return NULL if no event) // PADkeyEvent is called every vsync (return NULL if no event)
keyEvent* PADkeyEvent() HostKeyEvent* PADkeyEvent()
{ {
#ifdef SDL_BUILD #ifdef SDL_BUILD
// Take the opportunity to handle hot plugging here // Take the opportunity to handle hot plugging here
@ -263,7 +263,7 @@ keyEvent* PADkeyEvent()
{ {
// PAD_LOG("No events in queue, returning empty event\n"); // PAD_LOG("No events in queue, returning empty event\n");
s_event = event; s_event = event;
event.evt = 0; event.type = HostKeyEvent::Type::NoEvent;
event.key = 0; event.key = 0;
return &s_event; return &s_event;
} }
@ -274,14 +274,14 @@ keyEvent* PADkeyEvent()
return &s_event; return &s_event;
#else // MacOS #else // MacOS
s_event = event; s_event = event;
event.evt = 0; event.type = HostKeyEvent::Type::NoEvent;
event.key = 0; event.key = 0;
return &s_event; return &s_event;
#endif #endif
} }
#if defined(__unix__) #if defined(__unix__)
void PADWriteEvent(keyEvent& evt) void PADWriteEvent(HostKeyEvent& evt)
{ {
// if (evt.evt != 6) { // Skip mouse move events for logging // if (evt.evt != 6) { // Skip mouse move events for logging
// PAD_LOG("Pushing Event. Event Type: %d, Key: %d\n", evt.evt, evt.key); // PAD_LOG("Pushing Event. Event Type: %d, Key: %d\n", evt.evt, evt.key);

View File

@ -16,7 +16,9 @@
#pragma once #pragma once
#include "Global.h" #include "Global.h"
#include "Host.h"
#include "common/mt_queue.h" #include "common/mt_queue.h"
#include "SaveState.h"
enum PadOptions enum PadOptions
{ {
@ -32,8 +34,8 @@ enum PadOptions
extern FILE* padLog; extern FILE* padLog;
extern void initLogging(); extern void initLogging();
extern keyEvent event; extern HostKeyEvent event;
extern MtQueue<keyEvent> g_ev_fifo; extern MtQueue<HostKeyEvent> g_ev_fifo;
s32 _PADopen(void* pDsp); s32 _PADopen(void* pDsp);
void _PADclose(); void _PADclose();
@ -50,10 +52,10 @@ s32 PADsetSlot(u8 port, u8 slot);
s32 PADfreeze(FreezeAction mode, freezeData* data); s32 PADfreeze(FreezeAction mode, freezeData* data);
u8 PADstartPoll(int pad); u8 PADstartPoll(int pad);
u8 PADpoll(u8 value); u8 PADpoll(u8 value);
keyEvent* PADkeyEvent(); HostKeyEvent* PADkeyEvent();
void PADupdate(int pad); void PADupdate(int pad);
void PADconfigure(); void PADconfigure();
#if defined(__unix__) #if defined(__unix__)
void PADWriteEvent(keyEvent& evt); void PADWriteEvent(HostKeyEvent& evt);
#endif #endif

View File

@ -20,10 +20,7 @@
#include "Global.h" #include "Global.h"
#include "keyboard.h" #include "keyboard.h"
#include "PAD.h"
#include "common/mt_queue.h"
extern keyEvent event;
extern MtQueue<keyEvent> g_ev_fifo;
/// g_key_status.press but with proper handling for analog buttons /// g_key_status.press but with proper handling for analog buttons
static void PressButton(u32 pad, u32 button) 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_x = 0;
static unsigned int s_previous_mouse_y = 0; static unsigned int s_previous_mouse_y = 0;
void AnalyzeKeyEvent(keyEvent& evt) void AnalyzeKeyEvent(HostKeyEvent& evt)
{ {
KeySym key = (KeySym)evt.key; KeySym key = (KeySym)evt.key;
int pad = 0; int pad = 0;
@ -133,7 +130,7 @@ void AnalyzeKeyEvent(keyEvent& evt)
} }
} }
switch (evt.evt) switch (static_cast<int>(evt.type))
{ {
case KeyPress: case KeyPress:
// Shift F12 is not yet use by pcsx2. So keep it to grab/ungrab input // 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); //PAD_LOG("Key pressed:%d\n", index);
event.evt = KEYPRESS; event.type = HostKeyEvent::Type::KeyPressed;
event.key = key; event.key = key;
break; break;
@ -175,7 +172,7 @@ void AnalyzeKeyEvent(keyEvent& evt)
if (index != -1) if (index != -1)
g_key_status.release(pad, index); g_key_status.release(pad, index);
event.evt = KEYRELEASE; event.type = HostKeyEvent::Type::KeyReleased;
event.key = key; event.key = key;
break; break;
@ -258,7 +255,7 @@ void AnalyzeKeyEvent(keyEvent& evt)
void UpdateKeyboardInput() void UpdateKeyboardInput()
{ {
keyEvent evt = {0}; HostKeyEvent evt = {};
XEvent E = {0}; XEvent E = {0};
// Keyboard input send by PCSX2 // Keyboard input send by PCSX2
@ -271,7 +268,7 @@ void UpdateKeyboardInput()
// Change the format of the structure to be compatible with GSOpen2 // Change the format of the structure to be compatible with GSOpen2
// mode (event come from pcsx2 not X) // mode (event come from pcsx2 not X)
evt.evt = E.type; evt.type = static_cast<HostKeyEvent::Type>(E.type);
switch (E.type) switch (E.type)
{ {
case MotionNotify: case MotionNotify:

View File

@ -16,7 +16,7 @@
#pragma once #pragma once
#include "common/Pcsx2Defs.h" #include "common/Pcsx2Defs.h"
#include "gui/App.h" #include "Host.h"
#if defined(__unix__) || defined(__APPLE__) #if defined(__unix__) || defined(__APPLE__)
@ -29,7 +29,7 @@
#undef DisableScreenSaver #undef DisableScreenSaver
#endif #endif
extern void AnalyzeKeyEvent(keyEvent& evt); extern void AnalyzeKeyEvent(HostKeyEvent& evt);
extern void UpdateKeyboardInput(); extern void UpdateKeyboardInput();
extern bool PollForNewKeyboardKeys(u32& pkey); extern bool PollForNewKeyboardKeys(u32& pkey);
#endif #endif

View File

@ -18,6 +18,7 @@
#include "InputManager.h" #include "InputManager.h"
#include "KeyboardQueue.h" #include "KeyboardQueue.h"
#include "PADConfig.h" #include "PADConfig.h"
#include "Host.h"
InputDeviceManager* dm = 0; InputDeviceManager* dm = 0;
@ -235,9 +236,9 @@ void Device::CalcVirtualState()
if (i < numPhysicalControls) if (i < numPhysicalControls)
continue; continue;
} }
int event = KEYPRESS; HostKeyEvent::Type event = HostKeyEvent::Type::KeyPressed;
if (!(virtualControlState[index] >> 15)) if (!(virtualControlState[index] >> 15))
event = KEYRELEASE; event = HostKeyEvent::Type::KeyReleased;
QueueKeyEvent(c->vkey, event); QueueKeyEvent(c->vkey, event);
} }
} }

View File

@ -24,9 +24,9 @@ static std::mutex cSection;
// Actually points one beyond the last queued event. // Actually points one beyond the last queued event.
static u8 lastQueuedEvent = 0; static u8 lastQueuedEvent = 0;
static u8 nextQueuedEvent = 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<std::mutex> lock(cSection); std::lock_guard<std::mutex> lock(cSection);
@ -34,17 +34,17 @@ void QueueKeyEvent(int key, int event)
// purposes when a game is killing the emulator for whatever reason. // purposes when a game is killing the emulator for whatever reason.
if (nextQueuedEvent == lastQueuedEvent || if (nextQueuedEvent == lastQueuedEvent ||
queuedEvents[nextQueuedEvent].key != VK_ESCAPE || 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 // Clear queue on escape down, bringing escape to front. May do something
// with shift/ctrl/alt and F-keys, later. // with shift/ctrl/alt and F-keys, later.
if (event == KEYPRESS && key == VK_ESCAPE) if (event == HostKeyEvent::Type::KeyPressed && key == VK_ESCAPE)
{ {
nextQueuedEvent = lastQueuedEvent; nextQueuedEvent = lastQueuedEvent;
} }
queuedEvents[lastQueuedEvent].key = key; queuedEvents[lastQueuedEvent].key = key;
queuedEvents[lastQueuedEvent].evt = event; queuedEvents[lastQueuedEvent].type = event;
lastQueuedEvent = (lastQueuedEvent + 1) % EVENT_QUEUE_LEN; lastQueuedEvent = (lastQueuedEvent + 1) % EVENT_QUEUE_LEN;
// If queue wrapped around, remove last element. // 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) if (lastQueuedEvent == nextQueuedEvent)
return 0; return 0;

View File

@ -17,14 +17,16 @@
// This entire thing isn't really needed, // This entire thing isn't really needed,
// but takes little enough effort to be safe... // but takes little enough effort to be safe...
void QueueKeyEvent(int key, int event); #include "Host.h"
int GetQueuedKeyEvent(keyEvent* event);
void QueueKeyEvent(u32 key, HostKeyEvent::Type event);
int GetQueuedKeyEvent(HostKeyEvent* event);
// Cleans up as well as clears queue. // Cleans up as well as clears queue.
void ClearKeyQueue(); void ClearKeyQueue();
#ifdef __linux__ #ifdef __linux__
void R_QueueKeyEvent(const keyEvent& event); void R_QueueKeyEvent(const HostKeyEvent& event);
int R_GetQueuedKeyEvent(keyEvent* event); int R_GetQueuedKeyEvent(HostKeyEvent* event);
void R_ClearKeyQueue(); void R_ClearKeyQueue();
#endif #endif

View File

@ -24,6 +24,7 @@
#include "InputManager.h" #include "InputManager.h"
#include "PADConfig.h" #include "PADConfig.h"
#include "PAD.h" #include "PAD.h"
#include "Host.h"
#include "DeviceEnumerator.h" #include "DeviceEnumerator.h"
#ifdef _MSC_VER #ifdef _MSC_VER
@ -33,6 +34,8 @@
#include "KeyboardQueue.h" #include "KeyboardQueue.h"
#include "DualShock3.h" #include "DualShock3.h"
#include "gui/AppCoreThread.h"
#define WMA_FORCE_UPDATE (WM_APP + 0x537) #define WMA_FORCE_UPDATE (WM_APP + 0x537)
#define FORCE_UPDATE_WPARAM ((WPARAM)0x74328943) #define FORCE_UPDATE_WPARAM ((WPARAM)0x74328943)
#define FORCE_UPDATE_LPARAM ((LPARAM)0x89437437) #define FORCE_UPDATE_LPARAM ((LPARAM)0x89437437)
@ -222,9 +225,9 @@ u8 Cap(int i)
inline void ReleaseModifierKeys() inline void ReleaseModifierKeys()
{ {
QueueKeyEvent(VK_SHIFT, KEYRELEASE); QueueKeyEvent(VK_SHIFT, HostKeyEvent::Type::KeyReleased);
QueueKeyEvent(VK_MENU, KEYRELEASE); QueueKeyEvent(VK_MENU, HostKeyEvent::Type::KeyReleased);
QueueKeyEvent(VK_CONTROL, KEYRELEASE); QueueKeyEvent(VK_CONTROL, HostKeyEvent::Type::KeyReleased);
} }
// RefreshEnabledDevices() enables everything that can potentially // RefreshEnabledDevices() enables everything that can potentially
@ -387,7 +390,7 @@ void ProcessButtonBinding(Binding* b, ButtonSum* sum, int value)
unsigned int t = timeGetTime(); unsigned int t = timeGetTime();
if (t - LastCheck < 300) if (t - LastCheck < 300)
return; return;
QueueKeyEvent(VK_TAB, KEYPRESS); QueueKeyEvent(VK_TAB, HostKeyEvent::Type::KeyPressed);
LastCheck = t; LastCheck = t;
} }
@ -945,7 +948,7 @@ ExtraWndProcResult StatusWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPa
PrepareActivityState(LOWORD(wParam) != WA_INACTIVE); PrepareActivityState(LOWORD(wParam) != WA_INACTIVE);
break; break;
case WM_DESTROY: case WM_DESTROY:
QueueKeyEvent(VK_ESCAPE, KEYPRESS); QueueKeyEvent(VK_ESCAPE, HostKeyEvent::Type::KeyPressed);
break; break;
case WM_KILLFOCUS: case WM_KILLFOCUS:
PrepareActivityState(false); 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... // If running both pads, ignore every other call. So if two keys pressed in same interval...
static char eventCount = 0; static char eventCount = 0;
@ -1475,7 +1478,7 @@ keyEvent* PADkeyEvent()
eventCount = 0; eventCount = 0;
Update(2, 0); Update(2, 0);
static keyEvent ev; static HostKeyEvent ev;
if (!GetQueuedKeyEvent(&ev)) if (!GetQueuedKeyEvent(&ev))
return 0; return 0;
@ -1485,7 +1488,7 @@ keyEvent* PADkeyEvent()
if (!activeWindow) if (!activeWindow)
altDown = shiftDown = 0; 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). // 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 // 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) if (ev.key == VK_LSHIFT || ev.key == VK_RSHIFT || ev.key == VK_SHIFT)
{ {
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) 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) else if (ev.key == VK_LMENU || ev.key == VK_RMENU || ev.key == VK_SHIFT)
{ {
ev.key = VK_MENU; ev.key = VK_MENU;
altDown = (ev.evt == KEYPRESS); altDown = (ev.type == HostKeyEvent::Type::KeyPressed);
} }
#endif #endif
return &ev; return &ev;

View File

@ -33,17 +33,18 @@
#include <mutex> #include <mutex>
#include <queue> #include <queue>
#include "gui/App.h"
#include "SaveState.h" #include "SaveState.h"
typedef struct struct HostKeyEvent;
struct PadDataS
{ {
unsigned char controllerType; unsigned char controllerType;
unsigned short buttonStatus; unsigned short buttonStatus;
unsigned char rightJoyX, rightJoyY, leftJoyX, leftJoyY; unsigned char rightJoyX, rightJoyY, leftJoyX, leftJoyY;
unsigned char moveX, moveY; unsigned char moveX, moveY;
unsigned char reserved[91]; unsigned char reserved[91];
} PadDataS; };
void PADupdate(int pad); void PADupdate(int pad);
void PADshutdown(); void PADshutdown();
@ -52,7 +53,7 @@ s32 PADopen(void* pDsp);
void PADclose(); void PADclose();
u8 PADstartPoll(int pad); u8 PADstartPoll(int pad);
u8 PADpoll(u8 value); u8 PADpoll(u8 value);
keyEvent* PADkeyEvent(); HostKeyEvent* PADkeyEvent();
void PADconfigure(); void PADconfigure();
s32 PADfreeze(FreezeAction mode, freezeData* data); s32 PADfreeze(FreezeAction mode, freezeData* data);
s32 PADsetSlot(u8 port, u8 slot); s32 PADsetSlot(u8 port, u8 slot);

View File

@ -51,9 +51,9 @@ void WindowsKeyboard::UpdateKey(int vkey, int state)
// Check for alt-F4 to avoid toggling skip mode incorrectly. // Check for alt-F4 to avoid toggling skip mode incorrectly.
if (vkey != VK_F4 || !(physicalControlState[VK_MENU] || physicalControlState[VK_RMENU] || physicalControlState[VK_LMENU])) if (vkey != VK_F4 || !(physicalControlState[VK_MENU] || physicalControlState[VK_RMENU] || physicalControlState[VK_LMENU]))
{ {
int event = KEYPRESS; HostKeyEvent::Type event = HostKeyEvent::Type::KeyPressed;
if (!newState) if (!newState)
event = KEYRELEASE; event = HostKeyEvent::Type::KeyReleased;
QueueKeyEvent(vkey, event); QueueKeyEvent(vkey, event);
} }
} }

View File

@ -33,17 +33,11 @@
#endif #endif
class DisassemblyDialog; class DisassemblyDialog;
struct HostKeyEvent;
#include "System.h"
#include "System/SysThreads.h"
#include "GS.h" #include "GS.h"
#include "System.h"
typedef struct _keyEvent #include "System/SysThreads.h"
{
u32 key;
u32 evt;
} keyEvent;
extern uptr pDsp[2]; extern uptr pDsp[2];
@ -641,7 +635,7 @@ protected:
bool TryOpenConfigCwd(); bool TryOpenConfigCwd();
void CleanupOnExit(); void CleanupOnExit();
void OpenWizardConsole(); void OpenWizardConsole();
void PadKeyDispatch(const keyEvent& ev); void PadKeyDispatch(const HostKeyEvent& ev);
protected: protected:
void HandleEvent(wxEvtHandler* handler, wxEventFunction func, wxEvent& event) const; void HandleEvent(wxEvtHandler* handler, wxEventFunction func, wxEvent& event) const;

View File

@ -18,6 +18,7 @@
#include "MainFrame.h" #include "MainFrame.h"
#include "GSFrame.h" #include "GSFrame.h"
#include "GS.h" #include "GS.h"
#include "Host.h"
#include "AppSaveStates.h" #include "AppSaveStates.h"
#include "AppGameDatabase.h" #include "AppGameDatabase.h"
#include "AppAccelerators.h" #include "AppAccelerators.h"
@ -202,9 +203,9 @@ extern int TranslateVKToWXK( u32 keysym );
extern int TranslateGDKtoWXK( u32 keysym ); extern int TranslateGDKtoWXK( u32 keysym );
#endif #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 //returns 0 for normal keys and a WXK_* value for special keys
#ifdef __WXMSW__ #ifdef __WXMSW__
@ -489,7 +490,7 @@ void Pcsx2App::LogicalVsync()
if( (wxGetApp().GetGsFramePtr() != NULL) ) if( (wxGetApp().GetGsFramePtr() != NULL) )
PADupdate(0); PADupdate(0);
while( const keyEvent* ev = PADkeyEvent() ) while( const HostKeyEvent* ev = PADkeyEvent() )
{ {
if( ev->key == 0 ) break; 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 // 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, // 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 // 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 ); 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 // When the GSFrame CoreThread is paused, so is the logical VSync
// Meaning that we have to grab the user-input through here to potentially // Meaning that we have to grab the user-input through here to potentially
// resume emulation. // resume emulation.
if (const keyEvent* ev = PADkeyEvent() ) if (const HostKeyEvent* ev = PADkeyEvent() )
{ {
if( ev->key != 0 ) if( ev->key != 0 )
{ {

View File

@ -274,21 +274,21 @@ void GSPanel::OnMouseEvent( wxMouseEvent& evt )
#if defined(__unix__) #if defined(__unix__)
// HACK2: In gsopen2 there is one event buffer read by both wx/gui and pad. Wx deletes // 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. // 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 ??? // FIXME how to handle double click ???
if (evt.ButtonDown()) if (evt.ButtonDown())
{ {
event.evt = 4; // X equivalent of ButtonPress event.type = static_cast<HostKeyEvent::Type>(4); // X equivalent of ButtonPress
event.key = evt.GetButton(); event.key = evt.GetButton();
} }
else if (evt.ButtonUp()) else if (evt.ButtonUp())
{ {
event.evt = 5; // X equivalent of ButtonRelease event.type = static_cast<HostKeyEvent::Type>(5); // X equivalent of ButtonRelease
event.key = evt.GetButton(); event.key = evt.GetButton();
} }
else if (evt.Moving() || evt.Dragging()) else if (evt.Moving() || evt.Dragging())
{ {
event.evt = 6; // X equivalent of MotionNotify event.type = static_cast<HostKeyEvent::Type>(6); // X equivalent of MotionNotify
long x, y; long x, y;
evt.GetPosition(&x, &y); evt.GetPosition(&x, &y);
@ -314,7 +314,7 @@ void GSPanel::OnMouseEvent( wxMouseEvent& evt )
else else
{ {
event.key = 0; event.key = 0;
event.evt = 0; event.type = HostKeyEvent::Type::NoEvent;
} }
PADWriteEvent(event); PADWriteEvent(event);
@ -341,14 +341,14 @@ void GSPanel::OnKeyDownOrUp( wxKeyEvent& evt )
#if defined(__unix__) #if defined(__unix__)
// HACK2: In gsopen2 there is one event buffer read by both wx/gui and pad. Wx deletes // 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. // the event before the pad see it. So you send key event directly to the pad.
keyEvent event; HostKeyEvent event;
event.key = evt.GetRawKeyCode(); event.key = evt.GetRawKeyCode();
if (evt.GetEventType() == wxEVT_KEY_UP) if (evt.GetEventType() == wxEVT_KEY_UP)
event.evt = 3; // X equivalent of KEYRELEASE; event.type = static_cast<HostKeyEvent::Type>(3); // X equivalent of KEYRELEASE;
else if (evt.GetEventType() == wxEVT_KEY_DOWN) else if (evt.GetEventType() == wxEVT_KEY_DOWN)
event.evt = 2; // X equivalent of KEYPRESS; event.type = static_cast<HostKeyEvent::Type>(2); // X equivalent of KEYPRESS;
else else
event.evt = 0; event.type = HostKeyEvent::Type::NoEvent;
PADWriteEvent(event); PADWriteEvent(event);
#endif #endif
@ -424,7 +424,7 @@ void GSPanel::OnFocus( wxFocusEvent& evt )
#if defined(__unix__) #if defined(__unix__)
// HACK2: In gsopen2 there is one event buffer read by both wx/gui and pad. Wx deletes // 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. // 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<HostKeyEvent::Type>(9), 0}; // X equivalent of FocusIn;
PADWriteEvent(event); PADWriteEvent(event);
#endif #endif
//Console.Warning("GS frame > focus set"); //Console.Warning("GS frame > focus set");
@ -440,7 +440,7 @@ void GSPanel::OnFocusLost( wxFocusEvent& evt )
#if defined(__unix__) #if defined(__unix__)
// HACK2: In gsopen2 there is one event buffer read by both wx/gui and pad. Wx deletes // 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. // 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<HostKeyEvent::Type>(9), 0}; // X equivalent of FocusOut
PADWriteEvent(event); PADWriteEvent(event);
#endif #endif
//Console.Warning("GS frame > focus lost"); //Console.Warning("GS frame > focus lost");

View File

@ -769,6 +769,7 @@
<ClInclude Include="gui\Panels\MemoryCardPanels.h" /> <ClInclude Include="gui\Panels\MemoryCardPanels.h" />
<ClInclude Include="gui\ThreadingDialogs.h" /> <ClInclude Include="gui\ThreadingDialogs.h" />
<ClInclude Include="gui\wxAppWithHelpers.h" /> <ClInclude Include="gui\wxAppWithHelpers.h" />
<ClInclude Include="Host.h" />
<ClInclude Include="IopGte.h" /> <ClInclude Include="IopGte.h" />
<ClInclude Include="IPC.h" /> <ClInclude Include="IPC.h" />
<ClInclude Include="FW.h" /> <ClInclude Include="FW.h" />

View File

@ -2767,6 +2767,9 @@
<ClInclude Include="MemoryCardFile.h"> <ClInclude Include="MemoryCardFile.h">
<Filter>System\Ps2\Iop</Filter> <Filter>System\Ps2\Iop</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="Host.h">
<Filter>System\Include</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="windows\wxResources.rc"> <ResourceCompile Include="windows\wxResources.rc">