This is an automated email from the ASF dual-hosted git repository.

jerpelea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 31d3598f6a433d7aaafe56711922a3b9deaf5025
Author: Alan Carvalho de Assis <[email protected]>
AuthorDate: Thu Sep 24 11:21:35 2026 -0300

    arch/sim: buffer several mouse reports
    
    sim_mouse registered /dev/mouse0 with room for a single report.  The
    X11 event loop handles all pending X events at once every
    CONFIG_SIM_X11EVENT_INTERVAL ms, so a quick click (button press and
    release in the same period) overwrote the press before the application
    could read it, and the click was lost.
    
    Add CONFIG_SIM_MOUSE_BUFFSIZE (default 16) for the number of buffered
    reports, like CONFIG_SIM_KEYBOARD_BUFFSIZE for the keyboard.
    
    Assisted-by: Claude Opus 5.5 (1M context)
    Signed-off-by: Alan Carvalho de Assis <[email protected]>
---
 arch/sim/Kconfig             | 10 ++++++++++
 arch/sim/src/sim/sim_mouse.c |  2 +-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/arch/sim/Kconfig b/arch/sim/Kconfig
index 7aaedd23700..11024aabf7a 100644
--- a/arch/sim/Kconfig
+++ b/arch/sim/Kconfig
@@ -652,6 +652,16 @@ config SIM_KEYBOARD
        ---help---
                Support an X11 mouse-based keyboard emulation.  Also needs 
INPUT=y
 
+config SIM_MOUSE_BUFFSIZE
+       int "sim mouse buffer size"
+       default 16
+       depends on SIM_MOUSE
+       ---help---
+               Number of mouse reports buffered by /dev/mouse0.  The X11 event
+               loop can deliver a button press and its release in the same
+               polling period; with a single report buffered the press would be
+               overwritten before the application reads it.
+
 config SIM_KEYBOARD_BUFFSIZE
        int "sim keyboard buffer size"
        default 64
diff --git a/arch/sim/src/sim/sim_mouse.c b/arch/sim/src/sim/sim_mouse.c
index 851c59f8fa0..b1b8dcbd180 100644
--- a/arch/sim/src/sim/sim_mouse.c
+++ b/arch/sim/src/sim/sim_mouse.c
@@ -126,7 +126,7 @@ int sim_mouse_initialize(int minor)
   snprintf(devname, sizeof(devname), DEV_FORMAT, minor);
   iinfo("Registering %s\n", devname);
 
-  ret = mouse_register(&priv->lower, devname, 1);
+  ret = mouse_register(&priv->lower, devname, CONFIG_SIM_MOUSE_BUFFSIZE);
   if (ret < 0)
     {
       ierr("ERROR: mouse_register() failed: %d\n", ret);

Reply via email to