summaryrefslogtreecommitdiff
path: root/nuttx/include
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-12-25 17:22:58 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-12-25 17:22:58 +0000
commit81167b4592a18d9d80d1ed7795953addb71844c8 (patch)
tree2e052235e4dcf59a648996f8a77a98e9ad5e904b /nuttx/include
parent62b8fb69badccc3f10fb5184b9d375fea23ca59f (diff)
downloadpx4-nuttx-81167b4592a18d9d80d1ed7795953addb71844c8.tar.gz
px4-nuttx-81167b4592a18d9d80d1ed7795953addb71844c8.tar.bz2
px4-nuttx-81167b4592a18d9d80d1ed7795953addb71844c8.zip
Add logic to serialize and marshal out-of-band keyboard commands
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5460 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/include')
-rw-r--r--nuttx/include/nuttx/input/kbd_codec.h292
-rw-r--r--nuttx/include/nuttx/usb/hid.h2
2 files changed, 293 insertions, 1 deletions
diff --git a/nuttx/include/nuttx/input/kbd_codec.h b/nuttx/include/nuttx/input/kbd_codec.h
new file mode 100644
index 000000000..b103d544e
--- /dev/null
+++ b/nuttx/include/nuttx/input/kbd_codec.h
@@ -0,0 +1,292 @@
+/************************************************************************************
+ * include/nuttx/input/kbd_codec.h
+ * Serialize and marshaling out-of-band keyboard data
+ *
+ * Copyright (C) 2012 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gnutt@nuttx.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ************************************************************************************/
+
+#ifndef __INCLUDE_NUTTX_INPUT_KBD_CODEC_H
+#define __INCLUDE_NUTTX_INPUT_KBD_CODEC_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <nuttx/streams.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Types
+ ****************************************************************************/
+
+/* These are the special, "out-of-band" keyboard commands recognized by the
+ * CODEC.
+ */
+
+enum kbd_keycode_e
+{
+ KEYCODE_NORMAL = 0, /* Not a special keycode */
+
+ /* Delete and Backspace keycodes (in case they may be different than the
+ * ASCII BKSP and DEL values.
+ */
+
+ KEYCODE_FWDDEL, /* DELete (forward delete) */
+ KEYCODE_BACKDEL, /* Backspace (backward delete) */
+
+ /* Cursor movement */
+
+ KEYCODE_HOME, /* Home */
+ KEYCODE_END, /* End */
+ KEYCODE_LEFT, /* Left arrow */
+ KEYCODE_RIGHT, /* Right arrow */
+ KEYCODE_UP, /* Up arrow */
+ KEYCODE_DOWN, /* Down arrow */
+ KEYCODE_PAGEUP, /* Page up */
+ KEYCODE_PAGEDOWN, /* Page down */
+
+ /* Edit commands */
+
+ KEYCODE_INSERT, /* Insert */
+ KEYCODE_AGAIN, /* Again */
+ KEYCODE_UNDO, /* Undo */
+ KEYCODE_REDO, /* Redo */
+ KEYCODE_CUT, /* Cut */
+ KEYCODE_COPY, /* Copy */
+ KEYCODE_PASTE, /* Paste */
+ KEYCODE_FIND , /* Find */
+
+ /* Selection codes */
+
+ KEYCODE_ENTER, /* Enter */
+ KEYCODE_SELECT, /* Select */
+ KEYCODE_EXECUTE, /* Execute */
+
+ /* Keyboard modes */
+
+ KEYCODE_CAPSLOCK, /* Caps Lock */
+ KEYCODE_SCROLLLOCK, /* Scroll Lock */
+ KEYCODE_NUMLOCK, /* Keypad Num Lock and Clear */
+ KEYCODE_LCAPSLOCK, /* Locking Caps Lock */
+ KEYCODE_LNUMLOCK, /* Locking Num Lock */
+ KEYCODE_LSCROLLLOCK, /* Locking Scroll Lock */
+
+ /* Misc control codes */
+
+ KEYCODE_POWER, /* Power */
+ KEYCODE_HELP, /* Help */
+ KEYCODE_MENU, /* Menu */
+ KEYCODE_STOP, /* Stop */
+ KEYCODE_PAUSE, /* Pause */
+ KEYCODE_BREAK, /* Break */
+ KEYCODE_CANCEL, /* Cancel */
+ KEYCODE_PRINTSCN, /* PrintScreen */
+ KEYCODE_SYSREQ, /* SysReq/Attention */
+
+ /* Audio */
+
+ KEYCODE_MUTE, /* Mute */
+ KEYCODE_VOLUP, /* Volume Up */
+ KEYCODE_VOLDOWN, /* Volume Down */
+
+ /* Telephone */
+
+ KEYCODE_ANSWER, /* Answer (phone) */
+ KEYCODE_HANGUP, /* Hang-up (phone) */
+
+ /* Calculator */
+
+ KEYCODE_CLEAR, /* Clear */
+ KEYCODE_CLEARENTRY, /* Clear entry */
+
+ KEYCODE_MEMSET, /* Memory set */
+ KEYCODE_MEMCLEAR, /* Memory clear */
+ KEYCODE_MEMRECALL, /* Memory recall */
+ KEYCODE_MEMADD, /* Memory add */
+ KEYCODE_MEMSUBTRACT, /* Memory substract */
+ KEYCODE_MEMMULTIPY, /* Memory multiply */
+ KEYCODE_MEMDIVIDE, /* Memory divide */
+
+ KEYCODE_BINARY, /* Binary mode */
+ KEYCODE_OCTAL, /* Octal mode */
+ KEYCODE_DECIMAL, /* Decimal mode */
+ KEYCODE_HEXADECIMAL, /* Hexadecimal mode */
+
+ /* Languages */
+
+ KEYCODE_LANG1, /* LANG1 */
+ KEYCODE_LANG2, /* LANG2 */
+ KEYCODE_LANG3, /* LANG3 */
+ KEYCODE_LANG4, /* LANG4 */
+ KEYCODE_LANG5, /* LANG5 */
+ KEYCODE_LANG6, /* LANG6 */
+ KEYCODE_LANG7, /* LANG7 */
+ KEYCODE_LANG8, /* LANG8 */
+
+ /* Context-specific function keys */
+
+ KEYCODE_F1, /* Function key 1 */
+ KEYCODE_F2, /* Function key 2 */
+ KEYCODE_F3, /* Function key 3 */
+ KEYCODE_F4, /* Function key 4 */
+ KEYCODE_F5, /* Function key 5 */
+ KEYCODE_F6, /* Function key 6 */
+ KEYCODE_F7, /* Function key 7 */
+ KEYCODE_F8, /* Function key 8 */
+ KEYCODE_F9, /* Function key 9 */
+ KEYCODE_F10, /* Function key 10 */
+ KEYCODE_F11, /* Function key 11 */
+ KEYCODE_F12, /* Function key 12 */
+ KEYCODE_F13, /* Function key 13 */
+ KEYCODE_F14, /* Function key 14 */
+ KEYCODE_F15, /* Function key 15 */
+ KEYCODE_F16, /* Function key 16 */
+ KEYCODE_F17, /* Function key 17 */
+ KEYCODE_F18, /* Function key 18 */
+ KEYCODE_F19, /* Function key 19 */
+ KEYCODE_F20, /* Function key 20 */
+ KEYCODE_F21, /* Function key 21 */
+ KEYCODE_F22, /* Function key 22 */
+ KEYCODE_F23, /* Function key 23 */
+ KEYCODE_F24 /* Function key 24 */
+};
+
+#define FIRST_KEYCODE KEYCODE_FWDDEL
+#define LAST_KEYCODE KEYCODE_F24
+
+/* kbd_get return values */
+
+#define KBD_NORMAL 0
+#define KBD_SPECIAL 1
+#define KBD_ERROR EOF
+
+/****************************************************************************
+ * Public Types
+ ****************************************************************************/
+
+struct kget_getstate_s
+{
+ uint8_t nch; /* Number of characters in the buffer */
+ uint8_t ndx; /* Index to next character in the buffer */
+ uint8_t buf[4]; /* Buffer of ungotten data */
+};
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/****************************************************************************
+ * The following functions are intended for use by "producer", keyboard
+ * or keypad drivers to encode information into driver buffers.
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: kbd_puttext
+ *
+ * Description:
+ * Put one byte of normal, "in-band" ASCII data into the output stream.
+ *
+ * Input Parameters:
+ * ch - The character to be into the output stream.
+ * stream - An instance of lib_outstream_s to do the low-level put
+ * operation.
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+#define kbd_puttext(ch, stream) (stream)->put((stream), (int)(ch))
+
+/****************************************************************************
+ * Name: kbd_putspecial
+ *
+ * Description:
+ * Put one special, "out-of-band" command into the output stream.
+ *
+ * Input Parameters:
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+void kbd_putspecial(enum kbd_keycode_e keycode,
+ FAR struct lib_outstream_s *stream);
+
+/****************************************************************************
+ * The following functions are intended for use by "consumer" applications
+ * to remove and decode information from the driver provided buffer.
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: kbd_get
+ *
+ * Description:
+ * Put one byte of data or special command from the driver provided input
+ * buffer.
+ *
+ * Input Parameters:
+ * stream - An instance of lib_instream_s to do the low-level get
+ * operation.
+ * pch - The location character to save the returned value. This may be
+ * either a normal, "in-band" ASCII characer or a special, "out-of-band"
+ * command.
+ * state - A user provided buffer to support parsing. This structure
+ * should be cleared the first time that kbd_get is called.
+ *
+ * Returned Value:
+ * 1 - Indicates the successful receipt of a special, "out-of-band" command
+ * 0 - Indicates the successful receipt of normal, "in-band" ASCII data.
+ * EOF - An error has getting the next character (reported by the stream).
+ * Normally indicates the end of file.
+ *
+ ****************************************************************************/
+
+int kbd_get(FAR struct lib_instream_s *stream,
+ FAR struct kget_getstate_s *state, FAR uint8_t *pch);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __INCLUDE_NUTTX_INPUT_KBD_CODEC_H */
+
diff --git a/nuttx/include/nuttx/usb/hid.h b/nuttx/include/nuttx/usb/hid.h
index 5b83f08fc..877203a9c 100644
--- a/nuttx/include/nuttx/usb/hid.h
+++ b/nuttx/include/nuttx/usb/hid.h
@@ -619,7 +619,7 @@
#define USBHID_KBDUSE_RCTRL 0xe4 /* Keyboard RightControl */
#define USBHID_KBDUSE_RSHIFT 0xe5 /* Keyboard RightShift */
#define USBHID_KBDUSE_RALT 0xe6 /* Keyboard RightAlt */
-#define USBHID_KBDUSE_RGUI 0xe7 /* Keyboard Right GUI*/
+#define USBHID_KBDUSE_RGUI 0xe7 /* Keyboard Right GUI */
#define USBHID_KBDUSE_MAX 0xe7