From 47c2b3d4a76fc0671eb679e52d6b7621e1fabae7 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 22 Apr 2016 12:48:27 -0600 Subject: [PATCH] VNC: Add default mouse/keyboard input handlers --- graphics/vnc/server/vnc_keymap.c | 24 ++++++++++ graphics/vnc/server/vnc_receiver.c | 31 ++++++++++++ include/nuttx/video/vnc.h | 75 ++++++++++++++++++++++++++++++ 3 files changed, 130 insertions(+) diff --git a/graphics/vnc/server/vnc_keymap.c b/graphics/vnc/server/vnc_keymap.c index bb5fe3f623..b23e3199a1 100644 --- a/graphics/vnc/server/vnc_keymap.c +++ b/graphics/vnc/server/vnc_keymap.c @@ -48,6 +48,8 @@ #define XK_LATIN1 1 #define XK_XKB_KEYS 1 +#include +#include #include #include @@ -627,4 +629,26 @@ void vnc_key_map(FAR struct vnc_session_s *session, uint16_t keysym, #endif } +/**************************************************************************** + * Function: vnc_kbdout + * + * Description: + * This is the default keyboard callout function. This is simply wrappers around nx_kdbout(), respectively. When configured using vnc_fbinitialize(), the 'arg' must be the correct NXHANDLE value. + * + * Parameters: + * arg - The NXHANDLE from the NX graphics subsystem + * nch - Number of characters + * ch - An array of input characters. + * + * Returned Value: + * None + * + ****************************************************************************/ + +void vnc_kbdout(FAR void *arg, uint8_t nch, FAR const uint8_t *ch) +{ + DEBUGASSERT(arg != NULL); + (void)nx_kbdin((NXHANDLE)arg, nch, ch); +} + #endif /* CONFIG_NX_KBD */ \ No newline at end of file diff --git a/graphics/vnc/server/vnc_receiver.c b/graphics/vnc/server/vnc_receiver.c index 862b39362a..08a001631b 100644 --- a/graphics/vnc/server/vnc_receiver.c +++ b/graphics/vnc/server/vnc_receiver.c @@ -49,6 +49,9 @@ #include #include +#include +#include +#include #include "vnc_server.h" @@ -470,3 +473,31 @@ int vnc_client_encodings(FAR struct vnc_session_s *session, return OK; } + +/**************************************************************************** + * Function: vnc_mouse + * + * Description: + * This is the default keyboard/mouse callout function. This is simply a + * wrapper around nx_mousein(). When + * configured using vnc_fbinitialize(), the 'arg' must be the correct + * NXHANDLE value. + * + * Parameters: + * See vnc_mouseout_t and vnc_kbdout_t typde definitions above. These + * callouts have arguments that match the inputs to nx_kbdin() and + * nx_mousein() (if arg is really of type NXHANDLE). + * + * Returned Value: + * None + * + ****************************************************************************/ + +#ifdef CONFIG_NX_XYINPUT +void vnc_mouseout(FAR void *arg, nxgl_coord_t x, nxgl_coord_t y, + uint8_t buttons) +{ + DEBUGASSERT(arg != NULL); + (void)nx_mousein((NXHANDLE)arg, x, y, buttons); +} +#endif diff --git a/include/nuttx/video/vnc.h b/include/nuttx/video/vnc.h index a3b9f9e675..2dbcbd9e03 100644 --- a/include/nuttx/video/vnc.h +++ b/include/nuttx/video/vnc.h @@ -108,6 +108,8 @@ extern "C" * higher level level callouts can then call nx_kbdin() or nx_mousein() on * behalf of the VNC server. * + * See also vnc_default_fbinitialize() below. + * * Parameters: * display - In the case of hardware with multiple displays, this * specifies the display. Normally this is zero. @@ -129,6 +131,79 @@ extern "C" int vnc_fbinitialize(int display, vnc_kbdout_t kbdout, vnc_mouseout_t mouseout, FAR void *arg); +/**************************************************************************** + * Function: vnc_mouse and vnc_kbdout + * + * Description: + * These are the default keyboard/mouse callout functions. They are + * simply wrappers around nx_mousein() and nx_kdbout(), respectively. When + * configured using vnc_fbinitialize(), the 'arg' must be the correct + * NXHANDLE value. + * + * See also vnc_default_fbinitialize() below. + * + * Parameters: + * See vnc_mouseout_t and vnc_kbdout_t typde definitions above. These + * callouts have arguments that match the inputs to nx_kbdin() and + * nx_mousein() (if arg is really of type NXHANDLE). + * + * Returned Value: + * None + * + ****************************************************************************/ + +#ifdef CONFIG_NX_KBD +void vnc_kbdout(FAR void *arg, uint8_t nch, FAR const uint8_t *ch); +#endif + +#ifdef CONFIG_NX_XYINPUT +void vnc_mouseout(FAR void *arg, nxgl_coord_t x, nxgl_coord_t y, + uint8_t buttons); +#endif + +/**************************************************************************** + * Function: vnc_default_fbinitialize + * + * Description: + * This is just a wrapper around vnc_fbinitialize() that will establish + * the default mouse and keyboard callout functions. + * + * Parameters: + * display - In the case of hardware with multiple displays, this + * specifies the display. Normally this is zero. + * handle - And instance of NXHANDLE returned from initialization of the + * NX graphics system for that display. + * + * Returned Value: + * Zero (OK) is returned on success. Otherwise, a negated errno value is + * returned to indicate the nature of the failure. + * + ****************************************************************************/ + +/* int vnc_default_fbinitialize(nt display, NXHANDLE handle); */ + +#if defined(CONFIG_NX_KBD) && defined(CONFIG_NX_XYINPUT) + +#define vnc_default_fbinitialize(d,h) \ + vnc_fbinitialize((d), vnc_kbdout, vnc_mouseout, (FAR void *)(h)) + +#elif defined(CONFIG_NX_KBD) + +#define vnc_default_fbinitialize(d,h) \ + vnc_fbinitialize((d), vnc_kbdout, NULL, (FAR void *)(h)) + +#elif defined(CONFIG_NX_XYINPUT) + +#define vnc_default_fbinitialize(d,h) \ + vnc_fbinitialize((d), NULL, vnc_mouseout, (FAR void *)(h)) + +#else + +#define vnc_default_fbinitialize(d,h) \ + vnc_fbinitialize((d), NULL, NULL, NULL) + +#endif + #undef EXTERN #ifdef __cplusplus }