Skip to content

graphics/input: Add getevent input event monitor tool#3434

Open
HongChao6 wants to merge 4 commits intoapache:masterfrom
HongChao6:getevent
Open

graphics/input: Add getevent input event monitor tool#3434
HongChao6 wants to merge 4 commits intoapache:masterfrom
HongChao6:getevent

Conversation

@HongChao6
Copy link

@HongChao6 HongChao6 commented Mar 25, 2026

Summary

Add getevent, a command-line input event monitor that captures and displays real-time events from input devices.

What

getevent captures and displays real-time input events from mouse, touchscreen, and keyboard devices. It reads from input device nodes (/dev/mouse*, /dev/input*, /dev/kbd*) using non-blocking I/O with poll(), and prints structured event data via syslog.

Supported event types:

  • Mouse: button state, x/y coordinates, wheel (if enabled)
  • Touchscreen: multi-touch points with coordinates, flags, timestamps, and optional pressure/size detail
  • Keyboard: key code and event type

When / Why

This tool is useful during:

  • Driver bring-up: verify that a newly ported input driver produces correct events
  • Input debugging: inspect raw event data to diagnose issues like missed touches, incorrect coordinates, or stuck keys
  • System integration: confirm that input devices are properly registered and accessible from userspace

Without getevent, developers must write ad-hoc test programs or read device nodes manually to verify input behavior. This tool provides a ready-made, consistent way to do so.

Usage

# Auto-detect all input devices in /dev
getevent

# Monitor a specific mouse device
getevent -m /dev/mouse0

# Monitor a specific touchscreen
getevent -t /dev/input0

# Monitor a specific keyboard
getevent -k /dev/kbd0

# Combine multiple devices
getevent -m /dev/mouse0 -t /dev/input0 -k /dev/kbd0

Press Ctrl+C to stop.

Configuration

CONFIG_GRAPHICS_INPUT_GETEVENT=y            # Enable getevent
CONFIG_GRAPHICS_INPUT_GETEVENT_DETAIL_INFO=y # Optional: show touch pressure/size

Copy link
Contributor

@cederom cederom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @HongChao6 very useful utility :-)

Please read https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md and update git commit descriptions :-)

I am wondering if nuttx-apps/testing/input would not be a better fit for this tool? The main purpose is testing / input not really graphics right? Also exiting code in graphics/input? What do you think folks? :-)

HongChao6 and others added 3 commits March 25, 2026 14:07
Add getevent utility for monitoring input events including
mouse clicks/movement, multi-touch coordinates/pressure,
and keyboard key presses. Supports automatic device detection
in /dev and command-line device path specification with
non-blocking I/O.

Signed-off-by: liuhongchao <liuhongchao@xiaomi.com>
Fix format specifier mismatch where '%d' was used for int32_t
type argument. Use PRId32 macro instead to ensure portable
formatting across architectures.

Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
Fix volatile qualifier warning in pointer assignment.
Add errno logging for better error diagnostics.
Replace malloc with calloc for zero-initialized allocation.

Signed-off-by: liuhongchao <liuhongchao@xiaomi.com>
@HongChao6 HongChao6 force-pushed the getevent branch 2 times, most recently from 4b49bd9 to 9413590 Compare March 25, 2026 06:30
@HongChao6
Copy link
Author

Thank you @HongChao6 very useful utility :-)

Please read https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md and update git commit descriptions :-)

I am wondering if nuttx-apps/testing/input would not be a better fit for this tool? The main purpose is testing / input not really graphics right? Also exiting code in graphics/input? What do you think folks? :-)

Thanks for the suggestion. The getevent tool shares the same input subsystem infrastructure with monkey and generator under graphics/input/. Moving getevent alone would split the input toolset.

If the community agrees that graphics/input is not the right place, I'd prefer to create a separate PR to move the entire graphics/input/ directory to testing/input/ together, rather than splitting them up in this PR.

What do you think?

@HongChao6 HongChao6 requested a review from cederom March 25, 2026 06:34
acassis

This comment was marked as outdated.

Copy link
Contributor

