This is an automated email from the ASF dual-hosted git repository.
xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 2b0c59bcf4e drivers/usbhost_hidmouse: fix button detection in
touchscreen example
2b0c59bcf4e is described below
commit 2b0c59bcf4eb8794c335b4d8156df5d10fbf5461
Author: Lwazi Dube <[email protected]>
AuthorDate: Thu May 21 10:02:53 2026 -0400
drivers/usbhost_hidmouse: fix button detection in touchscreen example
Fix an issue where button presses were missed in the touchscreen
example due to incorrect packet processing.
Previously, the driver waited to accumulate a batch of packets but only
processed the first one, effectively discarding the rest. The driver
now reads and processes packets one at a time to ensure no input
events are lost.
Also fixed typo: usbhost_xythreshold does not exist.
Signed-off-by: Lwazi Dube <[email protected]>
---
drivers/usbhost/usbhost_hidmouse.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/usbhost/usbhost_hidmouse.c
b/drivers/usbhost/usbhost_hidmouse.c
index 90a9320258b..7c52e844c52 100644
--- a/drivers/usbhost/usbhost_hidmouse.c
+++ b/drivers/usbhost/usbhost_hidmouse.c
@@ -276,6 +276,7 @@ struct usbhost_state_s
struct work_s work; /* For cornercase error handling by
the worker thread */
struct mouse_sample_s sample; /* Last sampled mouse data */
usbhost_ep_t epin; /* Interrupt IN endpoint */
+ size_t packet_len;
/* The following is a list if poll structures of threads waiting for
* driver events. The 'struct pollfd' reference for each open is also
@@ -820,7 +821,7 @@ static bool usbhost_touchscreen(FAR struct usbhost_state_s
*priv,
* small, then ignore the event.
*/
- else if (!usbhost_xythreshold(priv))
+ else if (!usbhost_threshold(priv))
{
return false;
}
@@ -988,7 +989,7 @@ static int usbhost_mouse_poll(int argc, FAR char *argv[])
*/
nbytes = DRVR_TRANSFER(hport->drvr, priv->epin,
- priv->tbuffer, priv->tbuflen);
+ priv->tbuffer, priv->packet_len);
/* Check for errors -- Bail if an excessive number of consecutive
* errors are encountered.
@@ -1478,6 +1479,8 @@ static inline int usbhost_cfgdesc(FAR struct
usbhost_state_s *priv,
epindesc.mxpacketsize =
usbhost_getle16(epdesc->mxpacketsize);
+ priv->packet_len = (size_t)epindesc.mxpacketsize;
+
uinfo("Interrupt IN EP addr:%d mxpacketsize:%d\n",
epindesc.addr, epindesc.mxpacketsize);
}