patacongo edited a comment on pull request #1851: URL: https://github.com/apache/incubator-nuttx/pull/1851#issuecomment-695799871
The following is nonsensical: > Note that that thread could like in your featherwing driver logic. There is a function in nxterm_driver.c called nxterm_ioctl_tap() that permits the nxterm ioctl commands to be called from within the OS. You might even be able to come up with a solution that does not require a dedicated "listener" thread. Perhaps keyboard input could be handled on the work queue and nxterm_ioctl_tap() could be called directly. This makes sense because the featherwing is really an integrated solution, is it not? That is a really dumb idea, of course. The correct behavior is rather complex. Let me try: **The Normal Case:** Keyboard and mouse inputs are received by the application through window callbacks, just like with the X server. The listener needs to inject the keyboard input via nx_kbdin (libs/libnx/nx_kbdin.c) which sends a message to the NX server. The NX server will forward the keyboard input to the window that has focus. The Window application listens for NX server events by calling nx_eventhandler() (libs/libnx/nx_eventhandler) which, if the window has focus when the keypress is entered, forwards the keypress info to the registered window even handler. In apps/examples/nxterm, nxterm_listener.c is the thread that drivers nx_eventhandler(). The "normal" window NX keyboard callback is the function nxwndo_kbdin() in nxterm_wndo.c. It just writes the keyboard data to stdout. **The apps/examples/nxterm/kludge:** apps/examples/nxterm does not do things in the normal way. NSH does not receive keyboard input from NX; it gets it directly from stdin which is probably the host PC serial console. This is okay because only the background window is used and that example does not need the help of NX. **Re-direction of stdout and stderr:** Stdin in and stderrwere re-directed to the NxTerm in nxterm_main.c: 399 /* Now re-direct stdout and stderr so that they use the NX console driver. 400 * Note that stdin is retained (file descriptor 0, probably the serial 401 * console). 402 */ 403 404 printf("nxterm_main: Starting the console task\n"); 405 fflush(stdout); 406 407 fflush(stdout); 408 fflush(stderr); 409 410 fclose(stdout); 411 fclose(stderr); 412 413 dup2(fd, 1); 414 dup2(fd, 2); The BOARDIOC_NXTERM_IOCTL is only called for the case of a redraw event. This happens when a window "above" the current window is moved and the text is exposed. If you use only the background window, then it will always have focus. It will always have focus and will never be redrawn and the BOARDIOC_NXTERM_IOCTL will never be used. Unless, perhaps, you choose to implement pop-up error messages or menus on top of the NxTerm. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org