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:
patacongo 2012-05-20 18:56:14 +00:00
parent d2a564f8c8
commit 2ee17af708
6 changed files with 28 additions and 15 deletions

View file

@ -40,7 +40,7 @@ NXCON_CSRCS += nxcon_vt100.c nxcon_unregister.c nxtk_register.c
NXCON_CSRCS += nxtool_register.c NXCON_CSRCS += nxtool_register.c
ifeq ($(CONFIG_NXCONSOLE_NXKBDIN),y) ifeq ($(CONFIG_NXCONSOLE_NXKBDIN),y)
NXCON_CSRCS += nxcon_kbdin.c NXCON_CSRCS += nxcon_kbdin.c
endif endif
ifeq ($(CONFIG_DEBUG),y) ifeq ($(CONFIG_DEBUG),y)

View file

@ -128,7 +128,7 @@ static int nxcon_open(FAR struct file *filep)
#ifndef CONFIG_NXCONSOLE_NXKBDIN #ifndef CONFIG_NXCONSOLE_NXKBDIN
if ((filep->f_oflags & O_RDOK) != 0) if ((filep->f_oflags & O_RDOK) != 0)
{ {
gdbg("Attempted open with read access\n"); gdbg("ERROR: Attempted open with read access\n");
return -EACCES; return -EACCES;
} }
#endif #endif

View file

@ -144,20 +144,20 @@ struct nxcon_state_s
#ifdef CONFIG_DEBUG #ifdef CONFIG_DEBUG
pid_t holder; /* Deadlock avoidance */ pid_t holder; /* Deadlock avoidance */
#endif #endif
uint8_t minor; /* Device minor number */
/* Text output support */ /* Text output support */
struct nxgl_point_s fpos; /* Next display position */
uint16_t maxchars; /* Size of the bm[] array */
uint16_t nchars; /* Number of chars in the bm[] array */
uint8_t minor; /* Device minor number */
uint8_t fheight; /* Max height of a font in pixels */ uint8_t fheight; /* Max height of a font in pixels */
uint8_t fwidth; /* Max width of a font in pixels */ uint8_t fwidth; /* Max width of a font in pixels */
uint8_t spwidth; /* The width of a space */ uint8_t spwidth; /* The width of a space */
uint8_t maxglyphs; /* Size of the glyph[] array */ uint8_t maxglyphs; /* Size of the glyph[] array */
uint16_t maxchars; /* Size of the bm[] array */
uint16_t nchars; /* Number of chars in the bm[] array */
struct nxgl_point_s fpos; /* Next display position */
/* VT100 escape sequence processing */ /* VT100 escape sequence processing */
char seq[VT100_MAX_SEQUENCE]; /* Buffered characters */ char seq[VT100_MAX_SEQUENCE]; /* Buffered characters */
@ -210,8 +210,8 @@ extern const struct file_operations g_nxcon_drvrops;
int nxcon_semwait(FAR struct nxcon_state_s *priv); int nxcon_semwait(FAR struct nxcon_state_s *priv);
int nxcon_sempost(FAR struct nxcon_state_s *priv); int nxcon_sempost(FAR struct nxcon_state_s *priv);
#else #else
# define nxcon_semwait(p) sem_wait(&p->exclsem); # define nxcon_semwait(p) sem_wait(&p->exclsem)
# define nxcon_sempost(p) sem_post(&p->exclsem); # define nxcon_sempost(p) sem_post(&p->exclsem)
#endif #endif
/* Common device registration */ /* Common device registration */

View file

@ -126,6 +126,7 @@ ssize_t nxcon_read(FAR struct file *filep, FAR char *buffer, size_t len)
ret = nxcon_semwait(priv); ret = nxcon_semwait(priv);
if (ret < 0) if (ret < 0)
{ {
gdbg("ERROR: nxcon_semwait failed\n");
return ret; return ret;
} }
@ -198,6 +199,8 @@ ssize_t nxcon_read(FAR struct file *filep, FAR char *buffer, size_t len)
int errval = errno; int errval = errno;
gdbg("ERROR: nxcon_semwait failed\n");
/* Were we awakened by a signal? Did we read anything before /* Were we awakened by a signal? Did we read anything before
* we received the signal? * we received the signal?
*/ */
@ -283,6 +286,7 @@ int nxcon_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup)
ret = nxcon_semwait(priv); ret = nxcon_semwait(priv);
if (ret < 0) if (ret < 0)
{ {
gdbg("ERROR: nxcon_semwait failed\n");
return ret; return ret;
} }
@ -310,6 +314,8 @@ int nxcon_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup)
if (i >= CONFIG_NXCONSOLE_NPOLLWAITERS) if (i >= CONFIG_NXCONSOLE_NPOLLWAITERS)
{ {
gdbg("ERROR: Too many poll waiters\n");
fds->priv = NULL; fds->priv = NULL;
ret = -EBUSY; ret = -EBUSY;
goto errout; goto errout;
@ -343,6 +349,8 @@ int nxcon_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup)
#ifdef CONFIG_DEBUG #ifdef CONFIG_DEBUG
if (!slot) if (!slot)
{ {
gdbg("ERROR: No slot\n");
ret = -EIO; ret = -EIO;
goto errout; goto errout;
} }
@ -361,7 +369,7 @@ errout:
#endif #endif
/**************************************************************************** /****************************************************************************
* Name: nxcon_kdbin * Name: nxcon_kbdin
* *
* Description: * Description:
* This function should be driven by the window kbdin callback function * This function should be driven by the window kbdin callback function
@ -386,13 +394,14 @@ errout:
* *
****************************************************************************/ ****************************************************************************/
void nxcon_kdbin(NXCONSOLE handle, FAR const uint8_t *buffer, uint8_t buflen) void nxcon_kbdin(NXCONSOLE handle, FAR const uint8_t *buffer, uint8_t buflen)
{ {
FAR struct nxcon_state_s *priv; FAR struct nxcon_state_s *priv;
ssize_t nwritten; ssize_t nwritten;
int nexthead; int nexthead;
char ch; char ch;
gvdbg("buflen=%d\n");
DEBUGASSERT(handle); DEBUGASSERT(handle);
/* Get the reference to the driver structure from the handle */ /* Get the reference to the driver structure from the handle */

View file

@ -99,6 +99,10 @@ FAR struct nxcon_state_s *
memcpy(&priv->wndo, wndo, sizeof( struct nxcon_window_s)); memcpy(&priv->wndo, wndo, sizeof( struct nxcon_window_s));
sem_init(&priv->exclsem, 0, 1); sem_init(&priv->exclsem, 0, 1);
#ifdef CONFIG_DEBUG
priv->holder = NO_HOLDER;
#endif
#ifdef CONFIG_NXCONSOLE_NXKBDIN #ifdef CONFIG_NXCONSOLE_NXKBDIN
sem_init(&priv->waitsem, 0, 0); sem_init(&priv->waitsem, 0, 0);
#endif #endif

View file

@ -100,7 +100,7 @@
* CONFIG_NXCONSOLE_NXKBDIN * CONFIG_NXCONSOLE_NXKBDIN
* Take input from the NX keyboard input callback. By default, keyboard * Take input from the NX keyboard input callback. By default, keyboard
* input is taken from stdin (/dev/console). If this option is set, then * input is taken from stdin (/dev/console). If this option is set, then
* the interface nxcon_kdbin() is enabled. That interface may be driven * the interface nxcon_kbdin() is enabled. That interface may be driven
* by window callback functions so that keyboard input *only* goes to the * by window callback functions so that keyboard input *only* goes to the
* top window. * top window.
* CONFIG_NXCONSOLE_KBDBUFSIZE * CONFIG_NXCONSOLE_KBDBUFSIZE
@ -328,7 +328,7 @@ EXTERN void nxcon_redraw(NXCONSOLE handle, FAR const struct nxgl_rect_s *rect,
bool more); bool more);
/**************************************************************************** /****************************************************************************
* Name: nxcon_kdbin * Name: nxcon_kbdin
* *
* Description: * Description:
* This function should be driven by the window kbdin callback function * This function should be driven by the window kbdin callback function
@ -354,7 +354,7 @@ EXTERN void nxcon_redraw(NXCONSOLE handle, FAR const struct nxgl_rect_s *rect,
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_NXCONSOLE_NXKBDIN #ifdef CONFIG_NXCONSOLE_NXKBDIN
EXTERN void nxcon_kdbin(NXCONSOLE handle, FAR const uint8_t *buffer, EXTERN void nxcon_kbdin(NXCONSOLE handle, FAR const uint8_t *buffer,
uint8_t buflen); uint8_t buflen);
#endif #endif