apps/graphics/twm4nx: Fix some errors found when enabling NX keyboard support. The most important being that the mouse and keyboard drivers need to be opened non-blocking.

This commit is contained in:
Gregory Nutt 2019-05-26 12:37:18 -06:00
parent 10ab7a56c9
commit 41765ebe81
4 changed files with 44 additions and 18 deletions

View File

@ -88,7 +88,7 @@ config TWM4NX_NOMOUSE
---help---
Normally you would never disable mouse input. That would make using
Twm4Nx impossible. However, this setting is sometimes useful for
debugging Twm4Nx bringup in a simpler environment (it is also used
debugging Twm4Nx bring-up in a simpler environment (it is also used
if VNC is selected)
choice
@ -110,6 +110,11 @@ config TWM4NX_MOUSE_DEVPATH
default "/dev/mouse0" if TWM4NX_MOUSE
default "/dev/input0" if TWM4NX_TOUCHSCREEN
config TWM4NX_KEYBOARD_DEVPATH
string "Patch to keyboard input device"
default "/dev/kbd0"
depends on !TWM4NX_NOKEYBOARD
choice
prompt "Twm4Nx Theme"
default TWM4NX_CLASSIC

View File

@ -159,7 +159,10 @@ Issues:
There are no near-term plans to address these compatibility issues.
Other issues/bugs
Other issues/bugs. All-in-all, I would say that Twm4Nx is maturing well
and is attaining stability. That being said, there are some issues and
untested functionality that should be addressed:
1. Icon drag movement includes logic to avoid collisions with other
icons and with the background image. That later is an issue. We
need to paint the image directly on the background without the
@ -172,7 +175,7 @@ Issues:
files
4. I have seen some odd behavior when many NxTerm windows have been
opened (around 15). Specifically, I see failures to start NSH in the
windows so they come up blank. All other behaviors are normal. Most
windows so they come up blank. All other behaviors seem normal. Most
likely, some NxTerm resource allocation is failing silently and leaving
things in an unusable. The board I am using has 128Mb of SDRAM so I
can't believe that memory is the limiting factor. These are, however,
@ -195,5 +198,7 @@ Issues:
needed with a mouse. Cursor images also change depending on the
state (like grabbing and dragging or resizing). There is also a
possibility of using auto-raise with a mouse as well. All of this
logic is in place, but none has been verifed.
logic is in place, but none has been verified.
8. I am suspecting that NxTerm processes are not being shut down
properly when an NxTerm window is closed, but I have not yet
investigated this.

View File

@ -69,7 +69,6 @@
#ifndef CONFIG_TWM4NX_NOKEYBOARD
# define KBD_INDEX 0
# define NINPUT_DEVICES 1
# ifndef CONFIG_TWM4NX_NOMOUSE
# define MOUSE_INDEX 1
# define NINPUT_DEVICES 2
@ -234,9 +233,9 @@ int CInput::keyboardOpen(void)
do
{
// Try to open the keyboard device
// Try to open the keyboard device non-blocking.
fd = std::open(CONFIG_TWM4NX_KEYBOARD_DEVPATH, O_RDONLY);
fd = std::open(CONFIG_TWM4NX_KEYBOARD_DEVPATH, O_RDONLY | O_NONBLOCK);
if (fd < 0)
{
int errcode = errno;
@ -310,9 +309,9 @@ inline int CInput::mouseOpen(void)
do
{
// Try to open the mouse device
// Try to open the mouse device non-blocking
fd = std::open(CONFIG_TWM4NX_MOUSE_DEVPATH, O_RDONLY);
fd = std::open(CONFIG_TWM4NX_MOUSE_DEVPATH, O_RDONLY | O_NONBLOCK);
if (fd < 0)
{
int errcode = errno;
@ -388,9 +387,17 @@ int CInput::keyboardInput(void)
int errcode = errno;
DEBUGASSERT(errcode > 0);
// EINTR is not really an error, it simply means that something is
// trying to get our attention. We need to check m_state to see
// if we were asked to terminate
// EAGAIN and EINTR are not really error. EAGAIN just indicates that
// there is nothing available to read now.
if (errcode == EAGAIN)
{
return OK;
}
// EINTR it simply means that something is trying to get our attention
// We need to check m_state to see if we were asked to terminate.
// Anything else is bad news
if (errcode != EINTR)
{
@ -579,9 +586,17 @@ int CInput::mouseInput(void)
int errcode = errno;
DEBUGASSERT(errcode > 0);
// EINTR is not really an error, it simply means that something is
// trying to get our attention. We need to check m_state to see
// if we were asked to terminate
// EAGAIN and EINTR are not really error. EAGAIN just indicates that
// there is nothing available to read now.
if (errcode == EAGAIN)
{
return OK;
}
// EINTR it simply means that something is trying to get our attention
// We need to check m_state to see if we were asked to terminate.
// Anything else is bad news
if (errcode != EINTR)
{
@ -786,7 +801,7 @@ int CInput::session(void)
#ifndef CONFIG_TWM4NX_NOKEYBOARD
pfd[KBD_INDEX].fd = m_kbdFd;
pfd[KBD_INDEX].events = POLLIN | POLLERR | POLLHUP;
pfd[KBD_INDEX]revents = 0;
pfd[KBD_INDEX].revents = 0;
#endif
#ifndef CONFIG_TWM4NX_NOMOUSE
pfd[MOUSE_INDEX].fd = m_mouseFd;

View File

@ -484,7 +484,8 @@
* CONFIG_TWM4NX_MOUSE - Input is from a mouse.
* CONFIG_TWM4NX_TOUSCREEN - Input is from a touchscreen.
* CONFIG_TWM4NX_MOUSE_DEVPATH - The full path to the mouse device.
* Default: "/dev/console"
* Default: "/dev/mouse0" if a mouse is being used; /dev/input0 is a
* touchscreen is being used.
* CONFIG_TWM4NX_MOUSE_USBHOST - Indicates the the mouse is attached via
* USB
* CONFIG_TWM4NX_MOUSE_BUFSIZE - The size of the mouse read data buffer.