Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use XInput2 for processing all input events and extracting all devices' properties on Linux #3750

Open
madmiraal opened this issue Jan 4, 2022 · 0 comments

Comments

@madmiraal
Copy link

madmiraal commented Jan 4, 2022

Describe the project you are working on

N/A

Describe the problem or limitation you are having in your project

As identified in godotengine/godot#23439, InputEvent's device property is always 0. Not being able to differentiate between devices causes issues such as godotengine/godot#53033. In addition, there are various proposals that require differentiating between devices and obtaining a device's properties (#19, #426, #3749).

Currently, on the linuxbsd platform, a combination of the core input protocol and XInput2 is used to process input events. XInput2 is currently only used for touch events, retrieving raw motion data and extracting tablet pen properties. The core input protocol does not provide information about which device generated the event. XInput2 does. XInput2 also provides the ability to extract all devices' properties.

Note: When support for touch events was added (godotengine/godot#14347) in 2017, it was not assumed XInput2 would be available. However when support for retrieving raw motion data was added (godotengine/godot@cf124b1) in 2018, it was assumed XInput 2.0 would be available. XInput 2.0 has been available since 2009 and v2.3 (the current version) has been available since 2012[1]; although currently we only require XInput 2.2 (for touch events). I think it's safe to assume that XInput2 v2.2 is available.

[1] https://gitlab.freedesktop.org/xorg/proto/inputproto/-/blob/master/specs/XI2proto.txt

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Use XInput2, which contains the source device's id, instead of the core input protocol to process input events.
Use XInput2's to extract device info so it's available for #3749.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

  • Use XInput2's XIDeviceEvents for XI_KeyPress, XI_KeyRelease, XI_ButtonPress, XI_ButtonRelease, XI_Motion, XI_TouchBegin, XI_TouchUpdate and XI_TouchEnd events.
  • Use XInput2's XIDeviceEvent.sourceid member to assign InputEvent's device property.
  • Stop processing the core protocol's XKeyEvent, XButtonEvent and XMotionEvents for KeyPress, KeyRelease, ButtonPress, ButtonRelease and MotionNotify events.
  • Use XInput2's XIDeviceInfo to extract all device info for all input devices.

If this enhancement will not be used often, can it be worked around with a few lines of script?

No

Is there a reason why this should be core and not an add-on in the asset library?

It's linuxbsd platform code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants