mirror of
https://github.com/apache/nuttx.git
synced 2026-05-28 20:08:15 +08:00
The USB HID mouse driver is now functional. There are some usage issues as described in the top-level TODO list
This commit is contained in:
@@ -6553,4 +6553,8 @@
|
|||||||
completely untested on initial check-in (2014-2-9).
|
completely untested on initial check-in (2014-2-9).
|
||||||
* configs/olimex-lpc1766stk/src/lpc17_hidmouse.c and hidmouse: Add
|
* configs/olimex-lpc1766stk/src/lpc17_hidmouse.c and hidmouse: Add
|
||||||
support of a test of the USB HID mouse (2014-2-9).
|
support of a test of the USB HID mouse (2014-2-9).
|
||||||
|
* drivers/usbhost/usbhost_hidmouse.c: The driver appears to be
|
||||||
|
functional. But there are usability issues: How do you use the
|
||||||
|
mouse with no cursor? The HID mouse currently emulates a touchscreen
|
||||||
|
driver. That would work in the long run for several reasons (see the
|
||||||
|
top-level TODO list for details) (2014-2-9).
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ nuttx/
|
|||||||
(4) C++ Support
|
(4) C++ Support
|
||||||
(6) Binary loaders (binfmt/)
|
(6) Binary loaders (binfmt/)
|
||||||
(17) Network (net/, drivers/net)
|
(17) Network (net/, drivers/net)
|
||||||
(4) USB (drivers/usbdev, drivers/usbhost)
|
(5) USB (drivers/usbdev, drivers/usbhost)
|
||||||
(11) Libraries (libc/, )
|
(11) Libraries (libc/, )
|
||||||
(12) File system/Generic drivers (fs/, drivers/)
|
(12) File system/Generic drivers (fs/, drivers/)
|
||||||
(5) Graphics subystem (graphics/)
|
(5) Graphics subystem (graphics/)
|
||||||
@@ -1025,6 +1025,26 @@ o USB (drivers/usbdev, drivers/usbhost)
|
|||||||
Status: Open
|
Status: Open
|
||||||
Priority: Low/Unknown. This is a feature enhancement.
|
Priority: Low/Unknown. This is a feature enhancement.
|
||||||
|
|
||||||
|
Title: USB HID MOUSE LOGIC INCOMPLETE
|
||||||
|
Description: There is a working USB HID mouse driver at drivers/usbhost/usbhost_hidmouse.c.
|
||||||
|
Although the driver works, it is not useful. Currently it
|
||||||
|
emulates a touchscreen and uses the touchscreen interface.
|
||||||
|
The problems are:
|
||||||
|
|
||||||
|
- With no hardware cursor, a mouse is not usable because
|
||||||
|
you cannot tell where the mouse is positioned.
|
||||||
|
- Since it uses the touchscreen interface, there is no way
|
||||||
|
to report left or center button activity or to report
|
||||||
|
the wheel position.
|
||||||
|
- And, for the same reason, positional data is not reported
|
||||||
|
when the left button is not pressed (i.e., like touching
|
||||||
|
the screen). Data would have to be reported when no
|
||||||
|
buttons are pressed in order to driver a hardware cursor.
|
||||||
|
|
||||||
|
There is a test configuration at configs/olimex-lpc1766stk/hidmouse.
|
||||||
|
Status: Open
|
||||||
|
Priority: Low, unless you need a usable HID mouse now.
|
||||||
|
|
||||||
o Libraries (libc/)
|
o Libraries (libc/)
|
||||||
^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
|||||||
@@ -958,9 +958,9 @@ Where <subdir> is one of the following:
|
|||||||
CONFIG_WINDOWS_CYGWIN=y : Cygwin environment on Windows
|
CONFIG_WINDOWS_CYGWIN=y : Cygwin environment on Windows
|
||||||
CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW=y : CodeSourcery under Windows
|
CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW=y : CodeSourcery under Windows
|
||||||
|
|
||||||
3. The mouse is really useless with no display and not cursor. So this
|
3. The mouse is really useless with no display and no cursor. So this
|
||||||
configuration is only suited for testing. It is also awkward to use.
|
configuration is only suited for low-level testing. It is also awkward
|
||||||
Here are the steps:
|
to use. Here are the steps:
|
||||||
|
|
||||||
- Remove the USB HID mouse and reset the board.
|
- Remove the USB HID mouse and reset the board.
|
||||||
- When the NSH prompt comes up type 'tc'. That will fail, but it
|
- When the NSH prompt comes up type 'tc'. That will fail, but it
|
||||||
|
|||||||
@@ -407,7 +407,6 @@ CONFIG_USBHOST_NPREALLOC=4
|
|||||||
# CONFIG_USBHOST_MSC is not set
|
# CONFIG_USBHOST_MSC is not set
|
||||||
# CONFIG_USBHOST_HIDKBD is not set
|
# CONFIG_USBHOST_HIDKBD is not set
|
||||||
CONFIG_USBHOST_HIDMOUSE=y
|
CONFIG_USBHOST_HIDMOUSE=y
|
||||||
CONFIG_HIDMOUSE_POLLUSEC=100000
|
|
||||||
CONFIG_HIDMOUSE_DEFPRIO=50
|
CONFIG_HIDMOUSE_DEFPRIO=50
|
||||||
CONFIG_HIDMOUSE_STACKSIZE=1024
|
CONFIG_HIDMOUSE_STACKSIZE=1024
|
||||||
CONFIG_HIDMOUSE_BUFSIZE=64
|
CONFIG_HIDMOUSE_BUFSIZE=64
|
||||||
|
|||||||
@@ -157,6 +157,7 @@ config HIDMOUSE_SWAPXY
|
|||||||
default n
|
default n
|
||||||
---help---
|
---help---
|
||||||
Reverse the meaning of X and Y to handle different display orientations.
|
Reverse the meaning of X and Y to handle different display orientations.
|
||||||
|
NOTE: All of the following settings apply AFTER X and Y have been swapped.
|
||||||
|
|
||||||
config HIDMOUSE_XMAX
|
config HIDMOUSE_XMAX
|
||||||
int "Maximum X position"
|
int "Maximum X position"
|
||||||
@@ -178,24 +179,30 @@ config HIDMOUSE_XSCALE
|
|||||||
hex "X scaling factor"
|
hex "X scaling factor"
|
||||||
default 0x00010000
|
default 0x00010000
|
||||||
---help---
|
---help---
|
||||||
Mouse positions are accumumated from X/Y displacements reported by
|
Mouse positions are accumulated from X/Y displacements reported by
|
||||||
the mouse device. This setting provides a scaling value for the X
|
the mouse device. This setting provides a scaling value for the X
|
||||||
displacement. This is a fixed precision floating point number with
|
displacement. This is a fixed precision floating point number with
|
||||||
16 bits of fraction. So a value of 0x00010000 is 1.0, 0x00018000
|
16 bits of fraction. So a value of 0x00010000 is 1.0, 0x00018000
|
||||||
is 1.5, 0x00024000 is 2.25, etc.
|
is 1.5, 0x00024000 is 2.25, etc.
|
||||||
|
|
||||||
|
NOTE that a negative value of HIDMOUSE_XSCALE such as 0xffff0000
|
||||||
|
(-1.0) can be used to change the direction of movement.
|
||||||
|
|
||||||
Default: 0x00010000 (1.0)
|
Default: 0x00010000 (1.0)
|
||||||
|
|
||||||
config HIDMOUSE_YSCALE
|
config HIDMOUSE_YSCALE
|
||||||
hex "Y scaling factor"
|
hex "Y scaling factor"
|
||||||
default 0x00010000
|
default 0x00010000
|
||||||
---help---
|
---help---
|
||||||
Mouse positions are accumumated from X/Y displacements reported by
|
Mouse positions are accumulated from X/Y displacements reported by
|
||||||
the mouse device. This setting provides a scaling value for the Y
|
the mouse device. This setting provides a scaling value for the Y
|
||||||
displacement. This is a fixed precision floating point number with
|
displacement. This is a fixed precision floating point number with
|
||||||
16 bits of fraction. So a value of 0x00010000 is 1.0, 0x00018000
|
16 bits of fraction. So a value of 0x00010000 is 1.0, 0x00018000
|
||||||
is 1.5, 0x00024000 is 2.25, etc.
|
is 1.5, 0x00024000 is 2.25, etc.
|
||||||
|
|
||||||
|
NOTE that a negative value of HIDMOUSE_YSCALE such as 0xffff0000
|
||||||
|
(-1.0) can be used to change the direction of movement.
|
||||||
|
|
||||||
Default: 0x00010000 (1.0)
|
Default: 0x00010000 (1.0)
|
||||||
|
|
||||||
config HIDMOUSE_XTHRESH
|
config HIDMOUSE_XTHRESH
|
||||||
|
|||||||
@@ -228,8 +228,8 @@ struct usbhost_state_s
|
|||||||
sem_t exclsem; /* Used to maintain mutual exclusive access */
|
sem_t exclsem; /* Used to maintain mutual exclusive access */
|
||||||
sem_t waitsem; /* Used to wait for mouse data */
|
sem_t waitsem; /* Used to wait for mouse data */
|
||||||
FAR uint8_t *tbuffer; /* The allocated transfer buffer */
|
FAR uint8_t *tbuffer; /* The allocated transfer buffer */
|
||||||
b16_t xpos; /* Current integrated X position */
|
b16_t xaccum; /* Current integrated X position */
|
||||||
b16_t ypos; /* Current integrated Y position */
|
b16_t yaccum; /* Current integrated Y position */
|
||||||
b16_t xlast; /* Last reported X position */
|
b16_t xlast; /* Last reported X position */
|
||||||
b16_t ylast; /* Last reported Y position */
|
b16_t ylast; /* Last reported Y position */
|
||||||
size_t tbuflen; /* Size of the allocated transfer buffer */
|
size_t tbuflen; /* Size of the allocated transfer buffer */
|
||||||
@@ -753,53 +753,67 @@ static int usbhost_mouse_poll(int argc, char *argv[])
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef CONFIG_HIDMOUSE_SWAPXY
|
#ifdef CONFIG_HIDMOUSE_SWAPXY
|
||||||
|
xdisp = rpt->ydisp;
|
||||||
|
if ((rpt->ydisp & 0x80) != 0)
|
||||||
|
{
|
||||||
|
xdisp |= 0xffffff00;
|
||||||
|
}
|
||||||
|
#else
|
||||||
xdisp = rpt->xdisp;
|
xdisp = rpt->xdisp;
|
||||||
if ((rpt->xdisp & 0x80) != 0)
|
if ((rpt->xdisp & 0x80) != 0)
|
||||||
{
|
{
|
||||||
xdisp |= 0xffffff00;
|
xdisp |= 0xffffff00;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
xdisp = rpt->ydisp;
|
|
||||||
if ((rpt->ydisp & 0x80) != 0)
|
|
||||||
{
|
|
||||||
ydisp |= 0xffffff00;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Scale the X displacement and determine the new X position */
|
/* Scale the X displacement and determine the new X position */
|
||||||
|
|
||||||
xpos = priv->xpos + CONFIG_HIDMOUSE_XSCALE * xdisp;
|
xpos = priv->xaccum + CONFIG_HIDMOUSE_XSCALE * xdisp;
|
||||||
|
|
||||||
/* Make sure that the scaled X position does not exceed the
|
/* Make sure that the scaled X position does not become negative
|
||||||
* maximum.
|
* or exceed the maximum.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (xpos > HIDMOUSE_XMAX_B16)
|
if (xpos > HIDMOUSE_XMAX_B16)
|
||||||
{
|
{
|
||||||
xpos = HIDMOUSE_XMAX_B16;
|
xpos = HIDMOUSE_XMAX_B16;
|
||||||
}
|
}
|
||||||
|
else if (xpos < 0)
|
||||||
|
{
|
||||||
|
xpos = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Save the updated X position */
|
||||||
|
|
||||||
|
priv->xaccum = xpos;
|
||||||
|
|
||||||
/* Do the same for the Y position */
|
/* Do the same for the Y position */
|
||||||
|
|
||||||
#ifdef CONFIG_HIDMOUSE_SWAPXY
|
#ifdef CONFIG_HIDMOUSE_SWAPXY
|
||||||
|
ydisp = rpt->xdisp;
|
||||||
|
if ((rpt->xdisp & 0x80) != 0)
|
||||||
|
{
|
||||||
|
ydisp |= 0xffffff00;
|
||||||
|
}
|
||||||
|
#else
|
||||||
ydisp = rpt->ydisp;
|
ydisp = rpt->ydisp;
|
||||||
if ((rpt->ydisp & 0x80) != 0)
|
if ((rpt->ydisp & 0x80) != 0)
|
||||||
{
|
{
|
||||||
ydisp |= 0xffffff00;
|
ydisp |= 0xffffff00;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
ydisp = rpt->xdisp;
|
|
||||||
if ((rpt->xdisp & 0x80) != 0)
|
|
||||||
{
|
|
||||||
xdisp |= 0xffffff00;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
ypos = priv->ypos + CONFIG_HIDMOUSE_YSCALE * ydisp;
|
ypos = priv->yaccum + CONFIG_HIDMOUSE_YSCALE * ydisp;
|
||||||
|
|
||||||
if (ypos > HIDMOUSE_YMAX_B16)
|
if (ypos > HIDMOUSE_YMAX_B16)
|
||||||
{
|
{
|
||||||
ypos = HIDMOUSE_YMAX_B16;
|
ypos = HIDMOUSE_YMAX_B16;
|
||||||
}
|
}
|
||||||
|
else if (ypos < 0)
|
||||||
|
{
|
||||||
|
ypos = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
priv->yaccum = ypos;
|
||||||
|
|
||||||
/* Check if the left button is pressed */
|
/* Check if the left button is pressed */
|
||||||
|
|
||||||
@@ -841,9 +855,9 @@ static int usbhost_mouse_poll(int argc, char *argv[])
|
|||||||
|
|
||||||
else if (priv->sample.event == BUTTON_RELEASED)
|
else if (priv->sample.event == BUTTON_RELEASED)
|
||||||
{
|
{
|
||||||
/* If we have not yet processed the last pen up event, then we
|
/* If we have not yet processed the button release event, then
|
||||||
* cannot handle this pen down event. We will have to discard
|
* we cannot handle this button press event. We will have to
|
||||||
* it and wait for the next sample data.
|
* discard the data and wait for the next sample.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
goto ignored;
|
goto ignored;
|
||||||
@@ -1891,8 +1905,8 @@ static int usbhost_open(FAR struct file *filep)
|
|||||||
|
|
||||||
/* Set the reported position to the center of the range */
|
/* Set the reported position to the center of the range */
|
||||||
|
|
||||||
priv->xpos = (CONFIG_HIDMOUSE_XMAX >> 1);
|
priv->xaccum = (HIDMOUSE_XMAX_B16 >> 1);
|
||||||
priv->ypos = (CONFIG_HIDMOUSE_YMAX >> 1);
|
priv->yaccum = (HIDMOUSE_YMAX_B16 >> 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Otherwise, just increment the reference count on the driver */
|
/* Otherwise, just increment the reference count on the driver */
|
||||||
|
|||||||
Reference in New Issue
Block a user