diff --git a/ChangeLog b/ChangeLog index d091e99378b..20dd214c608 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6553,4 +6553,8 @@ completely untested on initial check-in (2014-2-9). * configs/olimex-lpc1766stk/src/lpc17_hidmouse.c and hidmouse: Add 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). diff --git a/TODO b/TODO index 22aa548fb51..95374c190c9 100644 --- a/TODO +++ b/TODO @@ -16,7 +16,7 @@ nuttx/ (4) C++ Support (6) Binary loaders (binfmt/) (17) Network (net/, drivers/net) - (4) USB (drivers/usbdev, drivers/usbhost) + (5) USB (drivers/usbdev, drivers/usbhost) (11) Libraries (libc/, ) (12) File system/Generic drivers (fs/, drivers/) (5) Graphics subystem (graphics/) @@ -1025,6 +1025,26 @@ o USB (drivers/usbdev, drivers/usbhost) Status: Open 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/) ^^^^^^^^^^^^^^^^^ diff --git a/configs/olimex-lpc1766stk/README.txt b/configs/olimex-lpc1766stk/README.txt index 4f47ffb1831..aee46965fa9 100644 --- a/configs/olimex-lpc1766stk/README.txt +++ b/configs/olimex-lpc1766stk/README.txt @@ -958,9 +958,9 @@ Where is one of the following: CONFIG_WINDOWS_CYGWIN=y : Cygwin environment on Windows CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW=y : CodeSourcery under Windows - 3. The mouse is really useless with no display and not cursor. So this - configuration is only suited for testing. It is also awkward to use. - Here are the steps: + 3. The mouse is really useless with no display and no cursor. So this + configuration is only suited for low-level testing. It is also awkward + to use. Here are the steps: - Remove the USB HID mouse and reset the board. - When the NSH prompt comes up type 'tc'. That will fail, but it diff --git a/configs/olimex-lpc1766stk/hidmouse/defconfig b/configs/olimex-lpc1766stk/hidmouse/defconfig index 1b73faea33f..4f8e2cb7af1 100644 --- a/configs/olimex-lpc1766stk/hidmouse/defconfig +++ b/configs/olimex-lpc1766stk/hidmouse/defconfig @@ -407,7 +407,6 @@ CONFIG_USBHOST_NPREALLOC=4 # CONFIG_USBHOST_MSC is not set # CONFIG_USBHOST_HIDKBD is not set CONFIG_USBHOST_HIDMOUSE=y -CONFIG_HIDMOUSE_POLLUSEC=100000 CONFIG_HIDMOUSE_DEFPRIO=50 CONFIG_HIDMOUSE_STACKSIZE=1024 CONFIG_HIDMOUSE_BUFSIZE=64 diff --git a/drivers/usbhost/Kconfig b/drivers/usbhost/Kconfig index fbb87ce2452..080109ea255 100644 --- a/drivers/usbhost/Kconfig +++ b/drivers/usbhost/Kconfig @@ -157,6 +157,7 @@ config HIDMOUSE_SWAPXY default n ---help--- 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 int "Maximum X position" @@ -178,24 +179,30 @@ config HIDMOUSE_XSCALE hex "X scaling factor" default 0x00010000 ---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 displacement. This is a fixed precision floating point number with 16 bits of fraction. So a value of 0x00010000 is 1.0, 0x00018000 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) config HIDMOUSE_YSCALE hex "Y scaling factor" default 0x00010000 ---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 displacement. This is a fixed precision floating point number with 16 bits of fraction. So a value of 0x00010000 is 1.0, 0x00018000 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) config HIDMOUSE_XTHRESH diff --git a/drivers/usbhost/usbhost_hidmouse.c b/drivers/usbhost/usbhost_hidmouse.c index 49834e43ecc..2a37ced2275 100644 --- a/drivers/usbhost/usbhost_hidmouse.c +++ b/drivers/usbhost/usbhost_hidmouse.c @@ -228,8 +228,8 @@ struct usbhost_state_s sem_t exclsem; /* Used to maintain mutual exclusive access */ sem_t waitsem; /* Used to wait for mouse data */ FAR uint8_t *tbuffer; /* The allocated transfer buffer */ - b16_t xpos; /* Current integrated X position */ - b16_t ypos; /* Current integrated Y position */ + b16_t xaccum; /* Current integrated X position */ + b16_t yaccum; /* Current integrated Y position */ b16_t xlast; /* Last reported X position */ b16_t ylast; /* Last reported Y position */ 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 + xdisp = rpt->ydisp; + if ((rpt->ydisp & 0x80) != 0) + { + xdisp |= 0xffffff00; + } +#else xdisp = rpt->xdisp; if ((rpt->xdisp & 0x80) != 0) { xdisp |= 0xffffff00; } -#else - xdisp = rpt->ydisp; - if ((rpt->ydisp & 0x80) != 0) - { - ydisp |= 0xffffff00; - } #endif /* 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 - * maximum. + /* Make sure that the scaled X position does not become negative + * or exceed the maximum. */ if (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 */ #ifdef CONFIG_HIDMOUSE_SWAPXY + ydisp = rpt->xdisp; + if ((rpt->xdisp & 0x80) != 0) + { + ydisp |= 0xffffff00; + } +#else ydisp = rpt->ydisp; if ((rpt->ydisp & 0x80) != 0) { ydisp |= 0xffffff00; } -#else - ydisp = rpt->xdisp; - if ((rpt->xdisp & 0x80) != 0) - { - xdisp |= 0xffffff00; - } #endif - ypos = priv->ypos + CONFIG_HIDMOUSE_YSCALE * ydisp; + ypos = priv->yaccum + CONFIG_HIDMOUSE_YSCALE * ydisp; if (ypos > HIDMOUSE_YMAX_B16) { ypos = HIDMOUSE_YMAX_B16; } + else if (ypos < 0) + { + ypos = 0; + } + + priv->yaccum = ypos; /* 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) { - /* If we have not yet processed the last pen up event, then we - * cannot handle this pen down event. We will have to discard - * it and wait for the next sample data. + /* If we have not yet processed the button release event, then + * we cannot handle this button press event. We will have to + * discard the data and wait for the next sample. */ goto ignored; @@ -1891,8 +1905,8 @@ static int usbhost_open(FAR struct file *filep) /* Set the reported position to the center of the range */ - priv->xpos = (CONFIG_HIDMOUSE_XMAX >> 1); - priv->ypos = (CONFIG_HIDMOUSE_YMAX >> 1); + priv->xaccum = (HIDMOUSE_XMAX_B16 >> 1); + priv->yaccum = (HIDMOUSE_YMAX_B16 >> 1); } /* Otherwise, just increment the reference count on the driver */