Skip to content

arch/sim: Add Mouse emulation - #19812

Merged
acassis merged 3 commits into
apache:masterfrom
acassis:sim_mouse
Aug 12, 2026
Merged

arch/sim: Add Mouse emulation#19812
acassis merged 3 commits into
apache:masterfrom
acassis:sim_mouse

Conversation

@acassis

@acassis acassis commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR adds Mouse emulation with 3 buttons support to NuttX SIM

Impact

NuttX users could use more advanced features with using mouse with Microwindow/Nano-X

Testing

SIM:

image

@github-actions github-actions Bot added Area: Documentation Improvements or additions to documentation Arch: simulator Issues related to the SIMulator Size: M The size of the change in this PR is medium labels Aug 12, 2026
@github-actions

github-actions Bot commented Aug 12, 2026

Copy link
Copy Markdown

MemBrowse Memory Report

No memory changes detected for:

This commit adds basic information about SIM Input support.

Signed-off-by: Alan C. Assis <acassis@gmail.com>
Comment thread arch/sim/src/sim/posix/sim_x11eventloop.c Outdated
Comment thread arch/sim/src/sim/sim_mouse.c
This commit adds support for three buttons Mouse emulation on SIM.

Signed-off-by: Alan C. Assis <acassis@gmail.com>
Assisted-by: Claude Code
As suggested by Xiang Xiao, let's fix the identation

Signed-off-by: Alan C. Assis <acassis@gmail.com>
@acassis

acassis commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

@ppisa I think this PR will be useful to test Microwindo/Nano-X on NuttX SIM

@simbit18
simbit18 requested a review from michallenc August 12, 2026 16:45
@acassis
acassis merged commit c9a27f0 into apache:master Aug 12, 2026
29 checks passed

The Sim can emulate buttons, keyboard, touchscreen-mouse based, mouse with 3 buttons and analog-mouse based joystick.

These drivers are particularly useful for graphical applications emulared over X11.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

*emulated

Keyboard
========

There are two types of keyboards: is native one used by default on NuttX SIM, since it is used to access the NuttShell interface and the ``CONFIG_SIM_KEYBOARD`` used with graphical applications.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

*the native one

=====

The driver emulates a Mouse with 3 buttons support. It can be enabled using the
symbol: ``CONFIG_SIM_MOUSE``. This driver is useful with used with more advanced interfaces like Microwindow/Nano-X that require at least left and right click buttons events.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there a doc page to link to for nano x yet or no? If there is it would be good to backlink

Touchscreen
===========

The difference between this driver and the Mouse is because this only generates a pen-down event when the user click in the interface. It is useful to use with LVGL graphic interface.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

*is that this only generates

*when the user clicks

*with the LVGL

Comment on lines +101 to +106
* undifferentiated "pen down" bit -- the whole point of
* CONFIG_SIM_MOUSE over CONFIG_SIM_TOUCHSCREEN is to keep which
* physical button was pressed. Not including that header here since
* it's the only thing that would pull NuttX input headers into this
* host-compiled (HOSTSRCS) file; the three bit values are hand-rolled
* instead, matching MOUSE_BUTTON_1=1, MOUSE_BUTTON_2=2, MOUSE_BUTTON_3=4.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think everything after "pen down bit" is extra info that doesn't really describe the function. It's quite "AI sounding".


priv->eventloop = 1;

/* And return success */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Remove

struct sim_dev_s *priv = (struct sim_dev_s *)&g_simmouse;
char devname[DEV_NAMELEN];

/* Stop the event loop (Hmm.. the caller must be sure that there are no

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe we can state this assumption in the function comment? I've seen other NuttX functions use the "Assumptions" field.

@ppisa

ppisa commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

@acassis Nice work.

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

Labels

Arch: simulator Issues related to the SIMulator Area: Documentation Improvements or additions to documentation Size: M The size of the change in this PR is medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants