mirror of
https://github.com/apache/nuttx.git
synced 2026-08-01 20:28:58 +00:00
drivers/input: report special keys from the keyboard matrix
The matrix driver reported every key with KEYBOARD_PRESS and KEYBOARD_RELEASE, so a board whose matrix has arrows or function keys had no way to say so: the keycode ranges overlap the character range, and the event type is what tells them apart. A keymap entry is a uint32_t, so wrap the entry in KMATRIX_SPECIAL() to declare that it holds a value from enum kbd_keycode_e. Existing keymaps hold characters and are unaffected. While here, drop the cast that truncated the keycode to sixteen bits, and default the device to /dev/kbd0. Applications look for a keyboard under that name, and /dev/keypad0 kept the matrix out of reach of every one of them. Signed-off-by: Jorge Guzman <jorge.gzm@gmail.com>
This commit is contained in:
parent
f47fd03407
commit
59101fa206
2 changed files with 38 additions and 7 deletions
|
|
@ -175,6 +175,7 @@ static void kmatrix_scan_worker(FAR void *arg)
|
|||
bool pressed;
|
||||
bool old_state;
|
||||
uint32_t keycode;
|
||||
uint32_t type;
|
||||
int ret;
|
||||
|
||||
ret = nxmutex_lock(&priv->lock);
|
||||
|
|
@ -212,13 +213,28 @@ static void kmatrix_scan_worker(FAR void *arg)
|
|||
kmatrix_set_state(priv, row, col, pressed);
|
||||
kmatrix_reset_debounce(priv, row, col);
|
||||
|
||||
/* Generate keyboard event */
|
||||
/* Generate keyboard event. A keymap entry wrapped in
|
||||
* KMATRIX_SPECIAL() is a keycode rather than a character,
|
||||
* and has to be reported with a SPEC event type: the two
|
||||
* ranges overlap, so the type is the only way the
|
||||
* application can tell them apart.
|
||||
*/
|
||||
|
||||
keycode = priv->config->keymap[
|
||||
row * priv->config->ncols + col];
|
||||
keyboard_event(&priv->lower, (uint16_t)keycode,
|
||||
pressed ? KEYBOARD_PRESS :
|
||||
KEYBOARD_RELEASE);
|
||||
|
||||
if ((keycode & KMATRIX_SPECIAL_FLAG) != 0)
|
||||
{
|
||||
keycode &= ~KMATRIX_SPECIAL_FLAG;
|
||||
type = pressed ? KEYBOARD_SPECPRESS :
|
||||
KEYBOARD_SPECREL;
|
||||
}
|
||||
else
|
||||
{
|
||||
type = pressed ? KEYBOARD_PRESS : KEYBOARD_RELEASE;
|
||||
}
|
||||
|
||||
keyboard_event(&priv->lower, keycode, type);
|
||||
|
||||
iinfo("Key [%d,%d]: %s (code %lu)\n", row, col,
|
||||
pressed ? "PRESS" : "RELEASE",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue