summaryrefslogtreecommitdiff
path: root/nuttx/libc/misc/lib_kbdencode.c
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/libc/misc/lib_kbdencode.c
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/libc/misc/lib_kbdencode.c')
-rw-r--r--nuttx/libc/misc/lib_kbdencode.c81
1 files changed, 81 insertions, 0 deletions
diff --git a/nuttx/libc/misc/lib_kbdencode.c b/nuttx/libc/misc/lib_kbdencode.c
new file mode 100644
index 000000000..80bf14777
--- /dev/null
+++ b/nuttx/libc/misc/lib_kbdencode.c
@@ -0,0 +1,81 @@
+/********************************************************************************************
+ * libc/msic/lib_kbdencode.c
+ * Encoding side of the Keyboard CODEC
+ *
+ * Copyright (C) 2012 Gregory Nutt. All rights reserved.
+ * Authors: 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.
+ *
+ ********************************************************************************************/
+
+/********************************************************************************************
+ * Included Files
+ ********************************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <assert.h>
+
+#include <nuttx/streams.h>
+#include <nuttx/ascii.h>
+#include <nuttx/input/kbd_codec.h>
+
+/********************************************************************************************
+ * Pre-Processor Definitions
+ ********************************************************************************************/
+
+/********************************************************************************************
+ * Public Functions
+ ********************************************************************************************/
+
+/****************************************************************************
+ * 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)
+{
+ DEBUGASSERT(stream && keycode >= KEYCODE_FWDDEL && keycode <= LAST_KEYCODE);
+
+ stream->put(stream, ASCII_ESC);
+ stream->put(stream, '[');
+ stream->put(stream, (int)keycode);
+ stream->put(stream, ';');
+}
+