Repository navigation
subsys/input: add the input subsystem - #2365
Merged
Merged
Conversation
gmarull
marked this pull request as ready for review
October 9, 2026 20:07
Drivers report input events (keys, absolute axes, gestures) with pbl_input_report() and listeners defined with PBL_INPUT_CALLBACK_DEFINE() consume them, collected at link time like the shell commands. Modelled on the Zephyr input subsystem. Delivery is synchronous, in the context of the report: the kernel event queue already defers work out of ISRs, so a queue and thread of its own would only add latency, stack and a task watchdog channel. Listeners must not block and check pbl_in_isr() before using APIs that are not ISR-safe. The input shell command dumps events and reports arbitrary ones. Nothing selects INPUT yet; the button and touch drivers move over next. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
Each ButtonConfig carries the input subsystem key code its button reports, so that the key codes do not need to share values with ButtonId. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
The button drivers report key events instead of putting PebbleEvents on the kernel queue, and a listener in fw/kernel turns them back into PEBBLE_BUTTON_DOWN/UP_EVENT, so the click recognizers and everything above them are unchanged. Drivers report the key code set in the board configuration, and the listener maps it back to its ButtonId. The listener runs in the debounce ISR, like the event_put_isr() calls it replaces. The SELECT+BACK hard reset stays in the drivers: it has to work with every thread wedged, and the debounce timer is what times the hold. `button raw`, duplicated in the SF32LB, nRF5 and QEMU drivers, moves next to the other button commands and reports through the subsystem, so it is now available on every board. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
The touch drivers report samples (BTN_TOUCH, ABS_X, ABS_Y) and gestures (ABS_X, ABS_Y, GES) instead of calling into the touch service, which now collects each report in an input listener and passes it on to touch_handle_update() and touch_handle_gesture(). The reports come from the system task, as the calls they replace did. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
Injected button presses (button click/hold/multi and the remote input endpoint) take the same path as the hardware buttons. The test links the subsystem and the button listener, and checks the PebbleEvents at the end of it as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
jplexer
approved these changes
Oct 12, 2026
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.
Adds
subsys/input, a Zephyr-style input subsystem. Drivers report events withpbl_input_report()and know nothing about who consumes them. Listeners are defined withPBL_INPUT_CALLBACK_DEFINE()next to the code that uses them and are collected at link time, the same way shell commands are.KEY(buttons,BTN_TOUCH),ABS(touch X/Y) andGES(tap, double tap, palm). Events are grouped into reports, and the last event of a report carriessync.pbl_in_isr()before calling APIs that are not ISR-safe.ButtonConfigsets the key code its button reports, so the codes are independent ofButtonId. A listener infw/kernelmaps the codes back toButtonIdand turns them intoPEBBLE_BUTTON_DOWN/UP_EVENT, so click recognition and everything above it is unchanged. The SELECT+BACK hard reset stays in the drivers on purpose: it has to work when every thread is wedged.touch_handle_update()/touch_handle_gesture().button click/hold/multi, the remote input endpoint andbutton rawall go through the subsystem.button rawwas duplicated in three drivers; it now exists once and works on every board.input dump on|offandinput report <key|abs|ges> <code> <value> [sync]shell commands.Design notes are in
docs/architecture/input.md.Future work, not part of this PR: a generic
gpio_keysdriver that owns debouncing, the hold timer and combos, once the device model can describe keys per board.Testing
pbl test: 375/375 pass, including the newtest_inputandtest_remote_input, which now runs through the subsystem and the button listener.input dump on:sendkeyandpbl touchproduce the expected key, BTN_TOUCH and ABS reports.button raw 3 1/0,button click 3andinput report key 3 1/0each move the selection down one row.input dump on:button raw,button clickandinput report keyreport the expected events.🤖 Generated with Claude Code