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 d028533b8a
commit 7459202633
6 changed files with 330 additions and 126 deletions

View File

@ -3832,4 +3832,8 @@
UG-2864HSWEG01 OLED for the STM32F4Discovery board.
* drivers/usbhost/usbhost_hidkbd.c: Correct a logic error in how
tasks waiting for read data are awakened.
* libc/misc/lib_kbdencode.c and lib_kbddecode.c: Now handles keypress
events too. 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

@ -3623,20 +3623,27 @@ extern void up_ledoff(int led);
<h3><a name="kbddriver">6.3.16 Keyboard/Keypad Drivers</a></h3>
<p>
<b>&quot;Out-of-Band&quot; Commands</b>.
Keyboards and keypads are the same device for NuttX.
<b>Keypads vs. Keyboards</b>
Keyboards and keypads are really the same devices for NuttX.
A keypad is thought of as simply a keyboard with fewer keys.
</p>
<p>
<b>Special Commands</b>.
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 &quot;in-band&quot; keyboard data stream.
However, in addition, most keyboards support actions that cannot be represented as text data.
A keyboard may return simple text data (alphabetic, numeric, and punctuaction) or control characters (enter, control-C, etc.) when a key is pressed.
We can think about this the &quot;normal&quot; keyboard data stream.
However, in addition, most keyboards support actions that cannot be represented as text or control 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, &quot;out-of-band&quot; keyboard commands.
In this case, some special encoding may be required to multiplex the in-band text data and out-of-band command streams.
In this case, some special encoding may be required to multiplex the normal text data and special command key press data streams.
</p>
<p>
<b>Key Press and Release Events</b>
Sometimes the time that a key is released is needed by applications as well.
Thus, in addition to normal and special key press events, it may also be necessary to encode normal and special key release events.
</p>
<p>
<b>Encoding/Decoding</b> Layer</b>.
An optional encoding/decoding layer can be used with the basic character driver to encode the out-of-band commands into the text data stream.
An optional encoding/decoding layer can be used with the basic character driver to encode the keyboard events into the text data stream.
The function interfaces that comprise that encoding/decoding layer are defined in the header file <code>include/nuttx/input/kbd_code.h</code>.
These functions provide an matched set of (a) driver encoding interfaces, and (b) application decoding interfaces.
</p>
@ -3644,21 +3651,23 @@ extern void up_ledoff(int led);
<li>
<p>
<b>Driver Encoding Interfaces</b>.
These are interfaces used by the keyboard/keypad driver to encode keyboard events and data.
</p>
<ul>
<li>
<p>
<b><code>kbd_puttext()</code></b>
<b><code>kbd_press()</code></b>
</p>
<p><b>Function Prototype:</b></p>
<ul><pre>
#include &lt;nuttx/streams.h&gt;
#include &lt;nuttx/input/kbd_codec.h&gt;
void kbd_puttext(int ch, FAR struct lib_outstream_s *stream);
void kbd_press(int ch, FAR struct lib_outstream_s *stream);
</pre></ul>
<p><b>Description:</b></p>
<ul>
Put one byte of normal, &quot;in-band&quot; ASCII data into the output stream.
Indicates a normal key press event.
Put one byte of normal keyboard data into the output stream.
</ul>
<p><b>Input Pameters:</b></p>
<ul>
@ -3676,17 +3685,76 @@ void kbd_puttext(int ch, FAR struct lib_outstream_s *stream);
</li>
<li>
<p>
<b><code>kbd_putspecial()</code></b>
<b><code>kbd_release()</code></b>
</p>
<p><b>Function Prototype:</b></p>
<ul><pre>
#include &lt;nuttx/streams.h&gt;
#include &lt;nuttx/input/kbd_codec.h&gt;
void kbd_putspecial(enum kbd_keycode_e keycode, FAR struct lib_outstream_s *stream);
void kbd_release(uint8_t ch, FAR struct lib_outstream_s *stream);
</pre></ul>
<p><b>Description:</b></p>
<ul>
Put one special, &quot;out-of-band&quot; command into the output stream.
Encode the release of a normal key.
</ul>
<p><b>Input Pameters:</b></p>
<ul>
<li>
<code>ch</code>: The character associated with the key that was releared.
</li>
<li>
<code>stream</code>: An instance of <code>lib_outstream_s</code> to perform the actual low-level put operation.
</li>
</ul>
<p><b>Returned Value:</b></p>
<ul>
None.
</ul>
</li>
<li>
<p>
<b><code>kbd_specpress()</code></b>
</p>
<p><b>Function Prototype:</b></p>
<ul><pre>
#include &lt;nuttx/streams.h&gt;
#include &lt;nuttx/input/kbd_codec.h&gt;
void kbd_specpress(enum kbd_keycode_e keycode, FAR struct lib_outstream_s *stream);
</pre></ul>
<p><b>Description:</b></p>
<ul>
Denotes a special key press event.
Put one special keyboard command into the output stream.
</ul>
<p><b>Input Pameters:</b></p>
<ul>
<li>
<code>keycode</code>: The command to be added to the output stream.
The enumeration <code>enum kbd_keycode_e keycode</code> identifies all commands known to the system.
</li>
<li>
<code>stream</code>: An instance of <code>lib_outstream_s</code> to perform the actual low-level put operation.
</li>
</ul>
<p><b>Returned Value:</b></p>
<ul>
None.
</ul>
</li>
<li>
<p>
<b><code>kbd_specrel()</code></b>
</p>
<p><b>Function Prototype:</b></p>
<ul><pre>
#include &lt;nuttx/streams.h&gt;
#include &lt;nuttx/input/kbd_codec.h&gt;
void kbd_specrel(enum kbd_keycode_e keycode, FAR struct lib_outstream_s *stream);
</pre></ul>
<p><b>Description:</b></p>
<ul>
Denotes a special key release event.
Put one special keyboard command into the output stream.
</ul>
<p><b>Input Pameters:</b></p>
<ul>
@ -3708,17 +3776,18 @@ void kbd_putspecial(enum kbd_keycode_e keycode, FAR struct lib_outstream_s *stre
<li>
<p>
<b>Application Decoding Interfaces</b>.
These are user interfaces to decode the values returned by the keyboard/keypad driver.
</p>
<ul>
<li>
<p>
<b><code>kbd_get()</code></b>
<b><code>kbd_decode()</code></b>
</p>
<p><b>Function Prototype:</b></p>
<ul><pre>
#include &lt;nuttx/streams.h&gt;
#include &lt;nuttx/input/kbd_codec.h&gt;
int kbd_get(FAR struct lib_instream_s *stream, FAR struct kbd_getstate_s *state, FAR uint8_t *pch);
int kbd_decode(FAR struct lib_instream_s *stream, FAR struct kbd_getstate_s *state, FAR uint8_t *pch);
</pre></ul>
<p><b>Description:</b></p>
<ul>
@ -3730,28 +3799,39 @@ int kbd_get(FAR struct lib_instream_s *stream, FAR struct kbd_getstate_s *state,
<code>stream</code>: An instance of <code>lib_instream_s</code> to perform the actual low-level get operation.
</li>
<li>
<code>pch</code>: The location character to save the returned value.
This may be either a normal, &quot;in-band&quot; ASCII characer or a special, "out-of-band" command (i.e., a value from <code>enum kbd_getstate_s</code>.
<code>pch</code>: The location to save the returned value.
This may be either a normal, character code or a special command (i.e., a value from <code>enum kbd_getstate_s</code>.
</li>
<li>
<code>state</code>: A user provided buffer to support parsing.
This structure should be cleared the first time that <code>kbd_get</code> is called.
This structure should be cleared the first time that <code>kbd_decode()</code> is called.
</li>
</ul>
<p><b>Returned Value:</b></p>
<ul>
<li>
<b>1</b>:
Indicates the successful receipt of a special, &quot;out-of-band&quot; command.
The returned value in <code>pch</code> is a value from <code>enum kbd_getstate_s</code>.
</li>
<li>
<b>0</b>:
Indicates the successful receipt of normal, &quot;in-band&quot; ASCII data.
<b><code>KBD_PRESS</code> (0)</b>:
Indicates the successful receipt of normal, keyboard data.
This corresponds to a keypress event.
The returned value in <code>pch</code> is a simple byte of text or control data.
</li>
<li>
<b><code>EOF</code></b>:
<b><code>KBD_RELEASE</code> (1)</b>:
Indicates a key release event.
The returned value in <code>pch</code> is the byte of text or control data corresponding to the released key.
</li>
<li>
<b><code>KBD_SPECPRESS</code> (2)</b>:
Indicates the successful receipt of a special keyboard command.
The returned value in <code>pch</code> is a value from <code>enum kbd_getstate_s</code>.
</li>
<li>
<b><code>KBD_SPECREL</code> (3)</b>:
Indicates a special command key release event.
The returned value in <code>pch</code> is a value from <code>enum kbd_getstate_s</code>.
</li>
<li>
<b><code>KBD_ERROR</code> (<code>EOF</code>)</b>:
An error has getting the next character (reported by the <code>stream</code>).
Normally indicates the end of file.
</li>

View File

@ -530,7 +530,7 @@ static const uint8_t ucmap[USBHID_NUMSCANCODES] =
0, 0, 0, 0, 0, 0, 0, 0, /* 0x40-0x47: F7,F8,F9,F10,F11,F12,PrtScn,ScrollLock */
0, 0, 0, 0, 0, 0, 0, 0, /* 0x48-0x4f: Pause,Insert,Home,PageUp,DeleteForward,End,PageDown,RightArrow */
0, 0, 0, 0, '/', '*', '-', '+', /* 0x50-0x57: LeftArrow,DownArrow,UpArrow,Num Lock,/,*,-,+ */
'\n', '1', '2', '3', '4', '4', '6', '7', /* 0x58-0x5f: Enter,1-7 */
'\n', '1', '2', '3', '4', '5', '6', '7', /* 0x58-0x5f: Enter,1-7 */
'8', '9', '0', '.', 0, 0, 0, '=', /* 0x60-0x67: 8-9,0,.,Non-US \,Application,Power,= */
#ifdef CONFIG_HIDKBD_ALLSCANCODES
0, 0, 0, 0, 0, 0, 0, 0, /* 0x68-0x6f: F13,F14,F15,F16,F17,F18,F19,F20 */
@ -565,7 +565,7 @@ static const uint8_t lcmap[USBHID_NUMSCANCODES] =
0, 0, 0, 0, 0, 0, 0, 0, /* 0x40-0x47: F7,F8,F9,F10,F11,F12,PrtScn,ScrollLock */
0, 0, 0, 0, 0, 0, 0, 0, /* 0x48-0x4f: Pause,Insert,Home,PageUp,DeleteForward,End,PageDown,RightArrow */
0, 0, 0, 0, '/', '*', '-', '+', /* 0x50-0x57: LeftArrow,DownArrow,UpArrow,Num Lock,/,*,-,+ */
'\n', '1', '2', '3', '4', '4', '6', '7', /* 0x58-0x5f: Enter,1-7 */
'\n', '1', '2', '3', '4', '5', '6', '7', /* 0x58-0x5f: Enter,1-7 */
'8', '9', '0', '.', 0, 0, 0, '=', /* 0x60-0x67: 8-9,0,.,Non-US \,Application,Power,= */
#ifdef CONFIG_HIDKBD_ALLSCANCODES
0, 0, 0, 0, 0, 0, 0, 0, /* 0x68-0x6f: F13,F14,F15,F16,F17,F18,F19,F20 */
@ -977,7 +977,7 @@ static inline void usbhost_encodescancode(FAR struct usbhost_state_s *priv,
/* Add the special function value to the user buffer */
kbd_putspecial((enum kbd_keycode_e)encoded,
kbd_specpress((enum kbd_keycode_e)encoded,
(FAR struct lib_outstream_s *)&usbstream);
}
}

View File

@ -1,6 +1,6 @@
/************************************************************************************
* include/nuttx/input/kbd_codec.h
* Serialize and marshaling out-of-band keyboard data
* Serialize and marshaling keyboard data and events
*
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@ -54,9 +54,7 @@
* Public Types
****************************************************************************/
/* These are the special, "out-of-band" keyboard commands recognized by the
* CODEC.
*/
/* These are the special keyboard commands recognized by the CODEC. */
enum kbd_keycode_e
{
@ -190,11 +188,13 @@ enum kbd_keycode_e
#define FIRST_KEYCODE KEYCODE_FWDDEL
#define LAST_KEYCODE KEYCODE_F24
/* kbd_get return values */
/* kbd_decode() return values */
#define KBD_NORMAL 0
#define KBD_SPECIAL 1
#define KBD_ERROR EOF
#define KBD_PRESS 0 /* Key press event */
#define KBD_RELEASE 1 /* Key release event */
#define KBD_SPECPRESS 2 /* Special key press event */
#define KBD_SPECREL 3 /* Special key release event */
#define KBD_ERROR EOF /* Error or end-of-file */
/****************************************************************************
* Public Types
@ -222,10 +222,11 @@ extern "C"
****************************************************************************/
/****************************************************************************
* Name: kbd_puttext
* Name: kbd_press
*
* Description:
* Put one byte of normal, "in-band" ASCII data into the output stream.
* Indicates a normal key press event. Put one byte of normal keyboard
* data into the output stream.
*
* Input Parameters:
* ch - The character to be added to the output stream.
@ -237,13 +238,32 @@ extern "C"
*
****************************************************************************/
#define kbd_puttext(ch, stream) (stream)->put((stream), (int)(ch))
#define kbd_press(ch, stream) (stream)->put((stream), (int)(ch))
/****************************************************************************
* Name: kbd_putspecial
* Name: kbd_release
*
* Description:
* Put one special, "out-of-band" command into the output stream.
* Encode the release of a normal key.
*
* Input Parameters:
* ch - The character associated with the key that was releared.
* stream - An instance of lib_outstream_s to do the low-level put
* operation.
*
* Returned Value:
* None
*
****************************************************************************/
void kbd_release(uint8_t ch, FAR struct lib_outstream_s *stream);
/****************************************************************************
* Name: kbd_specpress
*
* Description:
* Denotes a special key press event. Put one special keyboard command
* into the output stream.
*
* Input Parameters:
* keycode - The command to be added to the output stream.
@ -255,7 +275,27 @@ extern "C"
*
****************************************************************************/
void kbd_putspecial(enum kbd_keycode_e keycode,
void kbd_specpress(enum kbd_keycode_e keycode,
FAR struct lib_outstream_s *stream);
/****************************************************************************
* Name: kbd_specrel
*
* Description:
* Denotes a special key release event. Put one special keyboard
* command into the output stream.
*
* Input Parameters:
* keycode - The command to be added to the output stream.
* stream - An instance of lib_outstream_s to do the low-level put
* operation.
*
* Returned Value:
* None
*
****************************************************************************/
void kbd_specrel(enum kbd_keycode_e keycode,
FAR struct lib_outstream_s *stream);
/****************************************************************************
@ -264,7 +304,7 @@ void kbd_putspecial(enum kbd_keycode_e keycode,
****************************************************************************/
/****************************************************************************
* Name: kbd_get
* Name: kbd_decode
*
* Description:
* Get one byte of data or special command from the driver provided input
@ -273,23 +313,29 @@ void kbd_putspecial(enum kbd_keycode_e keycode,
* 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.
* pch - The location to save the returned value. This may be
* either a normal, character code or a special command from enum
* kbd_keycode_e
* state - A user provided buffer to support parsing. This structure
* should be cleared the first time that kbd_get is called.
* should be cleared the first time that kbd_decode is called.
*
* Returned Value:
* 1 - Indicates the successful receipt of a special, "out-of-band" command.
* The returned value in pch is a value from enum kbd_getstate_s.
* 0 - Indicates the successful receipt of normal, "in-band" ASCII data.
* The returned value in pch is a simple byte of text or control data.
*
* KBD_PRESS - Indicates the successful receipt of normal, keyboard data.
* This corresponds to a keypress event. The returned value in pch is a
* simple byte of text or control data corresponding to the pressed key.
* KBD_RELEASE - Indicates a key release event. The returned value in pch
* is the byte of text or control data corresponding to the released key.
* KBD_SPECPRESS - Indicates the successful receipt of a special keyboard
* command. The returned value in pch is a value from enum kbd_getstate_s.
* KBD_SPECREL - Indicates a special key release event. The returned value
* in pch is a value from enum kbd_getstate_s.
* 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,
int kbd_decode(FAR struct lib_instream_s *stream,
FAR struct kbd_getstate_s *state, FAR uint8_t *pch);
#ifdef __cplusplus

View File

@ -1,4 +1,4 @@
/********************************************************************************************
/****************************************************************************
* libc/msic/lib_kbddecode.c
* Decoding side of the Keyboard CODEC
*
@ -32,38 +32,43 @@
* 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 <debug.h>
#include <nuttx/streams.h>
#include <nuttx/ascii.h>
#include <nuttx/input/kbd_codec.h>
/********************************************************************************************
/****************************************************************************
* Pre-Processor Definitions
********************************************************************************************/
****************************************************************************/
#define NDX_ESC 0
#define NDX_BRACKET 1
#define NDX_CODE 2
#define NCX_SEMICOLON 3
#define NDX_TERMINATOR 3
#define NCH_ESC 1
#define NCH_BRACKET 2
#define NCH_CODE 3
#define NCH_SEMICOLON 4
#define NCH_TERMINATOR 4
/********************************************************************************************
#define TERM_MIN ('a' + KBD_RELEASE)
#define TERM_MAX ('a' + KBD_SPECREL)
#define TERM_RETURN(a) ((a) - 'a')
/****************************************************************************
* Private Functions
********************************************************************************************/
****************************************************************************/
/****************************************************************************
* Name: kbd_reget
@ -76,16 +81,11 @@
* 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.
* either a normal, character code or a special command from enum
* kbd_keycode_e
*
* Returned Value:
* 2 - Indicates the successful receipt of a special, "out-of-band" command
* 1 - Indicates the successful receipt of normal, "in-band" ASCII data.
* 0 - Indicates end-of-file or that the stream has been closed
* EOF - An error has getting the next character (reported by the stream).
* KBD_PRESS - Indicates the successful receipt of norma keyboard data.
*
****************************************************************************/
@ -96,15 +96,15 @@ static int kbd_reget(FAR struct kbd_getstate_s *state, FAR uint8_t *pch)
*pch = state->buf[state->ndx];
state->ndx++;
state->nch--;
return KBD_NORMAL;
return KBD_PRESS;
}
/********************************************************************************************
/****************************************************************************
* Public Functions
********************************************************************************************/
****************************************************************************/
/****************************************************************************
* Name: kbd_get
* Name: kbd_decode
*
* Description:
* Get one byte of data or special command from the driver provided input
@ -113,23 +113,29 @@ static int kbd_reget(FAR struct kbd_getstate_s *state, FAR uint8_t *pch)
* 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.
* pch - The location to save the returned value. This may be
* either a normal, character code or a special command from enum
* kbd_keycode_e
* state - A user provided buffer to support parsing. This structure
* should be cleared the first time that kbd_get is called.
* should be cleared the first time that kbd_decode is called.
*
* Returned Value:
* 1 - Indicates the successful receipt of a special, "out-of-band" command.
* The returned value in pch is a value from enum kbd_getstate_s.
* 0 - Indicates the successful receipt of normal, "in-band" ASCII data.
* The returned value in pch is a simple byte of text or control data.
*
* KBD_PRESS - Indicates the successful receipt of normal, keyboard data.
* This corresponds to a keypress event. The returned value in pch is a
* simple byte of text or control data corresponding to the pressed key.
* KBD_RELEASE - Indicates a key release event. The returned value in pch
* is the byte of text or control data corresponding to the released key.
* KBD_SPECPRESS - Indicates the successful receipt of a special keyboard
* command. The returned value in pch is a value from enum kbd_getstate_s.
* KBD_SPECREL - Indicates a special key release event. The returned value
* in pch is a value from enum kbd_getstate_s.
* 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,
int kbd_decode(FAR struct lib_instream_s *stream,
FAR struct kbd_getstate_s *state, FAR uint8_t *pch)
{
int ch;
@ -147,7 +153,7 @@ int kbd_get(FAR struct lib_instream_s *stream,
state->ndx = 0;
/* No, ungotten characters. Check for the beginning of an esc sequence. */
/* No, ungotten characters. Check for the beginning of an ESC sequence. */
ch = stream->get(stream);
if (ch == EOF)
@ -195,7 +201,7 @@ int kbd_get(FAR struct lib_instream_s *stream,
}
}
/* Get and verify the special, "out-of-band" command code */
/* Get and verify the special keyboard data to decode */
ch = stream->get(stream);
if (ch == EOF)
@ -234,12 +240,12 @@ int kbd_get(FAR struct lib_instream_s *stream,
}
else
{
state->buf[NCX_SEMICOLON] = (uint8_t)ch;
state->nch = NCH_SEMICOLON;
state->buf[NDX_TERMINATOR] = (uint8_t)ch;
state->nch = NCH_TERMINATOR;
/* Check for a valid special command code */
if (ch != ';')
if (ch < TERM_MIN || ch > TERM_MAX)
{
/* Not a special command code, return the ESC now and the next two
* characters later.
@ -250,11 +256,12 @@ int kbd_get(FAR struct lib_instream_s *stream,
}
/* We have successfully parsed the the entire escape sequence. Return the
* special code in pch and the value 2.
* keyboard value in pch and the value an indication determined by the
* terminating character.
*/
*pch = state->buf[NDX_CODE];
state->nch = 0;
return KBD_SPECIAL;
return TERM_RETURN(state->buf[NDX_TERMINATOR]);
}

View File

@ -1,4 +1,4 @@
/********************************************************************************************
/****************************************************************************
* libc/msic/lib_kbdencode.c
* Encoding side of the Keyboard CODEC
*
@ -32,11 +32,11 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
********************************************************************************************/
****************************************************************************/
/********************************************************************************************
/****************************************************************************
* Included Files
********************************************************************************************/
****************************************************************************/
#include <nuttx/config.h>
@ -47,19 +47,67 @@
#include <nuttx/ascii.h>
#include <nuttx/input/kbd_codec.h>
/********************************************************************************************
/****************************************************************************
* Pre-Processor Definitions
********************************************************************************************/
/********************************************************************************************
* Public Functions
********************************************************************************************/
****************************************************************************/
/****************************************************************************
* Name: kbd_putspecial
* Name: kbd_encode
*
* Description:
* Put one special, "out-of-band" command into the output stream.
* Encode one special special sequence command into the output stream.
*
* Input Parameters:
* keycode - The command to be added to the output stream.
* stream - An instance of lib_outstream_s to do the low-level put
* operation.
* terminator - Escape sequence terminating character.
*
* Returned Value:
* None
*
****************************************************************************/
static void kbd_encode(uint8_t keycode, FAR struct lib_outstream_s *stream,
uint8_t terminator)
{
stream->put(stream, ASCII_ESC);
stream->put(stream, '[');
stream->put(stream, (int)keycode);
stream->put(stream, terminator);
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: kbd_release
*
* Description:
* Encode the release of a normal key.
*
* Input Parameters:
* ch - The character associated with the key that was releared.
* stream - An instance of lib_outstream_s to do the low-level put
* operation.
*
* Returned Value:
* None
*
****************************************************************************/
void kbd_release(uint8_t ch, FAR struct lib_outstream_s *stream)
{
kbd_encode(ch, stream, ('a' + KBD_RELEASE));
}
/****************************************************************************
* Name: kbd_specpress
*
* Description:
* Denotes a special key press event. Put one special keyboard command
* into the output stream.
*
* Input Parameters:
* keycode - The command to be added to the output stream.
@ -71,14 +119,33 @@
*
****************************************************************************/
void kbd_putspecial(enum kbd_keycode_e keycode,
void kbd_specpress(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, ';');
kbd_encode((uint8_t)keycode, stream, ('a' + KBD_SPECPRESS));
}
/****************************************************************************
* Name: kbd_specrel
*
* Description:
* Denotes a special key release event. Put one special keyboard
* command into the output stream.
*
* Input Parameters:
* keycode - The command to be added to the output stream.
* stream - An instance of lib_outstream_s to do the low-level put
* operation.
*
* Returned Value:
* None
*
****************************************************************************/
void kbd_specrel(enum kbd_keycode_e keycode,
FAR struct lib_outstream_s *stream)
{
DEBUGASSERT(stream && keycode >= KEYCODE_FWDDEL && keycode <= LAST_KEYCODE);
kbd_encode((uint8_t)keycode, stream, ('a' + KBD_SPECREL));
}