Skip to content

Commit

Permalink
Merge pull request #11758 from jbosboom/xinput2-client-pointer
Browse files Browse the repository at this point in the history
XInput2: Accept input from keyboards other than the first master
  • Loading branch information
AdmiralCurtiss committed May 19, 2023
2 parents 3905288 + c6f9e61 commit 279fcaf
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 279fcaf

Please sign in to comment.