summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerInterface
diff options
context:
space:
mode:
authorJeffrey Bosboom <jbosboom@jeffreybosboom.com>2023-04-15 02:13:03 -0700
committerJeffrey Bosboom <jbosboom@jeffreybosboom.com>2023-05-19 14:20:10 -0700
commit620955d397d4c40aca06a0811294ccb90a6434f0 (patch)
treea668689ab6803ea047ff7b8dd84f438a706ff107 /Source/Core/InputCommon/ControllerInterface
parentb2a98c41eef80a28519d87abeb28c8869af1e403 (diff)
XInput2: Listen to master devices only
A comment removed by this commit gives two reasons for listening to slave devices, both of which no longer apply: - "Only slaves emit raw motion events": perhaps this was true when the comment was written, but now master devices provide raw motion events along with the other raw events. - "Selecting slave keyboards avoids dealing with key focus": we get raw key events regardless of the focus. Listening to both master and slave devices results in duplicate raw events. For button and key events, that's a tiny waste of time setting the update flag a second time, but for raw mouse events the raw motion will be processed twice. That makes this commit a user-facing change.
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface')
-rw-r--r--Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp40
-rw-r--r--Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.h1
2 files changed, 4 insertions, 37 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp b/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp
index 4c47da4fc5..d90139fe03 100644
--- a/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp
@@ -130,39 +130,6 @@ void PopulateDevices(void* const hwnd)
XIFreeDeviceInfo(all_masters);
}
-// Apply the event mask to the device and all its slaves. Only used in the
-// constructor. Remember, each KeyboardMouse has its own copy of the event
-// stream, which is how multiple event masks can "coexist."
-void KeyboardMouse::SelectEventsForDevice(XIEventMask* mask, int deviceid)
-{
- // Set the event mask for the master device.
- mask->deviceid = deviceid;
- XISelectEvents(m_display, DefaultRootWindow(m_display), mask, 1);
-
- // Query all the master device's slaves and set the same event mask for
- // those too. There are two reasons we want to do this. For mouse devices,
- // we want the raw motion events, and only slaves (i.e. physical hardware
- // devices) emit those. For keyboard devices, selecting slaves avoids
- // dealing with key focus.
-
- int num_slaves;
- XIDeviceInfo* const all_slaves = XIQueryDevice(m_display, XIAllDevices, &num_slaves);
-
- for (int i = 0; i < num_slaves; i++)
- {
- XIDeviceInfo* const slave = &all_slaves[i];
- if ((slave->use != XISlavePointer && slave->use != XISlaveKeyboard) ||
- slave->attachment != deviceid)
- {
- continue;
- }
- mask->deviceid = slave->deviceid;
- XISelectEvents(m_display, DefaultRootWindow(m_display), mask, 1);
- }
-
- XIFreeDeviceInfo(all_slaves);
-}
-
KeyboardMouse::KeyboardMouse(Window window, int opcode, int pointer, int keyboard,
double scroll_increment_)
: m_window(window), xi_opcode(opcode), pointer_deviceid(pointer), keyboard_deviceid(keyboard),
@@ -198,7 +165,8 @@ KeyboardMouse::KeyboardMouse(Window window, int opcode, int pointer, int keyboar
mask.mask = mask_buf;
mask.mask_len = sizeof(mask_buf);
- SelectEventsForDevice(&mask, pointer_deviceid);
+ mask.deviceid = pointer_deviceid;
+ XISelectEvents(m_display, DefaultRootWindow(m_display), &mask, 1);
}
{
@@ -209,8 +177,8 @@ KeyboardMouse::KeyboardMouse(Window window, int opcode, int pointer, int keyboar
XIEventMask mask;
mask.mask = mask_buf;
mask.mask_len = sizeof(mask_buf);
-
- SelectEventsForDevice(&mask, keyboard_deviceid);
+ mask.deviceid = keyboard_deviceid;
+ XISelectEvents(m_display, DefaultRootWindow(m_display), &mask, 1);
}
// Keyboard Keys
diff --git a/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.h b/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.h
index 52c78ab752..6a4f8436f1 100644
--- a/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.h
+++ b/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.h
@@ -108,7 +108,6 @@ private:
};
private:
- void SelectEventsForDevice(XIEventMask* mask, int deviceid);
void UpdateCursor(bool should_center_mouse);
public: