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

#include <ctouchscreen.hxx>

Public Member Functions

 CTouchscreen (NXWidgets::CNxServer *server, struct nxgl_size_s *windowSize)
 
 ~CTouchscreen (void)
 
bool start (void)
 
void setEnabled (bool enable)
 
bool isCalibrated (void) const
 
void setCalibrationData (const struct SCalibrationData &caldata)
 
bool getCalibrationData (struct SCalibrationData &caldata) const
 
bool waitRawTouchData (struct touch_sample_s *touch)
 

Private Types

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

Private Member Functions

void handleMouseInput (struct touch_sample_s *sample)
 

Static Private Member Functions

static FAR void * listener (FAR void *arg)
 

Private Attributes

NXWidgets::CNxServerm_server
 
int m_touchFd
 
sem_t m_waitSem
 
pthread_t m_thread
 
enum EListenerState m_state
 
volatile bool m_enabled
 
volatile bool m_capture
 
volatile bool m_calibrated
 
struct nxgl_size_s m_windowSize
 
struct SCalibrationData m_calibData
 
struct touch_sample_s m_sample
 
struct touch_sample_s * m_touch
 

Detailed Description

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

Definition at line 68 of file ctouchscreen.hxx.

Member Enumeration Documentation

◆ EListenerState

enum NxWM::CTouchscreen::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 ctouchscreen.hxx.

Constructor & Destructor Documentation

◆ CTouchscreen()

CTouchscreen::CTouchscreen ( NXWidgets::CNxServer server,
struct nxgl_size_s *  windowSize 
)

CTouchscreen Constructor

Parameters
server.An instance of the NX server. This will be needed for injecting mouse data.
windowSize.The size of the physical window in pixels. This is needed for touchscreen scaling.

Definition at line 97 of file ctouchscreen.cxx.

◆ ~CTouchscreen()

CTouchscreen::~CTouchscreen ( void  )

CTouchscreen Destructor

Definition at line 123 of file ctouchscreen.cxx.

Member Function Documentation

◆ getCalibrationData()

bool NxWM::CTouchscreen::getCalibrationData ( struct SCalibrationData caldata) const
inline

Recover the calibration data so that it can be saved to non-volatile storage.

Parameters
data.A reference to the touchscreen data.
Returns
True if calibration data was successfully returned.

Definition at line 198 of file ctouchscreen.hxx.

◆ handleMouseInput()

void CTouchscreen::handleMouseInput ( struct touch_sample_s *  sample)
private

Inject touchscreen data into NX as mouse intput

Parameters
sample.The buffer where data was collected.

Inject touchscreen data into NX as mouse intput

Definition at line 389 of file ctouchscreen.cxx.

◆ isCalibrated()

bool NxWM::CTouchscreen::isCalibrated ( void  ) const
inline

Is the touchscreen calibrated?

Returns
True if the touchscreen has been calibrated.

Definition at line 175 of file ctouchscreen.hxx.

◆ listener()

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

The touchscreen listener thread. This is the entry point of a thread that listeners for and dispatches touchscreens events to the NX server.

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

The touchscreen listener thread. This is the entry point of a thread that listeners for and dispatches touchscreen events to the NX server.

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

Definition at line 277 of file ctouchscreen.cxx.

◆ setCalibrationData()

void CTouchscreen::setCalibrationData ( const struct SCalibrationData caldata)

Provide touchscreen calibration data. If calibration data is received (and the touchscreen is enabled), then received touchscreen data will be scaled using the calibration data and forward to the NX layer which dispatches the touchscreen events in window-relative positions to the correct NX window.

Parameters
data.A reference to the touchscreen data.

Definition at line 209 of file ctouchscreen.cxx.

◆ setEnabled()

void NxWM::CTouchscreen::setEnabled ( bool  enable)
inline

Enable/disable touchscreen data processing. When enabled, touchscreen events are calibrated and forwarded to the NX layer which dispatches the touchscreen events in window-relative positions to the correct NX window.

When disabled, touchscreen data is not forwarded to NX, but is instead captured and made available for touchscreen calibration. The touchscreen driver is initially disabled and must be specifically enabled be begin normal processing. Normal processing also requires calibration data (see method setCalibrationData)

Parameters
capture.True enables capture mode; false disables.

Definition at line 161 of file ctouchscreen.hxx.

◆ start()

bool CTouchscreen::start ( void  )

Start the touchscreen listener thread.

Returns
True if the touchscreen listener thread was correctly started.

Definition at line 153 of file ctouchscreen.cxx.

◆ waitRawTouchData()

bool CTouchscreen::waitRawTouchData ( struct touch_sample_s *  touch)

Capture raw driver data. This method will capture mode one raw touchscreen input. The normal use of this method is for touchscreen calibration.

This function is not re-entrant: There may be only one thread waiting for raw touchscreen data.

Returns
True if the raw touchscreen data was sucessfully obtained

Capture raw driver data. This method will capture mode one raw touchscreen input. The normal use of this method is for touchscreen calibration.

This function is not re-entrant: There may be only one thread waiting for raw touchscreen data.

Returns
True if the raw touchscreen data was successfully obtained

Definition at line 236 of file ctouchscreen.cxx.

Member Data Documentation

◆ m_calibData

struct SCalibrationData NxWM::CTouchscreen::m_calibData
private

Calibration data

Definition at line 98 of file ctouchscreen.hxx.

◆ m_calibrated

volatile bool NxWM::CTouchscreen::m_calibrated
private

True: If have calibration data

Definition at line 96 of file ctouchscreen.hxx.

◆ m_capture

volatile bool NxWM::CTouchscreen::m_capture
private

True: There is a thread waiting for raw touch data

Definition at line 95 of file ctouchscreen.hxx.

◆ m_enabled

volatile bool NxWM::CTouchscreen::m_enabled
private

True: Normal touchscreen processing

Definition at line 94 of file ctouchscreen.hxx.

◆ m_sample

struct touch_sample_s NxWM::CTouchscreen::m_sample
private

In normal mode, touch data is collected here

Definition at line 99 of file ctouchscreen.hxx.

◆ m_server

NXWidgets::CNxServer* NxWM::CTouchscreen::m_server
private

CTouchscreen state dataThe current NX server

Definition at line 89 of file ctouchscreen.hxx.

◆ m_state

enum EListenerState NxWM::CTouchscreen::m_state
private

The state of the listener thread

Definition at line 93 of file ctouchscreen.hxx.

◆ m_thread

pthread_t NxWM::CTouchscreen::m_thread
private

The listener thread ID

Definition at line 92 of file ctouchscreen.hxx.

◆ m_touch

struct touch_sample_s* NxWM::CTouchscreen::m_touch
private

Points to the current touch data buffer

Definition at line 100 of file ctouchscreen.hxx.

◆ m_touchFd

int NxWM::CTouchscreen::m_touchFd
private

File descriptor of the opened touchscreen device

Definition at line 90 of file ctouchscreen.hxx.

◆ m_waitSem

sem_t NxWM::CTouchscreen::m_waitSem
private

Semaphore the supports waits for touchscreen data

Definition at line 91 of file ctouchscreen.hxx.

◆ m_windowSize

struct nxgl_size_s NxWM::CTouchscreen::m_windowSize
private

The size of the physical display

Definition at line 97 of file ctouchscreen.hxx.


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