Skip to content

feat: Kindle: add uevent listener for input device hotplug#2327

Open
zampierilucas wants to merge 1 commit intokoreader:masterfrom
zampierilucas:kindle-input-hotplug
Open

feat: Kindle: add uevent listener for input device hotplug#2327
zampierilucas wants to merge 1 commit intokoreader:masterfrom
zampierilucas:kindle-input-hotplug

Conversation

@zampierilucas
Copy link
Copy Markdown

@zampierilucas zampierilucas commented Apr 8, 2026

A user (@alllexx88, kindle-hid-passthrough#40) pointed out that keyboards connected via kindle-hid-passthrough don't work in KOReader because KOReader never discovers the dynamically created /dev/input/eventX device.

On Kobo, input-kobo.h already uses libue to listen for netlink uevents and emit CODE_FAKE_USB_DEVICE_PLUGGED_IN/OUT when new input devices appear. Kindle's input-kindle.h had no equivalent, only the lipc-wait-event loop for power/charging events. This patch adds a uevent listener as a forked child alongside the existing lipc loop, using the same libue library already in the repo. When a new evdev node appears (e.g., a UHID keyboard), it emits the same fake event codes that the Kobo path uses, so the existing externalkeyboard plugin can handle it. Tested on a Kindle PW4 with kindle-hid-passthrough and a BLE keyboard, KOReader correctly shows the "Keyboard connected" banner and accepts input.

Ref koreader/koreader#14359


This change is Reviewable

Add a netlink uevent listener alongside the existing lipc-wait-event
loop in input-kindle.h. This allows KOReader to detect dynamically
created input devices (e.g., UHID keyboards from kindle-hid-passthrough)
after startup.

The listener runs as a forked child of the fake event generator process,
using libue (already in the repo) to watch for input subsystem add/remove
events. When a new /dev/input/eventX appears, it emits
CODE_FAKE_USB_DEVICE_PLUGGED_IN (10040) with the evdev number; on removal,
CODE_FAKE_USB_DEVICE_PLUGGED_OUT (10041). This is the same mechanism Kobo
uses for USB OTG keyboards (input-kobo.h), adapted for Kindle where UHID
devices appear under /devices/virtual/input/.

Unlike Kobo, we don't filter on devpath since built-in Kindle input
devices are static and won't generate add/remove uevents.

Closes: koreader/koreader#14359
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