mirror of
https://github.com/apache/nuttx.git
synced 2026-06-03 22:20:31 +08:00
Verified USB HID KBD driver encoding of special characters; apps/examples/hidkbd now decodes encoded keyboar characters.
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5463 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
@@ -316,7 +316,10 @@ CONFIG_DEV_NULL=y
|
|||||||
# CONFIG_WATCHDOG is not set
|
# CONFIG_WATCHDOG is not set
|
||||||
# CONFIG_ANALOG is not set
|
# CONFIG_ANALOG is not set
|
||||||
# CONFIG_BCH is not set
|
# CONFIG_BCH is not set
|
||||||
# CONFIG_INPUT is not set
|
CONFIG_INPUT=y
|
||||||
|
# CONFIG_INPUT_TSC2007 is not set
|
||||||
|
# CONFIG_INPUT_ADS7843E is not set
|
||||||
|
# CONFIG_INPUT_STMPE811 is not set
|
||||||
# CONFIG_LCD is not set
|
# CONFIG_LCD is not set
|
||||||
CONFIG_MMCSD=y
|
CONFIG_MMCSD=y
|
||||||
CONFIG_MMCSD_NSLOTS=1
|
CONFIG_MMCSD_NSLOTS=1
|
||||||
@@ -364,7 +367,7 @@ CONFIG_HIDKBD_STACKSIZE=1024
|
|||||||
CONFIG_HIDKBD_BUFSIZE=64
|
CONFIG_HIDKBD_BUFSIZE=64
|
||||||
CONFIG_HIDKBD_NPOLLWAITERS=2
|
CONFIG_HIDKBD_NPOLLWAITERS=2
|
||||||
# CONFIG_HIDKBD_RAWSCANCODES is not set
|
# CONFIG_HIDKBD_RAWSCANCODES is not set
|
||||||
# CONFIG_HIDKBD_ENCODED is not set
|
CONFIG_HIDKBD_ENCODED=y
|
||||||
# CONFIG_HIDKBD_ALLSCANCODES is not set
|
# CONFIG_HIDKBD_ALLSCANCODES is not set
|
||||||
# CONFIG_HIDKBD_NODEBOUNCE is not set
|
# CONFIG_HIDKBD_NODEBOUNCE is not set
|
||||||
# CONFIG_WIRELESS is not set
|
# CONFIG_WIRELESS is not set
|
||||||
@@ -425,6 +428,10 @@ CONFIG_MM_REGIONS=2
|
|||||||
#
|
#
|
||||||
# Library Routines
|
# Library Routines
|
||||||
#
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# Standard C Library Options
|
||||||
|
#
|
||||||
CONFIG_STDIO_BUFFER_SIZE=256
|
CONFIG_STDIO_BUFFER_SIZE=256
|
||||||
CONFIG_STDIO_LINEBUFFER=y
|
CONFIG_STDIO_LINEBUFFER=y
|
||||||
CONFIG_NUNGET_CHARS=2
|
CONFIG_NUNGET_CHARS=2
|
||||||
@@ -443,6 +450,11 @@ CONFIG_LIB_SENDFILE_BUFSIZE=512
|
|||||||
# CONFIG_ARCH_ROMGETC is not set
|
# CONFIG_ARCH_ROMGETC is not set
|
||||||
# CONFIG_ARCH_OPTIMIZED_FUNCTIONS is not set
|
# CONFIG_ARCH_OPTIMIZED_FUNCTIONS is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# Non-standard Helper Functions
|
||||||
|
#
|
||||||
|
CONFIG_LIB_KBDCODEC=y
|
||||||
|
|
||||||
#
|
#
|
||||||
# Basic CXX Support
|
# Basic CXX Support
|
||||||
#
|
#
|
||||||
@@ -473,6 +485,10 @@ CONFIG_LIB_SENDFILE_BUFSIZE=512
|
|||||||
# CONFIG_EXAMPLES_HELLOXX is not set
|
# CONFIG_EXAMPLES_HELLOXX is not set
|
||||||
# CONFIG_EXAMPLES_JSON is not set
|
# CONFIG_EXAMPLES_JSON is not set
|
||||||
CONFIG_EXAMPLES_HIDKBD=y
|
CONFIG_EXAMPLES_HIDKBD=y
|
||||||
|
CONFIG_EXAMPLES_HIDKBD_DEFPRIO=50
|
||||||
|
CONFIG_EXAMPLES_HIDKBD_STACKSIZE=1024
|
||||||
|
CONFIG_EXAMPLES_HIDKBD_DEVNAME="/dev/kbda"
|
||||||
|
CONFIG_EXAMPLES_HIDKBD_ENCODED=y
|
||||||
# CONFIG_EXAMPLES_KEYPADTEST is not set
|
# CONFIG_EXAMPLES_KEYPADTEST is not set
|
||||||
# CONFIG_EXAMPLES_IGMP is not set
|
# CONFIG_EXAMPLES_IGMP is not set
|
||||||
# CONFIG_EXAMPLES_LCDRW is not set
|
# CONFIG_EXAMPLES_LCDRW is not set
|
||||||
|
|||||||
@@ -89,10 +89,10 @@ config HIDKBD_RAWSCANCODES
|
|||||||
config HIDKBD_ENCODED
|
config HIDKBD_ENCODED
|
||||||
bool "Enocode Special Keys"
|
bool "Enocode Special Keys"
|
||||||
default n
|
default n
|
||||||
depends on !HIDKBD_RAWSCANCODES
|
depends on !HIDKBD_RAWSCANCODES && LIB_KBDCODEC
|
||||||
---help---
|
---help---
|
||||||
Encode special key press events in the user buffer. In this case,
|
Encode special key press events in the user buffer. In this case,
|
||||||
the use end must decode the encoded special key values using the
|
the user end must decode the encoded special key values using the
|
||||||
interfaces defined in include/nuttx/input/kbd_codec.h. These
|
interfaces defined in include/nuttx/input/kbd_codec.h. These
|
||||||
special keys include such things as up/down arrows, home and end
|
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
|
keys, etc. If this not defined, only 7-bit print-able and control
|
||||||
|
|||||||
@@ -131,6 +131,14 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* We cant support encoding of special characters of unless the Keyboard
|
||||||
|
* CODEC is enabled.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CONFIG_LIB_KBDCODEC
|
||||||
|
# undef CONFIG_HIDKBD_ENCODED
|
||||||
|
#endif
|
||||||
|
|
||||||
/* If we are using raw scancodes, then we cannot support encoding of
|
/* If we are using raw scancodes, then we cannot support encoding of
|
||||||
* special characters either.
|
* special characters either.
|
||||||
*/
|
*/
|
||||||
@@ -399,7 +407,7 @@ static struct usbhost_state_s *g_priv; /* Data passed to thread */
|
|||||||
/* The first and last scancode values with encode-able values */
|
/* The first and last scancode values with encode-able values */
|
||||||
|
|
||||||
#define FIRST_ENCODING USBHID_KBDUSE_ENTER /* 0x28 Keyboard Return (ENTER) */
|
#define FIRST_ENCODING USBHID_KBDUSE_ENTER /* 0x28 Keyboard Return (ENTER) */
|
||||||
#ifdef CONFIG_HIDKBD_ALLSCANCODES
|
#ifndef CONFIG_HIDKBD_ALLSCANCODES
|
||||||
# define LAST_ENCODING USBHID_KBDUSE_POWER /* 0x66 Keyboard Power */
|
# define LAST_ENCODING USBHID_KBDUSE_POWER /* 0x66 Keyboard Power */
|
||||||
#else
|
#else
|
||||||
# define LAST_ENCODING USBHID_KBDUSE_KPDHEXADECIMAL /* 0xdd Keypad Hexadecimal */
|
# define LAST_ENCODING USBHID_KBDUSE_KPDHEXADECIMAL /* 0xdd Keypad Hexadecimal */
|
||||||
@@ -874,10 +882,10 @@ static void usbhost_putbuffer(FAR struct usbhost_state_s *priv,
|
|||||||
#ifdef CONFIG_HIDKBD_ENCODED
|
#ifdef CONFIG_HIDKBD_ENCODED
|
||||||
static void usbhost_putstream(FAR struct lib_outstream_s *stream, int ch)
|
static void usbhost_putstream(FAR struct lib_outstream_s *stream, int ch)
|
||||||
{
|
{
|
||||||
FAR struct usbhost_outstream_s *privstream = (FAR struct lib_outstream_s *)stream;
|
FAR struct usbhost_outstream_s *privstream = (FAR struct usbhost_outstream_s *)stream;
|
||||||
|
|
||||||
DEBUGASSERT(privstream && privstream->priv);
|
DEBUGASSERT(privstream && privstream->priv);
|
||||||
usbhost_putbuffer(privstream->priv), (uint8_t)ch);
|
usbhost_putbuffer(privstream->priv, (uint8_t)ch);
|
||||||
stream->nput++;
|
stream->nput++;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -945,7 +953,6 @@ static inline uint8_t usbhost_mapscancode(uint8_t scancode, uint8_t modifier)
|
|||||||
static inline void usbhost_encodescancode(FAR struct usbhost_state_s *priv,
|
static inline void usbhost_encodescancode(FAR struct usbhost_state_s *priv,
|
||||||
uint8_t scancode, uint8_t modifier)
|
uint8_t scancode, uint8_t modifier)
|
||||||
{
|
{
|
||||||
struct usbhost_outstream_s stream;
|
|
||||||
uint8_t encoded;
|
uint8_t encoded;
|
||||||
|
|
||||||
/* Check if the raw scancode is in a valid range */
|
/* Check if the raw scancode is in a valid range */
|
||||||
@@ -954,7 +961,7 @@ static inline void usbhost_encodescancode(FAR struct usbhost_state_s *priv,
|
|||||||
{
|
{
|
||||||
/* Yes the value is within range */
|
/* Yes the value is within range */
|
||||||
|
|
||||||
encoded = encoding(scancode - FIRST_ENCODING);
|
encoded = encoding[scancode - FIRST_ENCODING];
|
||||||
ivdbg(" scancode: %02x modifier: %02x encoded: %d\n",
|
ivdbg(" scancode: %02x modifier: %02x encoded: %d\n",
|
||||||
scancode, modifier, encoded);
|
scancode, modifier, encoded);
|
||||||
|
|
||||||
@@ -964,13 +971,14 @@ static inline void usbhost_encodescancode(FAR struct usbhost_state_s *priv,
|
|||||||
|
|
||||||
/* And it does correspond to a special function key */
|
/* And it does correspond to a special function key */
|
||||||
|
|
||||||
usbstream->stream.put = usbhost_putstream;
|
usbstream.stream.put = usbhost_putstream;
|
||||||
usbstream->stream.nput = 0;
|
usbstream.stream.nput = 0;
|
||||||
usbstream->priv = priv;
|
usbstream.priv = priv;
|
||||||
|
|
||||||
/* Add the special function value to the user buffer */
|
/* Add the special function value to the user buffer */
|
||||||
|
|
||||||
kbd_putspecial((enum kbd_keycode_e)encoded, &usbstream);
|
kbd_putspecial((enum kbd_keycode_e)encoded,
|
||||||
|
(FAR struct lib_outstream_s *)&usbstream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1156,7 +1164,7 @@ static int usbhost_kbdpoll(int argc, char *argv[])
|
|||||||
#ifdef CONFIG_HIDKBD_ENCODED
|
#ifdef CONFIG_HIDKBD_ENCODED
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
usbhost_encodescancode(priv, rpt->key[i], rpt->modifier));
|
usbhost_encodescancode(priv, rpt->key[i], rpt->modifier);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,6 +44,8 @@
|
|||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
#include <nuttx/streams.h>
|
#include <nuttx/streams.h>
|
||||||
|
|
||||||
|
#ifdef CONFIG_LIB_KBDCODEC
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -294,5 +296,6 @@ int kbd_get(FAR struct lib_instream_s *stream,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif /* CONFIG_LIB_KBDCODEC */
|
||||||
#endif /* __INCLUDE_NUTTX_INPUT_KBD_CODEC_H */
|
#endif /* __INCLUDE_NUTTX_INPUT_KBD_CODEC_H */
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
# see misc/tools/kconfig-language.txt.
|
# see misc/tools/kconfig-language.txt.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
comment "Standard C Library Options"
|
||||||
|
|
||||||
config STDIO_BUFFER_SIZE
|
config STDIO_BUFFER_SIZE
|
||||||
int "C STDIO buffer size"
|
int "C STDIO buffer size"
|
||||||
default 64
|
default 64
|
||||||
@@ -273,3 +275,29 @@ config ARCH_BZERO
|
|||||||
of bzero().
|
of bzero().
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
comment "Non-standard Helper Functions"
|
||||||
|
|
||||||
|
config LIB_KBDCODEC
|
||||||
|
bool "Keyboard CODEC"
|
||||||
|
default y
|
||||||
|
---help---
|
||||||
|
In NuttX, a keyboard/keypad driver is simply a character driver that
|
||||||
|
may have an (optional) encoding/decoding layer on the data returned
|
||||||
|
by the character driver. A keyboard may return simple text data
|
||||||
|
(alphabetic, numeric, and punctuaction) or control characters
|
||||||
|
(enter, control-C, etc.). We can think about this the normal
|
||||||
|
"in-band" keyboard data stream. However, in addition, most
|
||||||
|
keyboards support actions that cannot be represented as text data.
|
||||||
|
Such actions include things like cursor controls (home, up arrow,
|
||||||
|
page down, etc.), editing functions (insert, delete, etc.), volume
|
||||||
|
controls, (mute, volume up, etc.) and other special functions. We
|
||||||
|
can think about this as special, "out-of-band" keyboard commands.
|
||||||
|
In this case, some special encoding may be required to multiplex
|
||||||
|
the in-band text data and out-of-band command streams.
|
||||||
|
|
||||||
|
This option enables the functions that implement the encoding and
|
||||||
|
decoding of keyboard data. These are the interfaces prototyped in
|
||||||
|
include/nuttx/input/kbd_codec.h. While not correctly a part of
|
||||||
|
the C library, it is included here because the decoding side of this
|
||||||
|
interface must be accessible by end user programs.
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
config LIBM
|
config LIBM
|
||||||
bool "Math library"
|
bool "Standard Math library"
|
||||||
default n
|
default n
|
||||||
depends on !ARCH_MATH_H
|
depends on !ARCH_MATH_H
|
||||||
---help---
|
---help---
|
||||||
|
|||||||
+7
-1
@@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
# Add the internal C files to the build
|
# Add the internal C files to the build
|
||||||
|
|
||||||
CSRCS += lib_init.c lib_filesem.c lib_kbdencode.c lib_kbddecode.c
|
CSRCS += lib_init.c lib_filesem.c
|
||||||
|
|
||||||
# Add C files that depend on file OR socket descriptors
|
# Add C files that depend on file OR socket descriptors
|
||||||
|
|
||||||
@@ -63,6 +63,12 @@ CSRCS += lib_match.c
|
|||||||
CSRCS += lib_crc32.c
|
CSRCS += lib_crc32.c
|
||||||
CSRCS += lib_dbg.c lib_dumpbuffer.c
|
CSRCS += lib_dbg.c lib_dumpbuffer.c
|
||||||
|
|
||||||
|
# Keyboard driver encoder/decoder
|
||||||
|
|
||||||
|
ifneq ($(CONFIG_LIB_KBDCODEC),0)
|
||||||
|
CSRCS += lib_kbdencode.c lib_kbddecode.c
|
||||||
|
endif
|
||||||
|
|
||||||
# Add the misc directory to the build
|
# Add the misc directory to the build
|
||||||
|
|
||||||
DEPPATH += --dep-path misc
|
DEPPATH += --dep-path misc
|
||||||
|
|||||||
Reference in New Issue
Block a user