Skip to content

fix(input): pre-enable all event codes, eliminate uinput recreate#554

Open
jelmerdehen wants to merge 1 commit intoPixlOne:mainfrom
jelmerdehen:fix/input-device-no-recreate
Open

fix(input): pre-enable all event codes, eliminate uinput recreate#554
jelmerdehen wants to merge 1 commit intoPixlOne:mainfrom
jelmerdehen:fix/input-device-no-recreate

Conversation

@jelmerdehen
Copy link
Copy Markdown

Summary

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:

  1. 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.
  2. Every registration tore down the kernel uinput node, which changed /dev/input/eventN under 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_name to filter to the codes the kernel actually defines. registerKey and registerAxis become 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.

Supersedes #549 (fix/input-device-nullptr-guard), which only papers over symptom (1).

Test plan

  • Builds cleanly.
  • KeypressAction still works for previously-unregistered keys.
  • /dev/input/eventN for the LogiOps virtual input device stays stable across config reloads.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant