mirror of https://github.com/PCSX2/pcsx2.git
onepad-legacy: Use mt_queue, and move it from onepad to common. (#3060)
This commit is contained in:
parent
4e58558eb7
commit
ed6ac00186
|
@ -221,24 +221,16 @@ void PollForX11KeyboardInput()
|
||||||
XEvent E = {0};
|
XEvent E = {0};
|
||||||
|
|
||||||
// Keyboard input send by PCSX2
|
// Keyboard input send by PCSX2
|
||||||
while (!ev_fifo.empty())
|
g_ev_fifo.consume_all(AnalyzeKeyEvent);
|
||||||
{
|
|
||||||
AnalyzeKeyEvent(ev_fifo.front());
|
|
||||||
pthread_spin_lock(&mutex_KeyEvent);
|
|
||||||
ev_fifo.pop();
|
|
||||||
pthread_spin_unlock(&mutex_KeyEvent);
|
|
||||||
}
|
|
||||||
|
|
||||||
// keyboard input
|
// keyboard input
|
||||||
while (XPending(GSdsp) > 0)
|
while (XPending(GSdsp) > 0) {
|
||||||
{
|
|
||||||
XNextEvent(GSdsp, &E);
|
XNextEvent(GSdsp, &E);
|
||||||
|
|
||||||
// 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.evt = E.type;
|
||||||
switch (E.type)
|
switch (E.type) {
|
||||||
{
|
|
||||||
case MotionNotify:
|
case MotionNotify:
|
||||||
evt.key = (E.xbutton.x & 0xFFFF) | (E.xbutton.y << 16);
|
evt.key = (E.xbutton.x & 0xFFFF) | (E.xbutton.y << 16);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -53,11 +53,8 @@ const u32 build = 3; // increase that with each version
|
||||||
|
|
||||||
FILE *padLog = NULL;
|
FILE *padLog = NULL;
|
||||||
|
|
||||||
pthread_spinlock_t mutex_KeyEvent;
|
|
||||||
bool mutex_WasInit = false;
|
|
||||||
KeyStatus *key_status = NULL;
|
KeyStatus *key_status = NULL;
|
||||||
|
MtQueue<keyEvent> g_ev_fifo;
|
||||||
std::queue<keyEvent> ev_fifo;
|
|
||||||
|
|
||||||
static void InitLibraryName()
|
static void InitLibraryName()
|
||||||
{
|
{
|
||||||
|
@ -193,11 +190,7 @@ EXPORT_C_(s32) PADopen(void *pDsp)
|
||||||
{
|
{
|
||||||
memset(&event, 0, sizeof(event));
|
memset(&event, 0, sizeof(event));
|
||||||
key_status->Init();
|
key_status->Init();
|
||||||
|
g_ev_fifo.reset();
|
||||||
while (!ev_fifo.empty())
|
|
||||||
ev_fifo.pop();
|
|
||||||
pthread_spin_init(&mutex_KeyEvent, PTHREAD_PROCESS_PRIVATE);
|
|
||||||
mutex_WasInit = true;
|
|
||||||
|
|
||||||
#if defined(__unix__)
|
#if defined(__unix__)
|
||||||
GamePad::EnumerateGamePads(s_vgamePad);
|
GamePad::EnumerateGamePads(s_vgamePad);
|
||||||
|
@ -223,10 +216,6 @@ EXPORT_C_(void) PADsetLogDir(const char *dir)
|
||||||
|
|
||||||
EXPORT_C_(void) PADclose()
|
EXPORT_C_(void) PADclose()
|
||||||
{
|
{
|
||||||
while (!ev_fifo.empty())
|
|
||||||
ev_fifo.pop();
|
|
||||||
mutex_WasInit = false;
|
|
||||||
pthread_spin_destroy(&mutex_KeyEvent);
|
|
||||||
_PADclose();
|
_PADclose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -349,13 +338,6 @@ EXPORT_C_(keyEvent *) PADkeyEvent()
|
||||||
#if defined(__unix__)
|
#if defined(__unix__)
|
||||||
EXPORT_C_(void) PADWriteEvent(keyEvent &evt)
|
EXPORT_C_(void) PADWriteEvent(keyEvent &evt)
|
||||||
{
|
{
|
||||||
// This function call be called before PADopen. Therefore we cann't
|
g_ev_fifo.push(evt);
|
||||||
// guarantee that the spin lock was initialized
|
|
||||||
if (mutex_WasInit)
|
|
||||||
{
|
|
||||||
pthread_spin_lock(&mutex_KeyEvent);
|
|
||||||
ev_fifo.push(evt);
|
|
||||||
pthread_spin_unlock(&mutex_KeyEvent);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -43,7 +43,8 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <pthread.h>
|
#include <mutex>
|
||||||
|
#include <queue>
|
||||||
|
|
||||||
#define PADdefs
|
#define PADdefs
|
||||||
#include "PS2Edefs.h"
|
#include "PS2Edefs.h"
|
||||||
|
@ -54,6 +55,7 @@
|
||||||
#include "bitwise.h"
|
#include "bitwise.h"
|
||||||
#include "controller.h"
|
#include "controller.h"
|
||||||
#include "KeyStatus.h"
|
#include "KeyStatus.h"
|
||||||
|
#include "mt_queue.h"
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#define EXPORT_C_(type) extern "C" __declspec(dllexport) type CALLBACK
|
#define EXPORT_C_(type) extern "C" __declspec(dllexport) type CALLBACK
|
||||||
|
@ -122,8 +124,7 @@ enum gamePadValues {
|
||||||
};
|
};
|
||||||
|
|
||||||
extern keyEvent event;
|
extern keyEvent event;
|
||||||
extern std::queue<keyEvent> ev_fifo;
|
extern MtQueue<keyEvent> g_ev_fifo;
|
||||||
extern pthread_spinlock_t mutex_KeyEvent;
|
|
||||||
|
|
||||||
void clearPAD(int pad);
|
void clearPAD(int pad);
|
||||||
s32 _PADopen(void *pDsp);
|
s32 _PADopen(void *pDsp);
|
||||||
|
|
Loading…
Reference in New Issue