onepad: fix keyboard on 2nd pad

There is only a single event queue, so you need to detect the pad based
on the configuration

Mouse/Wiimote is limited to first pad

Related to issue 
This commit is contained in:
Gregory Hainaut 2016-07-08 19:04:55 +02:00
parent eefe3e8d4f
commit 8b3e04d1b6
3 changed files with 25 additions and 11 deletions

View File

@ -172,13 +172,18 @@ EXPORT_C_(void) PADupdate(int pad)
// Actually PADupdate is always call with pad == 0. So you need to update both // Actually PADupdate is always call with pad == 0. So you need to update both
// pads -- Gregory // pads -- Gregory
for (int cpad = 0; cpad < GAMEPAD_NUMBER; cpad++) {
// Poll keyboard/mouse event
key_status->keyboard_state_acces(cpad);
PollForX11KeyboardInput(cpad);
// Get joystick state // Poll keyboard/mouse event. There is currently no way to separate pad0 from pad1 event.
// So we will populate both pad in the same time
for (int cpad = 0; cpad < GAMEPAD_NUMBER; cpad++) {
key_status->keyboard_state_acces(cpad);
}
PollForX11KeyboardInput();
// Get joystick state + Commit
for (int cpad = 0; cpad < GAMEPAD_NUMBER; cpad++) {
key_status->joystick_state_acces(cpad); key_status->joystick_state_acces(cpad);
PollForJoystickInput(cpad); PollForJoystickInput(cpad);
key_status->commit_status(cpad); key_status->commit_status(cpad);

View File

@ -56,10 +56,19 @@ static bool s_grab_input = false;
static bool s_Shift = false; 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(int pad, keyEvent &evt) void AnalyzeKeyEvent(keyEvent &evt)
{ {
KeySym key = (KeySym)evt.key; KeySym key = (KeySym)evt.key;
int index = get_keyboard_key(pad, key); int pad = 0;
int index = -1;
for (int cpad = 0; cpad < GAMEPAD_NUMBER; cpad++) {
int tmp_index = get_keyboard_key(cpad, key);
if (tmp_index != -1) {
pad = cpad;
index = tmp_index;
}
}
switch (evt.evt) switch (evt.evt)
{ {
@ -194,14 +203,14 @@ void AnalyzeKeyEvent(int pad, keyEvent &evt)
} }
} }
void PollForX11KeyboardInput(int pad) void PollForX11KeyboardInput()
{ {
keyEvent evt; keyEvent evt;
XEvent E; XEvent E;
// Keyboard input send by PCSX2 // Keyboard input send by PCSX2
while (!ev_fifo.empty()) { while (!ev_fifo.empty()) {
AnalyzeKeyEvent(pad, ev_fifo.front()); AnalyzeKeyEvent(ev_fifo.front());
pthread_spin_lock(&mutex_KeyEvent); pthread_spin_lock(&mutex_KeyEvent);
ev_fifo.pop(); ev_fifo.pop();
pthread_spin_unlock(&mutex_KeyEvent); pthread_spin_unlock(&mutex_KeyEvent);
@ -227,7 +236,7 @@ void PollForX11KeyboardInput(int pad)
evt.key = (int)XLookupKeysym(&E.xkey, 0); evt.key = (int)XLookupKeysym(&E.xkey, 0);
} }
AnalyzeKeyEvent(pad, evt); AnalyzeKeyEvent(evt);
} }
} }

View File

@ -29,7 +29,7 @@
#include "Linux/linux.h" #include "Linux/linux.h"
extern Display *GSdsp; extern Display *GSdsp;
extern void PollForX11KeyboardInput(int pad); extern void PollForX11KeyboardInput();
extern bool PollX11KeyboardMouseEvent(u32 &pkey); extern bool PollX11KeyboardMouseEvent(u32 &pkey);
extern Window GSwin; extern Window GSwin;