diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-12-27 14:01:59 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-12-27 14:01:59 +0000 |
commit | 37e2da3332de942dfb728e7ee8f50cd31c9a2676 (patch) | |
tree | 38c8be37c3b6a235365da13ea736acb78b83319a /apps/examples | |
parent | 24f3d5c021bfa7d0a99870d363d86e4e17e4ca63 (diff) | |
download | px4-nuttx-37e2da3332de942dfb728e7ee8f50cd31c9a2676.tar.gz px4-nuttx-37e2da3332de942dfb728e7ee8f50cd31c9a2676.tar.bz2 px4-nuttx-37e2da3332de942dfb728e7ee8f50cd31c9a2676.zip |
Add support for key release events
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5464 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'apps/examples')
-rw-r--r-- | apps/examples/hidkbd/hidkbd_main.c | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/apps/examples/hidkbd/hidkbd_main.c b/apps/examples/hidkbd/hidkbd_main.c index 8a632bab7..d7e79b121 100644 --- a/apps/examples/hidkbd/hidkbd_main.c +++ b/apps/examples/hidkbd/hidkbd_main.c @@ -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; } } } |