mirror of
https://github.com/apache/nuttx.git
synced 2026-08-01 20:28:58 +00:00
drivers/usbhost: report the HID keyboard through the keyboard upper half
The driver kept a character device, a ring buffer, a poll waiter list and an encoder of its own, in parallel with everything the keyboard upper half already provides. A USB keyboard was therefore the one keyboard an application could not read like any other. Register with keyboard_register() and report with keyboard_event(), which removes the private character device and the four hundred lines that served it. Special keys are reported with the SPEC event types carrying a keycode, so an application no longer has to guess whether a value in the character range is a character or an arrow key. HIDKBD_ENCODED and HIDKBD_NODEBOUNCE go away with the code they guarded. Encoding is now inherent to the event, and the previous report is no longer an optimisation: a HID keyboard reports the keys that are down rather than the transitions, so it is what tells a new press from a key still held, and what tells that a key has been released. Reporting the modifiers as keys is new, so it is behind HIDKBD_REPORT_MODIFIERS and off by default. Signed-off-by: Jorge Guzman <jorge.gzm@gmail.com>
This commit is contained in:
parent
04822698b1
commit
f0a870baab
2 changed files with 268 additions and 601 deletions
|
|
@ -344,9 +344,16 @@ config USBHOST_HIDKBD
|
|||
bool "HID Keyboard Class Support"
|
||||
default n
|
||||
depends on !INT_DISABLE
|
||||
select INPUT
|
||||
select INPUT_KEYBOARD
|
||||
---help---
|
||||
Enable support for the keyboard class driver.
|
||||
|
||||
The keyboard is reported through the keyboard upper half, so it
|
||||
delivers struct keyboard_event_s events on read() just like any
|
||||
other keyboard. Set INPUT_KEYBOARD_BYTESTREAM if the application
|
||||
expects the plain byte stream that this driver used to provide.
|
||||
|
||||
if USBHOST_HIDKBD
|
||||
|
||||
config HIDKBD_POLLUSEC
|
||||
|
|
@ -368,17 +375,11 @@ config HIDKBD_STACKSIZE
|
|||
Stack size for polling thread. Default: 1024
|
||||
|
||||
config HIDKBD_BUFSIZE
|
||||
int "Scancode Buffer Size"
|
||||
int "Event Buffer Size"
|
||||
default 64
|
||||
---help---
|
||||
Scancode buffer size. Default: 64.
|
||||
|
||||
config HIDKBD_NPOLLWAITERS
|
||||
int "Max Number of Waiters for Poll Event"
|
||||
default 2
|
||||
---help---
|
||||
If the poll() method is enabled, this defines the maximum number
|
||||
of threads that can be waiting for keyboard events. Default: 2.
|
||||
Number of keyboard events buffered by the upper half for each
|
||||
open file description. Default: 64.
|
||||
|
||||
config HIDKBD_RAWSCANCODES
|
||||
bool "Use Raw Scan Codes"
|
||||
|
|
@ -387,18 +388,6 @@ config HIDKBD_RAWSCANCODES
|
|||
If set to y no conversions will be made on the raw keyboard scan
|
||||
codes. This option is useful during testing. Default: ASCII conversion.
|
||||
|
||||
config HIDKBD_ENCODED
|
||||
bool "Encode Special Keys"
|
||||
default n
|
||||
depends on !HIDKBD_RAWSCANCODES && LIBC_KBDCODEC
|
||||
---help---
|
||||
Encode special key press events in the user buffer. In this case,
|
||||
the user end must decode the encoded special key values using the
|
||||
interfaces defined in include/nuttx/input/kbd_codec.h. These
|
||||
special keys include such things as up/down arrows, home and end
|
||||
keys, etc. If this not defined, only 7-bit print-able and control
|
||||
ASCII characters will be provided to the user.
|
||||
|
||||
config HIDKBD_ALLSCANCODES
|
||||
bool "Use All Scancodes"
|
||||
default n
|
||||
|
|
@ -406,12 +395,19 @@ config HIDKBD_ALLSCANCODES
|
|||
If set to y all 231 possible scancodes will be converted to
|
||||
something. Default: 104 key US keyboard.
|
||||
|
||||
config HIDKBD_NODEBOUNCE
|
||||
bool "Disable Debounce"
|
||||
config HIDKBD_REPORT_MODIFIERS
|
||||
bool "Report modifier keys"
|
||||
default n
|
||||
depends on !HIDKBD_RAWSCANCODES
|
||||
---help---
|
||||
If set to y normal debouncing is disabled. Default:
|
||||
Debounce enabled (No repeat keys).
|
||||
Report Ctrl, Shift, Alt and GUI as keys in their own right, using
|
||||
the KEYCODE_LCTRL..KEYCODE_RGUI keycodes, in addition to applying
|
||||
them to the character that they modify. This lets an application
|
||||
bind an action to a modifier or know that one is being held down,
|
||||
which a game needs and a terminal does not.
|
||||
|
||||
Presses are reported before the keys that they modify and
|
||||
releases after.
|
||||
|
||||
config HIDKBD_NOGETREPORT
|
||||
bool "Use Interrupt pipe to get keys"
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue