summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerInterface
diff options
context:
space:
mode:
authorAdmiral H. Curtiss <pikachu025@gmail.com>2023-05-19 19:29:24 +0200
committerGitHub <noreply@github.com>2023-05-19 19:29:24 +0200
commit279fcafdc32354063ecc9ec3ad0512f6eb6b75fc (patch)
tree63e9e28ea9f81e94d034a8c504f7a27cf1b36f03 /Source/Core/InputCommon/ControllerInterface
parent3905288465bd608ef44a773ff625e459f6e07f7c (diff)
parentc6f9e61d38f674d81ba8786739f9fe38490670d0 (diff)
Merge pull request #11758 from jbosboom/xinput2-client-pointer
XInput2: Accept input from keyboards other than the first master
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface')
-rw-r--r--Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp b/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp
index e9f8d2fff2..07d8e4bfa5 100644
--- a/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp
@@ -166,6 +166,10 @@ KeyboardMouse::KeyboardMouse(Window window, int opcode, int pointer, int keyboar
name = std::string(pointer_device->name);
XIFreeDeviceInfo(pointer_device);
+ // Tell core X functions which keyboard is "the" keyboard for this
+ // X connection.
+ XISetClientPointer(m_display, None, pointer_deviceid);
+
{
unsigned char mask_buf[(XI_LASTEVENT + 7) / 8] = {};
XISetMask(mask_buf, XI_ButtonPress);
@@ -387,6 +391,10 @@ void KeyboardMouse::UpdateInput()
// KeyRelease and FocusOut events are sometimes not received.
// Cycling Alt-Tab and landing on the same window results in a stuck "Alt" key.
// Unpressed keys are released here.
+ // Because we called XISetClientPointer in the constructor, XQueryKeymap
+ // will return the state of the associated keyboard, even if it isn't the
+ // first master keyboard. (XInput2 doesn't provide a function to query
+ // keyboard state.)
std::array<char, 32> keyboard;
XQueryKeymap(m_display, keyboard.data());
for (size_t i = 0; i != keyboard.size(); ++i)