NXWidgets  1.19
Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
NxWM::CKeyboard Class Reference

#include <ckeyboard.hxx>

Public Member Functions

 CKeyboard (NXWidgets::CNxServer *server)
 
 ~CKeyboard (void)
 
bool start (void)
 

Private Types

enum  EListenerState {
  LISTENER_NOTRUNNING = 0, LISTENER_STARTED, LISTENER_RUNNING, LISTENER_STOPREQUESTED,
  LISTENER_TERMINATED, LISTENER_FAILED
}
 

Private Member Functions

int open (void)
 
int session (void)
 

Static Private Member Functions

static FAR void * listener (FAR void *arg)
 

Private Attributes

NXWidgets::CNxServerm_server
 
int m_kbdFd
 
pthread_t m_thread
 
enum EListenerState m_state
 
sem_t m_waitSem
 

Detailed Description

The CKeyboard class provides the the calibration window and obtains callibration data.

Definition at line 68 of file ckeyboard.hxx.

Member Enumeration Documentation

◆ EListenerState

enum NxWM::CKeyboard::EListenerState
private

The state of the listener thread.

Enumerator
LISTENER_NOTRUNNING 

The listener thread has not yet been started

LISTENER_STARTED 

The listener thread has been started, but is not yet running

LISTENER_RUNNING 

The listener thread is running normally

LISTENER_STOPREQUESTED 

The listener thread has been requested to stop

LISTENER_TERMINATED 

The listener thread terminated normally

LISTENER_FAILED 

The listener thread terminated abnormally

Definition at line 75 of file ckeyboard.hxx.

Constructor & Destructor Documentation

◆ CKeyboard()

CKeyboard::CKeyboard ( NXWidgets::CNxServer server)

CKeyboard Constructor

Parameters
server.An instance of the NX server. This will be needed for injecting mouse data.

Definition at line 71 of file ckeyboard.cxx.

◆ ~CKeyboard()

CKeyboard::~CKeyboard ( void  )

CKeyboard Destructor

Definition at line 86 of file ckeyboard.cxx.

Member Function Documentation

◆ listener()

FAR void * CKeyboard::listener ( FAR void *  arg)
staticprivate

The keyboard listener thread. This is the entry point of a thread that listeners for and dispatches keyboard events to the NX server. It simply opens the keyboard device (using CKeyboard::open()) and executes the session (via CKeyboard::session()).

If an errors while reading from the keyboard device AND we are configured to use a USB keyboard, then this function will wait for the USB keyboard to be re-connected.

Parameters
arg.The CKeyboard 'this' pointer cast to a void*.
Returns
This function normally does not return but may return NULL on error conditions.

Definition at line 325 of file ckeyboard.cxx.

◆ open()

int CKeyboard::open ( void  )
inlineprivate

Open the keyboard device. Not very interesting for the case of standard device but much more interesting for a USB keyboard device that may disappear when the keyboard is disconnect but later reappear when the keyboard is reconnected. In this case, this function will not return until the keyboard device was successfully opened (or until an irrecoverable error occurs.

Opens the keyboard device specified by CONFIG_NXWM_KEYBOARD_DEVPATH.

Returns
On success, then method returns a valid file descriptor that can be used to redirect stdin. A negated errno value is returned if an irrecoverable error occurs.

Definition at line 174 of file ckeyboard.cxx.

◆ session()

int CKeyboard::session ( void  )
inlineprivate

This is the heart of the keyboard listener thread. It contains the actual logic that listeners for and dispatches keyboard events to the NX server.

Returns
If the session terminates gracefully (i.e., because >m_state is no longer equal to LISTENER_RUNNING, then method returns OK. A negated errno value is returned if an error occurs while reading from the keyboard device. A read error, depending upon the type of the error, may simply indicate that a USB keyboard was removed and we should wait for the keyboard to be connected.

This is the heart of the keyboard listener thread. It contains the actual logic that listeners for and dispatches keyboard events to the NX server.

Returns
If the session terminates gracefully (i.e., because >m_state is no longer equal to LISTENER_RUNNING), then method returns OK. A negated errno value is returned if an error occurs while reading from the keyboard device. A read error, depending upon the type of the error, may simply indicate that a USB keyboard was removed and we should wait for the keyboard to be connected.

Definition at line 247 of file ckeyboard.cxx.

◆ start()

bool CKeyboard::start ( void  )

Start the keyboard listener thread.

Returns
True if the keyboard listener thread was correctly started.

Definition at line 112 of file ckeyboard.cxx.

Member Data Documentation

◆ m_kbdFd

int NxWM::CKeyboard::m_kbdFd
private

File descriptor of the opened keyboard device

Definition at line 90 of file ckeyboard.hxx.

◆ m_server

NXWidgets::CNxServer* NxWM::CKeyboard::m_server
private

CKeyboard state dataThe current NX server

Definition at line 89 of file ckeyboard.hxx.

◆ m_state

enum EListenerState NxWM::CKeyboard::m_state
private

The state of the listener thread

Definition at line 92 of file ckeyboard.hxx.

◆ m_thread

pthread_t NxWM::CKeyboard::m_thread
private

The listener thread ID

Definition at line 91 of file ckeyboard.hxx.

◆ m_waitSem

sem_t NxWM::CKeyboard::m_waitSem
private

Used to synchronize with the listener thread

Definition at line 93 of file ckeyboard.hxx.


The documentation for this class was generated from the following files: