NxWM::CNxConsole and NXWidgets::CCallback can now redirect keyboard input to the NxConsole driver
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4754 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
9083c67595
commit
43cae03680
@ -111,3 +111,16 @@
|
|||||||
threading model.
|
threading model.
|
||||||
|
|
||||||
1.2 2012-xx-xx Gregory Nutt <gnutt@nuttx.org>
|
1.2 2012-xx-xx Gregory Nutt <gnutt@nuttx.org>
|
||||||
|
|
||||||
|
* NXWidgets::CCallback: callback arguement is now type CCallback and not
|
||||||
|
CWidgetControl; Added a method to redirect keyboard contacts to either
|
||||||
|
the widgets in the window (via CWidgetControl) or to an NxConsole (via
|
||||||
|
nxcon_kbdin()).
|
||||||
|
* NXWidgets::INxWindow, CBgWindow, CNxTkWindow, CNxToolbar, CNxWindow:
|
||||||
|
Now pass the CCallback intances as the callback argument instead of
|
||||||
|
the CWidgetControl instance. New method redirectNxConsole() will
|
||||||
|
support redirection of any window keyboard input to the NxConsole
|
||||||
|
(via CCallback).
|
||||||
|
* NxWM:CNxConsole: Configures the NxConsole window to redirectin keyboard
|
||||||
|
input to the NxConsole; redirects standard input to the NxConsole
|
||||||
|
device driver.
|
||||||
|
@ -206,6 +206,27 @@ namespace NXWidgets
|
|||||||
|
|
||||||
bool lower(void);
|
bool lower(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Each window implementation also inherits from CCallback. CCallback,
|
||||||
|
* by default, forwards NX keyboard input to the various widgets residing
|
||||||
|
* in the window. But NxConsole is a different usage model; In this case,
|
||||||
|
* keyboard input needs to be directed to the NxConsole character driver.
|
||||||
|
* This method can be used to enable (or disable) redirection of NX
|
||||||
|
* keyboard input from the window widgets to the NxConsole
|
||||||
|
*
|
||||||
|
* @param handle. The NXCONSOLE handle. If non-NULL, NX keyboard
|
||||||
|
* input will be directed to the NxConsole driver using this
|
||||||
|
* handle; If NULL (the default), NX keyboard input will be
|
||||||
|
* directed to the widgets within the window.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef CONFIG_NXCONSOLE_NXKBDIN
|
||||||
|
inline void redirectNxConsole(NXCONSOLE handle)
|
||||||
|
{
|
||||||
|
setNxConsole(handle);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set an individual pixel in the window with the specified color.
|
* Set an individual pixel in the window with the specified color.
|
||||||
*
|
*
|
||||||
|
@ -48,7 +48,10 @@
|
|||||||
|
|
||||||
#include <nuttx/nx/nxglib.h>
|
#include <nuttx/nx/nxglib.h>
|
||||||
#include <nuttx/nx/nx.h>
|
#include <nuttx/nx/nx.h>
|
||||||
#include <nuttx/nx/nxtk.h>
|
|
||||||
|
#ifdef CONFIG_NXCONSOLE_NXKBDIN
|
||||||
|
# include <nuttx/nx/nxconsole.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "crect.hxx"
|
#include "crect.hxx"
|
||||||
|
|
||||||
@ -88,7 +91,11 @@ namespace NXWidgets
|
|||||||
class CCallback
|
class CCallback
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
struct nx_callback_s m_callbacks; /**< C-callable vtable of callback function pointers */
|
CWidgetControl *m_widgetControl; /**< The widget control instance for this window */
|
||||||
|
struct nx_callback_s m_callbacks; /**< C-callable vtable of callback function pointers */
|
||||||
|
#ifdef CONFIG_NXCONSOLE_NXKBDIN
|
||||||
|
NXCONSOLE m_nxconsole; /**< The NxConsole handle for redirection of keyboard input */
|
||||||
|
#endif
|
||||||
|
|
||||||
// Methods in the callback vtable
|
// Methods in the callback vtable
|
||||||
|
|
||||||
@ -235,6 +242,27 @@ namespace NXWidgets
|
|||||||
{
|
{
|
||||||
return &m_callbacks;
|
return &m_callbacks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* By default, NX keyboard input is given to the various widgets
|
||||||
|
* residing in the window. But NxConsole is a different usage model;
|
||||||
|
* In this case, keyboard input needs to be directed to the NxConsole
|
||||||
|
* character driver. This method can be used to enable (or disable)
|
||||||
|
* redirection of NX keyboard input from the window widgets to the
|
||||||
|
* NxConsole
|
||||||
|
*
|
||||||
|
* @param handle. The NXCONSOLE handle. If non-NULL, NX keyboard
|
||||||
|
* input will be directed to the NxConsole driver using this
|
||||||
|
* handle; If NULL (the default), NX keyboard input will be
|
||||||
|
* directed to the widgets within the window.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef CONFIG_NXCONSOLE_NXKBDIN
|
||||||
|
inline void setNxConsole(NXCONSOLE handle)
|
||||||
|
{
|
||||||
|
m_nxconsole = handle;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,6 +227,27 @@ namespace NXWidgets
|
|||||||
|
|
||||||
bool lower(void);
|
bool lower(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Each window implementation also inherits from CCallback. CCallback,
|
||||||
|
* by default, forwards NX keyboard input to the various widgets residing
|
||||||
|
* in the window. But NxConsole is a different usage model; In this case,
|
||||||
|
* keyboard input needs to be directed to the NxConsole character driver.
|
||||||
|
* This method can be used to enable (or disable) redirection of NX
|
||||||
|
* keyboard input from the window widgets to the NxConsole
|
||||||
|
*
|
||||||
|
* @param handle. The NXCONSOLE handle. If non-NULL, NX keyboard
|
||||||
|
* input will be directed to the NxConsole driver using this
|
||||||
|
* handle; If NULL (the default), NX keyboard input will be
|
||||||
|
* directed to the widgets within the window.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef CONFIG_NXCONSOLE_NXKBDIN
|
||||||
|
inline void redirectNxConsole(NXCONSOLE handle)
|
||||||
|
{
|
||||||
|
setNxConsole(handle);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set an individual pixel in the window with the specified color.
|
* Set an individual pixel in the window with the specified color.
|
||||||
*
|
*
|
||||||
|
@ -196,6 +196,27 @@ namespace NXWidgets
|
|||||||
|
|
||||||
bool lower(void);
|
bool lower(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Each window implementation also inherits from CCallback. CCallback,
|
||||||
|
* by default, forwards NX keyboard input to the various widgets residing
|
||||||
|
* in the window. But NxConsole is a different usage model; In this case,
|
||||||
|
* keyboard input needs to be directed to the NxConsole character driver.
|
||||||
|
* This method can be used to enable (or disable) redirection of NX
|
||||||
|
* keyboard input from the window widgets to the NxConsole
|
||||||
|
*
|
||||||
|
* @param handle. The NXCONSOLE handle. If non-NULL, NX keyboard
|
||||||
|
* input will be directed to the NxConsole driver using this
|
||||||
|
* handle; If NULL (the default), NX keyboard input will be
|
||||||
|
* directed to the widgets within the window.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef CONFIG_NXCONSOLE_NXKBDIN
|
||||||
|
inline void redirectNxConsole(NXCONSOLE handle)
|
||||||
|
{
|
||||||
|
setNxConsole(handle);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set an individual pixel in the toolbar with the specified color.
|
* Set an individual pixel in the toolbar with the specified color.
|
||||||
*
|
*
|
||||||
|
@ -200,6 +200,27 @@ namespace NXWidgets
|
|||||||
|
|
||||||
bool lower(void);
|
bool lower(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Each window implementation also inherits from CCallback. CCallback,
|
||||||
|
* by default, forwards NX keyboard input to the various widgets residing
|
||||||
|
* in the window. But NxConsole is a different usage model; In this case,
|
||||||
|
* keyboard input needs to be directed to the NxConsole character driver.
|
||||||
|
* This method can be used to enable (or disable) redirection of NX
|
||||||
|
* keyboard input from the window widgets to the NxConsole
|
||||||
|
*
|
||||||
|
* @param handle. The NXCONSOLE handle. If non-NULL, NX keyboard
|
||||||
|
* input will be directed to the NxConsole driver using this
|
||||||
|
* handle; If NULL (the default), NX keyboard input will be
|
||||||
|
* directed to the widgets within the window.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef CONFIG_NXCONSOLE_NXKBDIN
|
||||||
|
inline void redirectNxConsole(NXCONSOLE handle)
|
||||||
|
{
|
||||||
|
setNxConsole(handle);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set an individual pixel in the window with the specified color.
|
* Set an individual pixel in the window with the specified color.
|
||||||
*
|
*
|
||||||
|
@ -47,6 +47,10 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#ifdef CONFIG_NXCONSOLE_NXKBDIN
|
||||||
|
# include <nuttx/nx/nxconsole.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-Processor Definitions
|
* Pre-Processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -168,6 +172,24 @@ namespace NXWidgets
|
|||||||
|
|
||||||
virtual bool lower(void) = 0;
|
virtual bool lower(void) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Each window implementation also inherits from CCallback. CCallback,
|
||||||
|
* by default, forwards NX keyboard input to the various widgets residing
|
||||||
|
* in the window. But NxConsole is a different usage model; In this case,
|
||||||
|
* keyboard input needs to be directed to the NxConsole character driver.
|
||||||
|
* This method can be used to enable (or disable) redirection of NX
|
||||||
|
* keyboard input from the window widgets to the NxConsole
|
||||||
|
*
|
||||||
|
* @param handle. The NXCONSOLE handle. If non-NULL, NX keyboard
|
||||||
|
* input will be directed to the NxConsole driver using this
|
||||||
|
* handle; If NULL (the default), NX keyboard input will be
|
||||||
|
* directed to the widgets within the window.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef CONFIG_NXCONSOLE_NXKBDIN
|
||||||
|
virtual void redirectNxConsole(NXCONSOLE handle) = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set an individual pixel in the window with the specified color.
|
* Set an individual pixel in the window with the specified color.
|
||||||
*
|
*
|
||||||
|
@ -184,6 +184,14 @@
|
|||||||
# error "Only a single color plane is supported (CONFIG_NX_NPLANES)"
|
# error "Only a single color plane is supported (CONFIG_NX_NPLANES)"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* NxConsole checks. This just simplifies the conditional compilation by
|
||||||
|
* reducing the AND of these three conditions to a single condition.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if !defined(CONFIG_NX_KBD) || !defined(CONFIG_NXCONSOLE)
|
||||||
|
# undef CONFIG_NXCONSOLE_NXKBDIN
|
||||||
|
#endif
|
||||||
|
|
||||||
/* NX Server/Device Configuration *******************************************/
|
/* NX Server/Device Configuration *******************************************/
|
||||||
/**
|
/**
|
||||||
* LCD device number (in case there are more than one LCDs connected)
|
* LCD device number (in case there are more than one LCDs connected)
|
||||||
|
@ -101,7 +101,8 @@ bool CBgWindow::open(void)
|
|||||||
|
|
||||||
// Request the background the window
|
// Request the background the window
|
||||||
|
|
||||||
int ret = nx_requestbkgd(m_hNxServer, vtable, (FAR void *)m_widgetControl);
|
int ret = nx_requestbkgd(m_hNxServer, vtable,
|
||||||
|
(FAR void *)static_cast<CCallback*>(this));
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -44,6 +44,10 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
#ifdef CONFIG_NXCONSOLE_NXKBDIN
|
||||||
|
# include <nuttx/nx/nxconsole.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "cwidgetcontrol.hxx"
|
#include "cwidgetcontrol.hxx"
|
||||||
#include "ccallback.hxx"
|
#include "ccallback.hxx"
|
||||||
|
|
||||||
@ -65,6 +69,10 @@ using namespace NXWidgets;
|
|||||||
|
|
||||||
CCallback::CCallback(CWidgetControl *widgetControl)
|
CCallback::CCallback(CWidgetControl *widgetControl)
|
||||||
{
|
{
|
||||||
|
// Save the widgetControl
|
||||||
|
|
||||||
|
m_widgetControl = widgetControl;
|
||||||
|
|
||||||
// Initialize the callback vtable
|
// Initialize the callback vtable
|
||||||
|
|
||||||
m_callbacks.redraw = redraw;
|
m_callbacks.redraw = redraw;
|
||||||
@ -76,6 +84,12 @@ CCallback::CCallback(CWidgetControl *widgetControl)
|
|||||||
m_callbacks.kbdin = newKeyboardEvent;
|
m_callbacks.kbdin = newKeyboardEvent;
|
||||||
#endif
|
#endif
|
||||||
m_callbacks.blocked = windowBlocked;
|
m_callbacks.blocked = windowBlocked;
|
||||||
|
|
||||||
|
// Keyboard input is initially direct to the widgets within the window
|
||||||
|
|
||||||
|
#ifdef CONFIG_NXCONSOLE_NXKBDIN
|
||||||
|
m_nxconsole = (NXCONSOLE)0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -98,13 +112,13 @@ void CCallback::redraw(NXHANDLE hwnd,
|
|||||||
rect->pt1.x, rect->pt1.y, rect->pt2.x, rect->pt2.y,
|
rect->pt1.x, rect->pt1.y, rect->pt2.x, rect->pt2.y,
|
||||||
bMore ? "true" : "false");
|
bMore ? "true" : "false");
|
||||||
|
|
||||||
// The argument must be the CWidgetControl instance
|
// The argument must be the CCallback instance
|
||||||
|
|
||||||
CWidgetControl *This = (CWidgetControl *)arg;
|
CCallback *This = (CCallback *)arg;
|
||||||
|
|
||||||
// Just forward the callback to the CWidgetControl::redrawEvent method
|
// Just forward the callback to the CWidgetControl::redrawEvent method
|
||||||
|
|
||||||
This->redrawEvent(rect, bMore);
|
This->m_widgetControl->redrawEvent(rect, bMore);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -132,13 +146,13 @@ void CCallback::position(NXHANDLE hwnd,
|
|||||||
arg);
|
arg);
|
||||||
|
|
||||||
|
|
||||||
// The argument must be the CWidgetControl instance
|
// The argument must be the CCallback instance
|
||||||
|
|
||||||
CWidgetControl *This = (CWidgetControl *)arg;
|
CCallback *This = (CCallback *)arg;
|
||||||
|
|
||||||
// Just forward the callback to the CWidgetControl::geometry method
|
// Just forward the callback to the CWidgetControl::geometry method
|
||||||
|
|
||||||
This->geometryEvent(hwnd, size, pos, bounds);
|
This->m_widgetControl->geometryEvent(hwnd, size, pos, bounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -160,13 +174,13 @@ void CCallback::newMouseEvent(NXHANDLE hwnd,
|
|||||||
gvdbg("hwnd=%p pos=(%d,%d) buttons=%02x arg=%p\n",
|
gvdbg("hwnd=%p pos=(%d,%d) buttons=%02x arg=%p\n",
|
||||||
hwnd, pos->x, pos->y, buttons, arg);
|
hwnd, pos->x, pos->y, buttons, arg);
|
||||||
|
|
||||||
// The argument must be the CWidgetControl instance
|
// The argument must be the CCallback instance
|
||||||
|
|
||||||
CWidgetControl *This = (CWidgetControl *)arg;
|
CCallback *This = (CCallback *)arg;
|
||||||
|
|
||||||
// Just forward the callback to the CWidgetControl::newMouseEvent method
|
// Just forward the callback to the CWidgetControl::newMouseEvent method
|
||||||
|
|
||||||
This->newMouseEvent(pos, buttons);
|
This->m_widgetControl->newMouseEvent(pos, buttons);
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_NX_MOUSE */
|
#endif /* CONFIG_NX_MOUSE */
|
||||||
|
|
||||||
@ -188,13 +202,28 @@ void CCallback::newKeyboardEvent(NXHANDLE hwnd, uint8_t nCh,
|
|||||||
{
|
{
|
||||||
gvdbg("hwnd=%p nCh=%d arg=%p\n", hwnd, nCh, arg);
|
gvdbg("hwnd=%p nCh=%d arg=%p\n", hwnd, nCh, arg);
|
||||||
|
|
||||||
// The argument must be the CWidgetControl instance
|
// The argument must be the CCallback instance
|
||||||
|
|
||||||
CWidgetControl *This = (CWidgetControl *)arg;
|
CCallback *This = (CCallback *)arg;
|
||||||
|
|
||||||
// Just forward the callback to the CWidgetControl::newKeyboardEvent method
|
// Is NX keyboard input being directed to the widgets within the window
|
||||||
|
// (default) OR is NX keyboard input being re-directed to an NxConsole
|
||||||
|
// driver?
|
||||||
|
|
||||||
This->newKeyboardEvent(nCh, str);
|
#ifdef CONFIG_NXCONSOLE_NXKBDIN
|
||||||
|
if (This->m_nxconsole)
|
||||||
|
{
|
||||||
|
// Keyboard input is going to an NxConsole
|
||||||
|
|
||||||
|
nxcon_kbdin(This->m_nxconsole, str, nCh);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
// Just forward the callback to the CWidgetControl::newKeyboardEvent method
|
||||||
|
|
||||||
|
This->m_widgetControl->newKeyboardEvent(nCh, str);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -221,13 +250,13 @@ void CCallback::windowBlocked(NXWINDOW hwnd, FAR void *arg1, FAR void *arg2)
|
|||||||
{
|
{
|
||||||
gvdbg("hwnd=%p arg1=%p arg2=%p\n", hwnd, arg1, arg2);
|
gvdbg("hwnd=%p arg1=%p arg2=%p\n", hwnd, arg1, arg2);
|
||||||
|
|
||||||
// The first argument must be the CWidgetControl instance
|
// The first argument must be the CCallback instance
|
||||||
|
|
||||||
CWidgetControl *This = (CWidgetControl *)arg1;
|
CCallback *This = (CCallback *)arg1;
|
||||||
|
|
||||||
// Just forward the callback to the CWidgetControl::windowBlocked method
|
// Just forward the callback to the CWidgetControl::windowBlocked method
|
||||||
|
|
||||||
This->windowBlocked(arg2);
|
This->m_widgetControl->windowBlocked(arg2);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -118,7 +118,8 @@ bool CNxTkWindow::open(void)
|
|||||||
|
|
||||||
// Create the window
|
// Create the window
|
||||||
|
|
||||||
m_hNxTkWindow = nxtk_openwindow(m_hNxServer, vtable, (FAR void *)m_widgetControl);
|
m_hNxTkWindow = nxtk_openwindow(m_hNxServer, vtable,
|
||||||
|
(FAR void *)static_cast<CCallback*>(this));
|
||||||
return m_hNxTkWindow != NULL;
|
return m_hNxTkWindow != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ bool CNxToolbar::open(void)
|
|||||||
// Create the toolbar
|
// Create the toolbar
|
||||||
|
|
||||||
int ret = nxtk_opentoolbar(m_hNxTkWindow, m_height, vtable,
|
int ret = nxtk_opentoolbar(m_hNxTkWindow, m_height, vtable,
|
||||||
(FAR void *)m_widgetControl);
|
(FAR void *)static_cast<CCallback*>(this));
|
||||||
return ret == OK;
|
return ret == OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,7 +99,8 @@ bool CNxWindow::open(void)
|
|||||||
|
|
||||||
// Create the window
|
// Create the window
|
||||||
|
|
||||||
m_hNxWindow = nx_openwindow(m_hNxServer, vtable, (FAR void *)m_widgetControl);
|
m_hNxWindow = nx_openwindow(m_hNxServer, vtable,
|
||||||
|
(FAR void *)static_cast<CCallback*>(this));
|
||||||
return m_hNxWindow != NULL;
|
return m_hNxWindow != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,6 +36,11 @@
|
|||||||
/********************************************************************************************
|
/********************************************************************************************
|
||||||
* Included Files
|
* Included Files
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
#include <nuttx/config.h> // REMOVE ME
|
||||||
|
#define CONFIG_DEBUG 1 // REMOVE ME
|
||||||
|
#define CONFIG_DEBUG_VERBOSE 1 // REMOVE ME
|
||||||
|
#define CONFIG_DEBUG_GRAPHICS 1 // REMOVE ME
|
||||||
|
#include <debug.h> // REMOVE ME
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
@ -202,6 +207,7 @@ bool CNxConsole::run(void)
|
|||||||
|
|
||||||
if (m_pid >= 0 || m_nxcon != 0)
|
if (m_pid >= 0 || m_nxcon != 0)
|
||||||
{
|
{
|
||||||
|
gdbg("ERROR: All ready running or connected\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,6 +217,7 @@ bool CNxConsole::run(void)
|
|||||||
{
|
{
|
||||||
// This might fail if a signal is received while we are waiting.
|
// This might fail if a signal is received while we are waiting.
|
||||||
|
|
||||||
|
gdbg("ERROR: Failed to get semaphore\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,6 +259,7 @@ bool CNxConsole::run(void)
|
|||||||
bool result = true;
|
bool result = true;
|
||||||
if (m_pid < 0)
|
if (m_pid < 0)
|
||||||
{
|
{
|
||||||
|
gdbg("ERROR: Failed to create the NxConsole task\n");
|
||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -267,14 +275,22 @@ bool CNxConsole::run(void)
|
|||||||
|
|
||||||
if (ret == OK && g_nxconvars.result)
|
if (ret == OK && g_nxconvars.result)
|
||||||
{
|
{
|
||||||
|
// Re-direct NX keyboard input to the new NxConsole driver
|
||||||
|
|
||||||
|
DEBUGASSERT(g_nxconvars.nxcon != 0);
|
||||||
|
#ifdef CONFIG_NXCONSOLE_NXKBDIN
|
||||||
|
window->redirectNxConsole(g_nxconvars.nxcon);
|
||||||
|
#endif
|
||||||
// Save the handle to use in the stop method
|
// Save the handle to use in the stop method
|
||||||
|
|
||||||
m_nxcon = g_nxconvars.nxcon;
|
m_nxcon = g_nxconvars.nxcon;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Stop the application
|
// sem_timedwait failed OR the NxConsole task reported a
|
||||||
|
// failure. Stop the application
|
||||||
|
|
||||||
|
gdbg("ERROR: Failed start the NxConsole task\n");
|
||||||
stop();
|
stop();
|
||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
@ -313,6 +329,15 @@ void CNxConsole::stop(void)
|
|||||||
|
|
||||||
if (m_nxcon)
|
if (m_nxcon)
|
||||||
{
|
{
|
||||||
|
// Re-store NX keyboard input routing
|
||||||
|
|
||||||
|
#ifdef CONFIG_NXCONSOLE_NXKBDIN
|
||||||
|
NXWidgets::INxWindow *window = m_window->getWindow();
|
||||||
|
window->redirectNxConsole((NXCONSOLE)0);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Unregister the NxConsole driver
|
||||||
|
|
||||||
nxcon_unregister(m_nxcon);
|
nxcon_unregister(m_nxcon);
|
||||||
m_nxcon = 0;
|
m_nxcon = 0;
|
||||||
}
|
}
|
||||||
@ -405,6 +430,7 @@ int CNxConsole::nxconsole(int argc, char *argv[])
|
|||||||
|
|
||||||
if (on_exit(exitHandler, g_nxconvars.console) != 0)
|
if (on_exit(exitHandler, g_nxconvars.console) != 0)
|
||||||
{
|
{
|
||||||
|
gdbg("ERROR: on_exit failed\n");
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -414,6 +440,7 @@ int CNxConsole::nxconsole(int argc, char *argv[])
|
|||||||
g_nxconvars.minor);
|
g_nxconvars.minor);
|
||||||
if (!g_nxconvars.nxcon)
|
if (!g_nxconvars.nxcon)
|
||||||
{
|
{
|
||||||
|
gdbg("ERROR: Failed register the console device\n");
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -428,9 +455,14 @@ int CNxConsole::nxconsole(int argc, char *argv[])
|
|||||||
|
|
||||||
// Open the NxConsole driver
|
// Open the NxConsole driver
|
||||||
|
|
||||||
|
#ifdef CONFIG_NXCONSOLE_NXKBDIN
|
||||||
|
fd = open(devname, O_RDWR);
|
||||||
|
#else
|
||||||
fd = open(devname, O_WRONLY);
|
fd = open(devname, O_WRONLY);
|
||||||
|
#endif
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
{
|
{
|
||||||
|
gdbg("ERROR: Failed open the console device\n");
|
||||||
goto errout_with_nxcon;
|
goto errout_with_nxcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -442,12 +474,21 @@ int CNxConsole::nxconsole(int argc, char *argv[])
|
|||||||
(void)std::fflush(stdout);
|
(void)std::fflush(stdout);
|
||||||
(void)std::fflush(stderr);
|
(void)std::fflush(stderr);
|
||||||
|
|
||||||
|
#ifdef CONFIG_NXCONSOLE_NXKBDIN
|
||||||
|
(void)std::fclose(stdin);
|
||||||
|
#endif
|
||||||
(void)std::fclose(stdout);
|
(void)std::fclose(stdout);
|
||||||
(void)std::fclose(stderr);
|
(void)std::fclose(stderr);
|
||||||
|
|
||||||
|
#ifdef CONFIG_NXCONSOLE_NXKBDIN
|
||||||
|
(void)std::dup2(fd, 0);
|
||||||
|
#endif
|
||||||
(void)std::dup2(fd, 1);
|
(void)std::dup2(fd, 1);
|
||||||
(void)std::dup2(fd, 2);
|
(void)std::dup2(fd, 2);
|
||||||
|
|
||||||
|
#ifdef CONFIG_NXCONSOLE_NXKBDIN
|
||||||
|
(void)std::fdopen(0, "r");
|
||||||
|
#endif
|
||||||
(void)std::fdopen(1, "w");
|
(void)std::fdopen(1, "w");
|
||||||
(void)std::fdopen(2, "w");
|
(void)std::fdopen(2, "w");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user