diff --git a/plugins/onepad/Linux/linux.cpp b/plugins/onepad/Linux/linux.cpp index 602b1e9519..c0dc6d3336 100644 --- a/plugins/onepad/Linux/linux.cpp +++ b/plugins/onepad/Linux/linux.cpp @@ -172,13 +172,18 @@ EXPORT_C_(void) PADupdate(int pad) // Actually PADupdate is always call with pad == 0. So you need to update both // 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); + PollForJoystickInput(cpad); key_status->commit_status(cpad); diff --git a/plugins/onepad/keyboard.cpp b/plugins/onepad/keyboard.cpp index ae82eb7bc7..eba4356172 100644 --- a/plugins/onepad/keyboard.cpp +++ b/plugins/onepad/keyboard.cpp @@ -56,10 +56,19 @@ static bool s_grab_input = false; static bool s_Shift = false; static unsigned int s_previous_mouse_x = 0; static unsigned int s_previous_mouse_y = 0; -void AnalyzeKeyEvent(int pad, keyEvent &evt) +void AnalyzeKeyEvent(keyEvent &evt) { 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) { @@ -194,14 +203,14 @@ void AnalyzeKeyEvent(int pad, keyEvent &evt) } } -void PollForX11KeyboardInput(int pad) +void PollForX11KeyboardInput() { keyEvent evt; XEvent E; // Keyboard input send by PCSX2 while (!ev_fifo.empty()) { - AnalyzeKeyEvent(pad, ev_fifo.front()); + AnalyzeKeyEvent(ev_fifo.front()); pthread_spin_lock(&mutex_KeyEvent); ev_fifo.pop(); pthread_spin_unlock(&mutex_KeyEvent); @@ -227,7 +236,7 @@ void PollForX11KeyboardInput(int pad) evt.key = (int)XLookupKeysym(&E.xkey, 0); } - AnalyzeKeyEvent(pad, evt); + AnalyzeKeyEvent(evt); } } diff --git a/plugins/onepad/keyboard.h b/plugins/onepad/keyboard.h index 84171e6557..410d1f25b8 100644 --- a/plugins/onepad/keyboard.h +++ b/plugins/onepad/keyboard.h @@ -29,7 +29,7 @@ #include "Linux/linux.h" extern Display *GSdsp; -extern void PollForX11KeyboardInput(int pad); +extern void PollForX11KeyboardInput(); extern bool PollX11KeyboardMouseEvent(u32 &pkey); extern Window GSwin;