diff options
Diffstat (limited to 'nuttx/examples/nx')
-rw-r--r-- | nuttx/examples/nx/nx_events.c | 48 | ||||
-rw-r--r-- | nuttx/examples/nx/nx_main.c | 41 |
2 files changed, 51 insertions, 38 deletions
diff --git a/nuttx/examples/nx/nx_events.c b/nuttx/examples/nx/nx_events.c index a3c7d7830..864b267c8 100644 --- a/nuttx/examples/nx/nx_events.c +++ b/nuttx/examples/nx/nx_events.c @@ -41,6 +41,7 @@ #include <sys/types.h> #include <stdlib.h> +#include <ctype.h> #include <semaphore.h> #include <debug.h> #include <errno.h> @@ -78,7 +79,7 @@ static void nxeg_mousein(NXEGWINDOW hwnd, FAR const struct nxgl_point_s *pos, ubyte buttons, FAR void *arg); #endif #ifdef CONFIG_NX_KBD -static void nxeg_kbdin(NXEGWINDOW hwnd, ubyte nch, const ubyte *ch); +static void nxeg_kbdin(NXWINDOW hwnd, ubyte nch, const ubyte *ch, FAR void *arg); #endif #ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS @@ -93,7 +94,7 @@ static void nxeg_tbmousein(NXEGWINDOW hwnd, FAR const struct nxgl_point_s *pos, ubyte buttons, FAR void *arg); #endif #ifdef CONFIG_NX_KBD -static void nxeg_tbkbdin(NXEGWINDOW hwnd, ubyte nch, const ubyte *ch); +static void nxeg_tbkbdin(NXWINDOW hwnd, ubyte nch, const ubyte *ch, FAR void *arg); #endif #endif @@ -256,11 +257,11 @@ static void nxeg_kbdinfo(ubyte nch, const ubyte *ch) { if (isprint(ch[i])) { - message(" ch[%d]= (%02x)", i, ch[i]); + message(" ch[%d]=%c (%02x)\n", i, ch[i], ch[i]); } else { - message(" ch[%d]=%c (%02x)", i, ch[i], ch[i]); + message(" ch[%d]= (%02x)\n", i, ch[i]); } } } @@ -271,9 +272,9 @@ static void nxeg_kbdinfo(ubyte nch, const ubyte *ch) ****************************************************************************/ #ifdef CONFIG_NX_KBD -static void nxeg_kbdin(NXEGWINDOW hwnd, ubyte nch, const ubyte *ch) +static void nxeg_kbdin(NXWINDOW hwnd, ubyte nch, const ubyte *ch, FAR void *arg) { - message("nxeg_kbdin: hwnd=%p nch=%d\n", hwnd, nch); + message("nxeg_kbdin%d: hwnd=%p nch=%d\n", (int)arg, hwnd, nch); nxeg_kbdinfo(nch, ch); } #endif @@ -333,45 +334,16 @@ static void nxeg_tbmousein(NXEGWINDOW hwnd, FAR const struct nxgl_point_s *pos, #ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS #ifdef CONFIG_NX_KBD -static void nxeg_tbkbdin(NXEGWINDOW hwnd, ubyte nch, const ubyte *ch) +static void nxeg_tbkbdin(NXWINDOW hwnd, ubyte nch, const ubyte *ch, FAR void *arg) { - message("nxeg_tbkbdin: ERROR -- toolbar should not received keyboard input\n"; - message("nxeg_tbkbdin: hwnd=%p nch=%d\n", hwnd, nch); + message("nxeg_tbkbdin: ERROR -- toolbar should not received keyboard input\n"); + message("nxeg_tbkbdin%d: hwnd=%p nch=%d\n", (int)arg, hwnd, nch); nxeg_kbdinfo(nch, ch); } #endif #endif /**************************************************************************** - * Name: nxeg_kbdin2 - ****************************************************************************/ - -#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS -#ifdef CONFIG_NX_KBD -static void nxeg_kbdin2(NXEGWINDOW hwnd, ubyte nch, const ubyte *ch) -{ - message("nxeg_kbdin2: hwnd=%p nch=%d\n", hwnd, nch); - nxeg_kbdinfo(nch, ch); -} -#endif -#endif - -/**************************************************************************** - * Name: nxeg_mousein2 - ****************************************************************************/ - -#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS -#ifdef CONFIG_NX_MOUSE -static void nxeg_mousein2(NXEGWINDOW hwnd, FAR const struct nxgl_point_s *pos, - ubyte buttons, FAR void *arg) -{ - message("nxeg_mousein%d: hwnd=%p pos=(%d,%d) button=%02x\n", - (int)arg, hwnd, pos->x, pos->y, buttons); -} -#endif -#endif - -/**************************************************************************** * Public Functions ****************************************************************************/ diff --git a/nuttx/examples/nx/nx_main.c b/nuttx/examples/nx/nx_main.c index 7e68b47bd..ed7b7a3bb 100644 --- a/nuttx/examples/nx/nx_main.c +++ b/nuttx/examples/nx/nx_main.c @@ -43,6 +43,7 @@ #include <stdio.h> #include <stdlib.h> #include <unistd.h> +#include <string.h> #include <sched.h> #include <pthread.h> #include <errno.h> @@ -72,6 +73,12 @@ static int g_exitcode = NXEXIT_SUCCESS; +#ifdef CONFIG_NX_KBD +static const ubyte g_kbdmsg1[] = "NuttX is cool!"; +static const ubyte g_kbdmsg2[] = "NuttX is fun!"; +#endif + + /**************************************************************************** * Public Data ****************************************************************************/ @@ -660,6 +667,23 @@ int user_start(int argc, char *argv[]) sleep(1); #endif + /* Give keyboard input to the top window -- should be window #2 */ + +#ifdef CONFIG_NX_KBD + message("user_start: Send keyboard input: %s\n", g_kbdmsg1); + ret = nx_kbdin(g_hnx, strlen((FAR const char *)g_kbdmsg1), g_kbdmsg1); + if (ret < 0) + { + message("user_start: nx_kbdin failed: %d\n", errno); + goto errout_with_hwnd2; + } + + /* Sleep a bit */ + + message("user_start: Sleeping\n\n"); + sleep(1); +#endif + /* Lower window 2 */ message("user_start: Lower window #2\n"); @@ -685,6 +709,23 @@ int user_start(int argc, char *argv[]) sleep(1); #endif + /* Give keyboard input to the top window -- should be window #1 */ + +#ifdef CONFIG_NX_KBD + message("user_start: Send keyboard input: %s\n", g_kbdmsg2); + ret = nx_kbdin(g_hnx, strlen((FAR const char *)g_kbdmsg2), g_kbdmsg2); + if (ret < 0) + { + message("user_start: nx_kbdin failed: %d\n", errno); + goto errout_with_hwnd2; + } + + /* Sleep a bit */ + + message("user_start: Sleeping\n\n"); + sleep(1); +#endif + /* Raise window 2 */ message("user_start: Raise window #2\n"); |