示例#1
0
int arch_tcinitialize(int minor)
{
  FAR NX_DRIVERTYPE *dev;
  nxgl_mxpixel_t color;
  int ret;

  /* Initialize the simulated frame buffer device.  We need to create an
   * X11 window to support the mouse-driven touchscreen simulation.
   */

  ivdbg("Initializing framebuffer\n");
  ret = up_fbinitialize();
  if (ret < 0)
    {
      idbg("up_fbinitialize failed: %d\n", -ret);
      goto errout;
    }

  dev = up_fbgetvplane(0);
  if (!dev)
    {
      idbg("up_fbgetvplane 0 failed\n");
      ret = -ENODEV;
      goto errout_with_fb;
    }

  /* Then open NX */

  ivdbg("Open NX\n");
  g_simtc.hnx = nx_open(dev);
  if (!g_simtc.hnx)
    {
      ret = -errno;
      idbg("nx_open failed: %d\n", ret);
      goto errout_with_fb;
    }

  /* Set the background to the configured background color */

  ivdbg("Set background color=%d\n", CONFIG_EXAMPLES_TOUCHSCREEN_BGCOLOR);

  color = CONFIG_EXAMPLES_TOUCHSCREEN_BGCOLOR;
  ret = nx_setbgcolor(g_simtc.hnx, &color);
  if (ret < 0)
    {
      idbg("nx_setbgcolor failed: %d\n", ret);
      goto errout_with_nx;
    }

  /* Finally, initialize the touchscreen simulation on the X window */

  ret = sim_tcinitialize(minor);
  if (ret < 0)
    {
      idbg("sim_tcinitialize failed: %d\n", ret);
      goto errout_with_nx;
    }
  return OK;

errout_with_nx:
  nx_close(g_simtc.hnx);
  goto errout;
errout_with_fb:
  fb_uninitialize();
errout:
  return ret;
}
示例#2
0
int nxterm_main(int argc, char **argv)
#endif
{
  nxgl_mxpixel_t color;
  int fd;
  int ret;

  /* General Initialization *************************************************/
  /* Reset all global data */

  printf("nxterm_main: Started\n");
  memset(&g_nxterm_vars, 0, sizeof(struct nxterm_state_s));

  /* Call all C++ static constructors */

#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE)
  up_cxxinitialize();
#endif

  /* NSH Initialization *****************************************************/
  /* Initialize the NSH library */

  printf("nxterm_main: Initialize NSH\n");
  nsh_initialize();

  /* If the Telnet console is selected as a front-end, then start the
   * Telnet daemon.
   */

#ifdef CONFIG_NSH_TELNET
  ret = nsh_telnetstart();
  if (ret < 0)
    {
     /* The daemon is NOT running.  Report the the error then fail...
      * either with the serial console up or just exiting.
      */

     fprintf(stderr, "ERROR: Failed to start TELNET daemon: %d\n", ret);
   }
#endif
  /* NX Initialization ******************************************************/
  /* Initialize NX */

  printf("nxterm_main: Initialize NX\n");
  ret = nxterm_initialize();
  printf("nxterm_main: NX handle=%p\n", g_nxterm_vars.hnx);
  if (!g_nxterm_vars.hnx || ret < 0)
    {
      printf("nxterm_main: Failed to get NX handle: %d\n", errno);
      goto errout;
    }

  /* Set the background to the configured background color */

  printf("nxterm_main: Set background color=%d\n", CONFIG_EXAMPLES_NXTERM_BGCOLOR);
  color = CONFIG_EXAMPLES_NXTERM_BGCOLOR;
  ret = nx_setbgcolor(g_nxterm_vars.hnx, &color);
  if (ret < 0)
    {
      printf("nxterm_main: nx_setbgcolor failed: %d\n", errno);
      goto errout_with_nx;
    }

  /* Window Configuration ***************************************************/
  /* Create a window */

  printf("nxterm_main: Create window\n");
  g_nxterm_vars.hwnd = nxtk_openwindow(g_nxterm_vars.hnx, &g_nxtermcb, NULL);
  if (!g_nxterm_vars.hwnd)
    {
      printf("nxterm_main: nxtk_openwindow failed: %d\n", errno);
      goto errout_with_nx;
    }
  printf("nxterm_main: hwnd=%p\n", g_nxterm_vars.hwnd);

  /* Wait until we have the screen resolution.  We'll have this immediately
   * unless we are dealing with the NX server.
   */

  while (!g_nxterm_vars.haveres)
    {
      (void)sem_wait(&g_nxterm_vars.eventsem);
    }
  printf("nxterm_main: Screen resolution (%d,%d)\n", g_nxterm_vars.xres, g_nxterm_vars.yres);

  /* Determine the size and position of the window */

  g_nxterm_vars.wndo.wsize.w = g_nxterm_vars.xres / 2 + g_nxterm_vars.xres / 4;
  g_nxterm_vars.wndo.wsize.h = g_nxterm_vars.yres / 2 + g_nxterm_vars.yres / 4;

  g_nxterm_vars.wpos.x       = g_nxterm_vars.xres / 8;
  g_nxterm_vars.wpos.y       = g_nxterm_vars.yres / 8;

  /* Set the window position */

  printf("nxterm_main: Set window position to (%d,%d)\n",
         g_nxterm_vars.wpos.x, g_nxterm_vars.wpos.y);

  ret = nxtk_setposition(g_nxterm_vars.hwnd, &g_nxterm_vars.wpos);
  if (ret < 0)
    {
      printf("nxterm_main: nxtk_setposition failed: %d\n", errno);
      goto errout_with_hwnd;
    }

  /* Set the window size */

  printf("nxterm_main: Set window size to (%d,%d)\n",
         g_nxterm_vars.wndo.wsize.w, g_nxterm_vars.wndo.wsize.h);

  ret = nxtk_setsize(g_nxterm_vars.hwnd, &g_nxterm_vars.wndo.wsize);
  if (ret < 0)
    {
      printf("nxterm_main: nxtk_setsize failed: %d\n", errno);
      goto errout_with_hwnd;
    }

  /* Open the toolbar */

  printf("nxterm_main: Add toolbar to window\n");
  ret = nxtk_opentoolbar(g_nxterm_vars.hwnd, CONFIG_EXAMPLES_NXTERM_TOOLBAR_HEIGHT, &g_nxtoolcb, NULL);
  if (ret < 0)
    {
      printf("nxterm_main: nxtk_opentoolbar failed: %d\n", errno);
      goto errout_with_hwnd;
    }

  /* Sleep a little bit to allow the server to catch up */

  sleep(2);

  /* NxTerm Configuration ************************************************/
  /* Use the window to create an NX console */

  g_nxterm_vars.wndo.wcolor[0] = CONFIG_EXAMPLES_NXTERM_WCOLOR;
  g_nxterm_vars.wndo.fcolor[0] = CONFIG_EXAMPLES_NXTERM_FONTCOLOR;
  g_nxterm_vars.wndo.fontid    = CONFIG_EXAMPLES_NXTERM_FONTID;

  g_nxterm_vars.hdrvr = nxtk_register(g_nxterm_vars.hwnd, &g_nxterm_vars.wndo, CONFIG_EXAMPLES_NXTERM_MINOR);
  if (!g_nxterm_vars.hdrvr)
    {
      printf("nxterm_main: nxtk_register failed: %d\n", errno);
      goto errout_with_hwnd;
    }

  /* Open the NxTerm driver */

  fd = open(CONFIG_EXAMPLES_NXTERM_DEVNAME, O_WRONLY);
  if (fd < 0)
    {
      printf("nxterm_main: open %s read-only failed: %d\n",
             CONFIG_EXAMPLES_NXTERM_DEVNAME, errno);
      goto errout_with_driver;
    }

  /* Start Console Task *****************************************************/
  /* Now re-direct stdout and stderr so that they use the NX console driver.
   * Note that stdin is retained (file descriptor 0, probably the the serial console).
    */

   printf("nxterm_main: Starting the console task\n");
   fflush(stdout);

  (void)fflush(stdout);
  (void)fflush(stderr);

  (void)fclose(stdout);
  (void)fclose(stderr);

  (void)dup2(fd, 1);
  (void)dup2(fd, 2);

   /* And we can close our original driver file descriptor */

   close(fd);

   /* And start the console task.  It will inherit stdin, stdout, and stderr
    * from this task.
    */

   g_nxterm_vars.pid = task_create("NxTerm", CONFIG_EXAMPLES_NXTERM_PRIO,
                                  CONFIG_EXAMPLES_NXTERM_STACKSIZE,
                                  nxterm_task, NULL);
   ASSERT(g_nxterm_vars.pid > 0);
   return EXIT_SUCCESS;

  /* Error Exits ************************************************************/

errout_with_driver:
  (void)nxterm_unregister(g_nxterm_vars.hdrvr);

errout_with_hwnd:
  (void)nxtk_closewindow(g_nxterm_vars.hwnd);

errout_with_nx:
  /* Disconnect from the server */

  nx_disconnect(g_nxterm_vars.hnx);
errout:
  return EXIT_FAILURE;
}
示例#3
0
int nxlines_main(int argc, char *argv[])
{
    nxgl_mxpixel_t color;
    int ret;

    /* Initialize NX */

    ret = nxlines_initialize();
    message("nxlines_main: NX handle=%p\n", g_nxlines.hnx);
    if (!g_nxlines.hnx || ret < 0)
    {
        message("nxlines_main: Failed to get NX handle: %d\n", errno);
        g_nxlines.code = NXEXIT_NXOPEN;
        goto errout;
    }

    /* Set the background to the configured background color */

    message("nxlines_main: Set background color=%d\n",
            CONFIG_EXAMPLES_NXLINES_BGCOLOR);

    color = CONFIG_EXAMPLES_NXLINES_BGCOLOR;
    ret = nx_setbgcolor(g_nxlines.hnx, &color);
    if (ret < 0)
    {
        message("nxlines_main: nx_setbgcolor failed: %d\n", errno);
        g_nxlines.code = NXEXIT_NXSETBGCOLOR;
        goto errout_with_nx;
    }

    /* Get the background window */

    ret = nx_requestbkgd(g_nxlines.hnx, &g_nxlinescb, NULL);
    if (ret < 0)
    {
        message("nxlines_main: nx_setbgcolor failed: %d\n", errno);
        g_nxlines.code = NXEXIT_NXREQUESTBKGD;
        goto errout_with_nx;
    }

    /* Wait until we have the screen resolution.  We'll have this immediately
     * unless we are dealing with the NX server.
     */

    while (!g_nxlines.havepos)
    {
        (void)sem_wait(&g_nxlines.sem);
    }
    message("nxlines_main: Screen resolution (%d,%d)\n", g_nxlines.xres, g_nxlines.yres);

    /* Now, say perform the lines (these test does not return so the remaining
     * logic is cosmetic).
     */

    nxlines_test(g_nxlines.hbkgd);

    /* Release background */

    (void)nx_releasebkgd(g_nxlines.hbkgd);

    /* Close NX */

errout_with_nx:
    message("nxlines_main: Close NX\n");
    nx_close(g_nxlines.hnx);
errout:
    return g_nxlines.code;
}
示例#4
0
int nximage_main(int argc, char *argv[])
#endif
{
  nxgl_mxpixel_t color;
  int ret;

  /* Initialize NX */

  ret = nximage_initialize();
  printf("nximage_main: NX handle=%p\n", g_nximage.hnx);
  if (!g_nximage.hnx || ret < 0)
    {
      printf("nximage_main: Failed to get NX handle: %d\n", errno);
      g_nximage.code = NXEXIT_NXOPEN;
      goto errout;
    }

  /* Set the background to the configured background color */

  color =  nximage_bgcolor();
  printf("nximage_main: Set background color=%u\n", color);

  ret = nx_setbgcolor(g_nximage.hnx, &color);
  if (ret < 0)
    {
      printf("nximage_main: nx_setbgcolor failed: %d\n", errno);
      g_nximage.code = NXEXIT_NXSETBGCOLOR;
      goto errout_with_nx;
    }

  /* Get the background window */

  ret = nx_requestbkgd(g_nximage.hnx, &g_nximagecb, NULL);
  if (ret < 0)
    {
      printf("nximage_main: nx_setbgcolor failed: %d\n", errno);
      g_nximage.code = NXEXIT_NXREQUESTBKGD;
      goto errout_with_nx;
    }

  /* Wait until we have the screen resolution.  We'll have this immediately
   * unless we are dealing with the NX server.
   */

  while (!g_nximage.havepos)
    {
      (void)sem_wait(&g_nximage.sem);
    }
  printf("nximage_main: Screen resolution (%d,%d)\n", g_nximage.xres, g_nximage.yres);

  /* Now, put up the NuttX logo and wait a bit so that it visible. */

  nximage_image(g_nximage.hbkgd);
  sleep(5);

  /* Release background */

  (void)nx_releasebkgd(g_nximage.hbkgd);

  /* Close NX */

errout_with_nx:
  printf("nximage_main: Close NX\n");
  nx_close(g_nximage.hnx);
errout:
  return g_nximage.code;
}
示例#5
0
int nxtext_main(int argc, char **argv)
{
  FAR struct nxtext_state_s *bgstate;
  NXWINDOW hwnd = NULL;
  nxgl_mxpixel_t color;
  int popcnt;
  int bkgndx;
  int ret;

  /* Initialize NX */

  ret = nxtext_initialize();
  message("nxtext_main: NX handle=%p\n", g_hnx);
  if (!g_hnx || ret < 0)
    {
      message("nxtext_main: Failed to get NX handle: %d\n", errno);
      g_exitcode = NXEXIT_NXOPEN;
      goto errout;
    }

  /* Get the configured font handles */

  g_bghfont = nxf_getfonthandle(CONFIG_EXAMPLES_NXTEXT_BGFONTID);
  if (!g_bghfont)
    {
      message("nxtext_main: Failed to get background font handle: %d\n", errno);
      g_exitcode = NXEXIT_FONTOPEN;
      goto errout;
    }

  g_puhfont = nxf_getfonthandle(CONFIG_EXAMPLES_NXTEXT_PUFONTID);
  if (!g_puhfont)
    {
      message("nxtext_main: Failed to get pop-up font handle: %d\n", errno);
      g_exitcode = NXEXIT_FONTOPEN;
      goto errout;
    }

  /* Set the background to the configured background color */

  message("nxtext_main: Set background color=%d\n", CONFIG_EXAMPLES_NXTEXT_BGCOLOR);
  color = CONFIG_EXAMPLES_NXTEXT_BGCOLOR;
  ret = nx_setbgcolor(g_hnx, &color);
  if (ret < 0)
    {
      message("nxtext_main: nx_setbgcolor failed: %d\n", errno);
      g_exitcode = NXEXIT_NXSETBGCOLOR;
      goto errout_with_nx;
    }

  /* Get the background window */

  bgstate = nxbg_getstate();
  ret = nx_requestbkgd(g_hnx, &g_nxtextcb, bgstate);
  if (ret < 0)
    {
      message("nxtext_main: nx_setbgcolor failed: %d\n", errno);
      g_exitcode = NXEXIT_NXREQUESTBKGD;
      goto errout_with_nx;
    }

  /* Wait until we have the screen resolution.  We'll have this immediately
   * unless we are dealing with the NX server.
   */

  while (!b_haveresolution)
    {
      (void)sem_wait(&g_semevent);
    }
  message("nxtext_main: Screen resolution (%d,%d)\n", g_xres, g_yres);

  /* Now loop, adding text to the background and periodically presenting
   * a pop-up window.
   */

  popcnt = 0;
  bkgndx = 0;
  for (;;)
    {
      /* Sleep for one second */

      sleep(1);
      popcnt++;

      /* Each three seconds, create a pop-up window.  Destroy the pop-up
       * window after two more seconds.
       */

      if (popcnt == 3)
        {
          /* Create a pop-up window */

          hwnd = nxpu_open();

          /* Give keyboard input to the top window (which should be the pop-up) */

#ifdef CONFIG_NX_KBD
          message("nxtext_main: Send keyboard input: %s\n", g_pumsg);
          ret = nx_kbdin(g_hnx, strlen((FAR const char *)g_pumsg), g_pumsg);
          if (ret < 0)
           {
             message("nxtext_main: nx_kbdin failed: %d\n", errno);
             goto errout_with_hwnd;
           }
#endif
        }
      else if (popcnt == 5)
        {
          /* Destroy the pop-up window and restart the sequence */

          message("nxtext_main: Close pop-up\n");
          (void)nxpu_close(hwnd);
          popcnt = 0;
        }

      /* Give another line of text to the background window.  Force this
       * text to go the background by calling the background window interfaces
       * directly.
       */

      nxbg_write(g_bgwnd, (FAR const uint8_t *)g_bgmsg[bkgndx], strlen(g_bgmsg[bkgndx]));
      if (++bkgndx >= BGMSG_LINES)
        {
          bkgndx = 0;
        }
    }

  /* Close the pop-up window */

errout_with_hwnd:
  if (popcnt >= 3)
    {
      message("nxtext_main: Close pop-up\n");
     (void)nxpu_close(hwnd);
    }

//errout_with_bkgd:
  (void)nx_releasebkgd(g_bgwnd);

errout_with_nx:
#ifdef CONFIG_NX_MULTIUSER
  /* Disconnect from the server */

  message("nxtext_main: Disconnect from the server\n");
  nx_disconnect(g_hnx);
#else
  /* Close the server */

  message("nxtext_main: Close NX\n");
  nx_close(g_hnx);
#endif
errout:
  return g_exitcode;
}
示例#6
0
int nxhello_main(int argc, char *argv[])
#endif
{
  nxgl_mxpixel_t color;
  int ret;

  /* Initialize NX */

  ret = nxhello_initialize();
  printf("nxhello_main: NX handle=%p\n", g_nxhello.hnx);
  if (!g_nxhello.hnx || ret < 0)
    {
      printf("nxhello_main: Failed to get NX handle: %d\n", errno);
      g_nxhello.code = NXEXIT_NXOPEN;
      goto errout;
    }

  /* Get the default font handle */

  g_nxhello.hfont = nxf_getfonthandle(CONFIG_EXAMPLES_NXHELLO_FONTID);
  if (!g_nxhello.hfont)
    {
      printf("nxhello_main: Failed to get font handle: %d\n", errno);
      g_nxhello.code = NXEXIT_FONTOPEN;
      goto errout;
    }

  /* Set the background to the configured background color */

  printf("nxhello_main: Set background color=%d\n",
         CONFIG_EXAMPLES_NXHELLO_BGCOLOR);

  color = CONFIG_EXAMPLES_NXHELLO_BGCOLOR;
  ret = nx_setbgcolor(g_nxhello.hnx, &color);
  if (ret < 0)
    {
      printf("nxhello_main: nx_setbgcolor failed: %d\n", errno);
      g_nxhello.code = NXEXIT_NXSETBGCOLOR;
      goto errout_with_nx;
    }

  /* Get the background window */

  ret = nx_requestbkgd(g_nxhello.hnx, &g_nxhellocb, NULL);
  if (ret < 0)
    {
      printf("nxhello_main: nx_setbgcolor failed: %d\n", errno);
      g_nxhello.code = NXEXIT_NXREQUESTBKGD;
      goto errout_with_nx;
    }

  /* Wait until we have the screen resolution.  We'll have this immediately
   * unless we are dealing with the NX server.
   */

  while (!g_nxhello.havepos)
    {
      (void)sem_wait(&g_nxhello.sem);
    }
  printf("nxhello_main: Screen resolution (%d,%d)\n", g_nxhello.xres, g_nxhello.yres);

  /* Now, say hello and exit, sleeping a little before each. */

  sleep(1);
  nxhello_hello(g_nxhello.hbkgd);
  sleep(5000);

  /* Release background */

  (void)nx_releasebkgd(g_nxhello.hbkgd);

  /* Close NX */

errout_with_nx:
  printf("nxhello_main: Close NX\n");
  nx_close(g_nxhello.hnx);
errout:
  return g_nxhello.code;
}
int nx_main(int argc, char *argv[])
{
  NXEGWINDOW hwnd1;
  NXEGWINDOW hwnd2;
  struct nxgl_size_s size;
  struct nxgl_point_s pt;
  nxgl_mxpixel_t color;
  int ret;

  /* Initialize */

  ret = nxeg_initialize();
  message("nx_main: NX handle=%p\n", g_hnx);
  if (!g_hnx || ret < 0)
    {
      message("nx_main: Failed to get NX handle: %d\n", errno);
      g_exitcode = NXEXIT_NXOPEN;
      goto errout;
    }

  /* Get the default font handle */

  g_fonthandle = nxf_getfonthandle(CONFIG_EXAMPLES_NX_FONTID);
  if (!g_fonthandle)
    {
      message("nx_main: Failed to get font handle: %d\n", errno);
      g_exitcode = NXEXIT_FONTOPEN;
      goto errout;
    }

  /* Set the background to the configured background color */

  message("nx_main: Set background color=%d\n", CONFIG_EXAMPLES_NX_BGCOLOR);
  color = CONFIG_EXAMPLES_NX_BGCOLOR;
  ret = nx_setbgcolor(g_hnx, &color);
  if (ret < 0)
    {
      message("nx_main: nx_setbgcolor failed: %d\n", errno);
      g_exitcode = NXEXIT_NXSETBGCOLOR;
      goto errout_with_nx;
    }

  /* Create window #1 */

  message("nx_main: Create window #1\n");
  nxeg_initstate(&g_wstate[0], 1, CONFIG_EXAMPLES_NX_COLOR1);
  hwnd1 = nxeg_openwindow(&g_nxcb, &g_wstate[0]);
  message("nx_main: hwnd1=%p\n", hwnd1);
  if (!hwnd1)
    {
      goto errout_with_nx;
    }

  /* Wait until we have the screen resolution */

  while (!b_haveresolution)
    {
      (void)sem_wait(&g_semevent);
    }
  message("nx_main: Screen resolution (%d,%d)\n", g_xres, g_yres);

  /* Set the size of the window 1 */

  size.w = g_xres / 2;
  size.h = g_yres / 2;

  message("nx_main: Set window #1 size to (%d,%d)\n", size.w, size.h);
  ret = nxeg_setsize(hwnd1, &size);
  if (ret < 0)
    {
      goto errout_with_hwnd1;
    }

  /* Sleep a bit -- both so that we can see the result of the above operations
   * but also, in the multi-user case, so that the server can get a chance to
   * actually do them!
   */

  message("nx_main: Sleeping\n\n");
  sleep(1);

  /* Set the position of window #1 */

  pt.x = g_xres / 8;
  pt.y = g_yres / 8;

  message("nx_main: Set window #1 postion to (%d,%d)\n", pt.x, pt.y);
  ret = nxeg_setposition(hwnd1, &pt);
  if (ret < 0)
    {
      goto errout_with_hwnd1;
    }

  /* Sleep a bit */

  message("nx_main: Sleeping\n\n");
  sleep(1);

  /* Open the toolbar */

#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
  message("nx_main: Add toolbar to window #1\n");
  ret = nxeq_opentoolbar(hwnd1, CONFIG_EXAMPLES_NX_TOOLBAR_HEIGHT, &g_tbcb, &g_wstate[0]);
  if (ret < 0)
    {
      goto errout_with_hwnd1;
    }

  /* Sleep a bit */

  message("nx_main: Sleeping\n\n");
  sleep(1);
#endif

  /* Create window #2 */

  message("nx_main: Create window #2\n");
  nxeg_initstate(&g_wstate[1], 2, CONFIG_EXAMPLES_NX_COLOR2);
  hwnd2 = nxeg_openwindow(&g_nxcb, &g_wstate[1]);
  message("nx_main: hwnd2=%p\n", hwnd2);
  if (!hwnd2)
    {
      goto errout_with_hwnd1;
    }

  /* Sleep a bit */

  message("nx_main: Sleeping\n\n");
  sleep(1);

  /* Set the size of the window 2 == size of window 1*/

  message("nx_main: Set hwnd2 size to (%d,%d)\n", size.w, size.h);
  ret = nxeg_setsize(hwnd2, &size);
  if (ret < 0)
    {
      goto errout_with_hwnd2;
    }

  /* Sleep a bit */

  message("nx_main: Sleeping\n\n");
  sleep(1);

  /* Set the position of window #2 */

  pt.x = g_xres - size.w - pt.x;
  pt.y = g_yres - size.h - pt.y;

  message("nx_main: Set hwnd2 postion to (%d,%d)\n", pt.x, pt.y);
  ret = nxeg_setposition(hwnd2, &pt);
  if (ret < 0)
    {
      goto errout_with_hwnd2;
    }

  /* Sleep a bit */

  message("nx_main: Sleeping\n\n");
  sleep(1);

#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
  message("nx_main: Add toolbar to window #2\n");
  ret = nxeq_opentoolbar(hwnd2, CONFIG_EXAMPLES_NX_TOOLBAR_HEIGHT, &g_tbcb, &g_wstate[1]);
  if (ret < 0)
    {
      goto errout_with_hwnd2;
    }

  /* Sleep a bit */

  message("nx_main: Sleeping\n\n");
  sleep(1);
#endif

  /* Give keyboard input to the top window -- should be window #2 */

#ifdef CONFIG_NX_KBD
  message("nx_main: Send keyboard input: %s\n", g_kbdmsg1);
  ret = nx_kbdin(g_hnx, strlen((FAR const char *)g_kbdmsg1), g_kbdmsg1);
  if (ret < 0)
    {
      message("nx_main: nx_kbdin failed: %d\n", errno);
      goto errout_with_hwnd2;
    }

  /* Sleep a bit */

  message("nx_main: Sleeping\n\n");
  sleep(1);
#endif

  /* Lower window 2 */

  message("nx_main: Lower window #2\n");
  ret = nxeg_lower(hwnd2);
  if (ret < 0)
    {
      goto errout_with_hwnd2;
    }

  /* Sleep a bit */

  message("nx_main: Sleeping\n\n");
  sleep(1);

  /* Put mouse left-button clicks all over the screen and see who responds */

#ifdef CONFIG_NX_MOUSE
  nxeg_drivemouse();

  /* Sleep a bit */

  message("nx_main: Sleeping\n\n");
  sleep(1);
#endif

  /* Give keyboard input to the top window -- should be window #1 */

#ifdef CONFIG_NX_KBD
  message("nx_main: Send keyboard input: %s\n", g_kbdmsg2);
  ret = nx_kbdin(g_hnx, strlen((FAR const char *)g_kbdmsg2), g_kbdmsg2);
  if (ret < 0)
    {
      message("nx_main: nx_kbdin failed: %d\n", errno);
      goto errout_with_hwnd2;
    }

  /* Sleep a bit */

  message("nx_main: Sleeping\n\n");
  sleep(1);
#endif

  /* Raise window 2 */

  message("nx_main: Raise window #2\n");
  ret = nxeg_raise(hwnd2);
  if (ret < 0)
    {
      goto errout_with_hwnd2;
    }

  /* Put mouse left-button clicks all over the screen and see who responds */

#ifdef CONFIG_NX_MOUSE
  nxeg_drivemouse();
#endif

  /* Sleep a bit */

  message("nx_main: Sleeping\n\n");
  sleep(2);

  /* Close the window 2 */

errout_with_hwnd2:
  message("nx_main: Close window #2\n");
  (void)nxeg_closewindow(hwnd2, &g_wstate[1]);

  /* Close the window1 */

errout_with_hwnd1:
  message("nx_main: Close window #1\n");
  (void)nxeg_closewindow(hwnd1, &g_wstate[0]);

errout_with_nx:
#ifdef CONFIG_NX_MULTIUSER
  /* Disconnect from the server */

  message("nx_main: Disconnect from the server\n");
  nx_disconnect(g_hnx);
#else
  /* Close the server */

  message("nx_main: Close NX\n");
  nx_close(g_hnx);
#endif
errout:
  return g_exitcode;
}
示例#8
0
int board_tsc_setup(int minor)
{
  FAR NX_DRIVERTYPE *dev;
  nxgl_mxpixel_t color;
  int ret;

  /* Initialize the simulated frame buffer device.  We need to create an
   * X11 window to support the mouse-driven touchscreen simulation.
   */

  iinfo("Initializing framebuffer\n");
  ret = up_fbinitialize(0);
  if (ret < 0)
    {
      ierr("ERROR: up_fbinitialize failed: %d\n", -ret);
      goto errout;
    }

  dev = up_fbgetvplane(0, 0);
  if (!dev)
    {
      ierr("ERROR: up_fbgetvplane 0 failed\n");
      ret = -ENODEV;
      goto errout_with_fb;
    }

  /* Then open NX */

  iinfo("Open NX\n");
  g_simtc.hnx = nx_open(dev);
  if (!g_simtc.hnx)
    {
      ret = -errno;
      ierr("ERROR: nx_open failed: %d\n", ret);
      goto errout_with_fb;
    }

#ifdef CONFIG_VNCSERVER
  /* Setup the VNC server to support keyboard/mouse inputs */

  ret = vnc_default_fbinitialize(0, g_simtc.hnx);
  if (ret < 0)
    {
      ierr("ERROR: vnc_default_fbinitialize failed: %d\n", ret);
      goto errout_with_fb;
    }
#endif

  /* Set the background to the configured background color */

  iinfo("Set background color=%d\n", CONFIG_EXAMPLES_TOUCHSCREEN_BGCOLOR);

  color = CONFIG_EXAMPLES_TOUCHSCREEN_BGCOLOR;
  ret = nx_setbgcolor(g_simtc.hnx, &color);
  if (ret < 0)
    {
      ierr("ERROR: nx_setbgcolor failed: %d\n", ret);
      goto errout_with_nx;
    }

  /* Finally, initialize the touchscreen simulation on the X window */

  ret = board_tsc_setup(minor);
  if (ret < 0)
    {
      ierr("ERROR: board_tsc_setup failed: %d\n", ret);
      goto errout_with_nx;
    }
  return OK;

errout_with_nx:
  nx_close(g_simtc.hnx);
  goto errout;
errout_with_fb:
  up_fbuninitialize(0);
errout:
  return ret;
}