fix(input): pre-enable all event codes, eliminate uinput recreate#554
Open
jelmerdehen wants to merge 1 commit intoPixlOne:mainfrom
Open
fix(input): pre-enable all event codes, eliminate uinput recreate#554jelmerdehen wants to merge 1 commit intoPixlOne:mainfrom
jelmerdehen wants to merge 1 commit intoPixlOne:mainfrom
Conversation
InputDevice originally enabled the first 128 EV_KEY codes in the
constructor and then destroyed and recreated the libevdev_uinput
device every time a new key or axis was registered through
KeypressAction or other consumers. Two problems followed:
* libevdev_uinput_create_from_device could fail mid-life, leaving
'device' and 'ui_device' set to nullptr while the daemon kept
running. Subsequent send/register calls would then dereference
nullptr.
* Every registration tore down the kernel uinput node, which
changed the /dev/input/eventN device under the feet of any
application that had the node open and produced spurious
add/remove events through udev.
Enable every valid EV_KEY and EV_REL code up-front in the constructor
and turn registerKey/registerAxis into no-ops. The uinput node is now
created exactly once, lives for the daemon's lifetime, and never has
its event-code set mutated. _enableEvent is dropped.
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
InputDeviceoriginally enabled the first 128 EV_KEY codes in the constructor and then destroyed and recreated the libevdev_uinput device every time a new key or axis was registered throughKeypressActionor other consumers. Two problems followed:libevdev_uinput_create_from_devicecould fail mid-life, leavingdeviceandui_deviceset tonullptrwhile the daemon kept running. Subsequent send/register calls would then dereference nullptr./dev/input/eventNunder the feet of any application that had the node open and produced spurious add/remove events through udev.Fix
Enable every valid EV_KEY and EV_REL code up-front in the constructor, using
libevdev_event_code_get_nameto filter to the codes the kernel actually defines.registerKeyandregisterAxisbecome no-ops. The uinput node is now created exactly once, lives for the daemon's lifetime, and never has its event-code set mutated._enableEventis dropped.Supersedes #549 (
fix/input-device-nullptr-guard), which only papers over symptom (1).Test plan
KeypressActionstill works for previously-unregistered keys./dev/input/eventNfor the LogiOps virtual input device stays stable across config reloads.