Add support for key release events

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5464 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2012-12-27 14:01:59 +00:00
parent f18028f1bc
commit 42149b6373
2 changed files with 29 additions and 9 deletions

View File

@ -455,4 +455,7 @@
this build phase.
* apps/examples/hidbkd: Now supports decoding of encoded special keys
if CONFIG_EXAMPLES_HIDKBD_ENCODED is defined.
* apps/examples/hidbkd: Add support for decoding key release events
as well. However, the USB HID keyboard drier has not yet been
updated to detect key release events. That is kind of tricky in
the USB HID keyboard report data.

View File

@ -176,7 +176,7 @@ static void hidkbd_decode(FAR char *buffer, ssize_t nbytes)
{
/* Decode the next thing from the buffer */
ret = kbd_get((FAR struct lib_instream_s *)&kbdstream, &state, &ch);
ret = kbd_decode((FAR struct lib_instream_s *)&kbdstream, &state, &ch);
if (ret == KBD_ERROR)
{
break;
@ -184,14 +184,31 @@ static void hidkbd_decode(FAR char *buffer, ssize_t nbytes)
/* Normal data? Or special key? */
if (ret == KBD_NORMAL)
switch (ret)
{
printf("Data: %c [%02x]\n", isprint(ch) ? ch : '.', ch);
}
else
{
DEBUGASSERT(ret == KBD_SPECIAL);
printf("Special: %d\n", ch);
case KBD_PRESS: /* Key press event */
printf("Normal Press: %c [%02x]\n", isprint(ch) ? ch : '.', ch);
break;
case KBD_RELEASE: /* Key release event */
printf("Normal Release: %c [%02x]\n", isprint(ch) ? ch : '.', ch);
break;
case KBD_SPECPRESS: /* Special key press event */
printf("Special Press: %d\n", ch);
break;
case KBD_SPECREL: /* Special key release event */
printf("Special Release: %d\n", ch);
break;
case KBD_ERROR: /* Error or end-of-file */
printf("EOF: %d\n", ret);
break;
default:
printf("Unexpected: %d\n", ret);
break;
}
}
}