@acassis acassis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@HongChao6 please create a Documentation about this Graphics Input Getevent, I think we also need some basic Documentation about Graphics Input in general

@cederom
Copy link
Contributor

cederom commented Mar 25, 2026

@acassis is this input tightly coupled with graphics? if not and can be used as general input then maybe we should create a separate and dedicated nuttx-apps/input ? :-)

@acassis
Copy link
Contributor

acassis commented Mar 25, 2026

@acassis is this input tightly coupled with graphics? if not and can be used as general input then maybe we should create a separate and dedicated nuttx-apps/input ? :-)

AFAIK Graphics Input is mostly used to create Monkey testing events, but a generic Input device tester

@cederom
Copy link
Contributor

cederom commented Mar 25, 2026

Okay not to delay here we can put where existing input resides :-) Just an idea to uncover this functionality into its own space :-)

Copy link
Contributor

@cederom cederom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO :-)

  • PR description.
  • Documentation.
  • Kconfig description.

@cederom
Copy link
Contributor

cederom commented Mar 25, 2026

I have created a dedicated issue for discussion of input location #3436 :-)

simbit18
simbit18 previously approved these changes Mar 26, 2026
@HongChao6
Copy link
Author

Addressed review feedback:

Updated Kconfig help text with detailed description
Updated PR description
Documentation submitted in rst format: apache/nuttx#18615
@cederom @acassis Please take another look when you have a chance. Thanks!

Remove the in-tree README.md in favor of rst documentation in the
nuttx main repository. Update the Kconfig help text for getevent
to describe what it does, when to use it, and why it is needed.

Signed-off-by: liuhongchao <liuhongchao@xiaomi.com>
@simbit18
Copy link
Contributor

Hi @HongChao6, this error is not related to this PR

You will need to wait for this PR #3440 to be merged, after which you will need to rebase

====================================================================================
Configuration/Tool: sim/citest
2026-03-27 02:48:55
------------------------------------------------------------------------------------
  Cleaning...
  Configuring...
  Building NuttX...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0

100 1646k  100 1646k    0     0  3078k      0 --:--:-- --:--:-- --:--:-- 5899k

100  143k    0  143k    0     0   286k      0 --:--:-- --:--:-- --:--:--  286k
  Running NuttX...
++ pwd
+ olddir=/github/workspace/sources/nuttx
+ nuttdir=/github/workspace/sources/nuttx/boards/sim/sim/sim/configs/citest/../../../../../../
+ cd /github/workspace/sources/nuttx/boards/sim/sim/sim/configs/citest/../../../../../../
+ confpath=/github/workspace/sources/nuttx/boards/sim/sim/sim/configs/citest/config.yaml
+ jsonconf=/github/workspace/sources/nuttx/boards/sim/sim/sim/configs/citest/session.json
+ testpath=/github/workspace/nuttx-ntfc/external/nuttx-testing
+ ntfc test --testpath=/github/workspace/nuttx-ntfc/external/nuttx-testing --confpath=/github/workspace/sources/nuttx/boards/sim/sim/sim/configs/citest/config.yaml --jsonconf=/github/workspace/sources/nuttx/boards/sim/sim/sim/configs/citest/session.json
/github/workspace/sources/nuttx/../nuttx/boards/sim/sim/sim/configs/citest/run.sh: line 35: ntfc: command not found
+ ret=127
+ echo 127
+ artifacts=/github/workspace/buildartifacts/sim/citest//ntfc
+ mkdir -p /github/workspace/buildartifacts/sim/citest//ntfc
127
+ rm -f pytest.debug.log
+ mv result /github/workspace/buildartifacts/sim/citest//ntfc
mv: cannot stat 'result': No such file or directory
+ cd /github/workspace/sources/nuttx
+ exit 127
  [1/1] Normalize sim/citest
====================================================================================

@HongChao6
Copy link
Author

Hi @HongChao6, this error is not related to this PR

You will need to wait for this PR #3440 to be merged, after which you will need to rebase

Thanks for the heads up! I'll rebase once #3440 is merged.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants