PebbleOS v4.47.0-1362-gd278268fe
Loading...
Searching...
No Matches
Touchscreen drivers

Interface for touchscreen drivers. More...

Data Structures

struct  pbl_touch_ops
 Touchscreen driver operations, called with the device lock held. More...
 
struct  pbl_touch_state
 Touchscreen runtime state. More...
 
struct  pbl_touch
 Touchscreen. More...
 

Macros

#define PBL_TOUCH_STATE_DEFINE(sym)
 Define the class state of a touchscreen.
 
#define PBL_TOUCH_INIT(sym, _name, _parent, _ops, ...)
 Initialize a struct pbl_touch.
 

Functions

void pbl_touch_lock (const struct pbl_touch *touch)
 Take the device lock.
 
void pbl_touch_unlock (const struct pbl_touch *touch)
 Release the device lock.
 
void pbl_touch_report (const struct pbl_touch *touch, bool down, uint16_t x, uint16_t y)
 Report a sample.
 
void pbl_touch_report_gesture (const struct pbl_touch *touch, uint16_t code, uint16_t x, uint16_t y)
 Report a gesture recognized by the controller.
 

Detailed Description

Interface for touchscreen drivers.

A driver embeds a struct pbl_touch in its instance, sets it up with PBL_TOUCH_STATE_DEFINE() and PBL_TOUCH_INIT(), implements the struct pbl_touch_ops the class calls, and reports with pbl_touch_report() and pbl_touch_report_gesture().


Data Structure Documentation

◆ pbl_touch_state

struct pbl_touch_state

Touchscreen runtime state.

Data Fields
struct pbl_touch_sample last Last sample reported.
struct pbl_mutex lock Device lock.
uint16_t users Users.

◆ pbl_touch

struct pbl_touch

Touchscreen.

Data Fields
struct pbl_device dev Device.
const struct pbl_touch_ops * ops Driver operations.
struct pbl_touch_props props Properties.
struct pbl_touch_state * state Runtime state.

Macro Definition Documentation

◆ PBL_TOUCH_INIT

#define PBL_TOUCH_INIT (   sym,
  _name,
  _parent,
  _ops,
  ... 
)
Value:
{ \
.dev = PBL_DEVICE_INIT_CLASS(sym, _name, pbl_touch_dev_init, _parent, &pbl_touch_class), \
.ops = (_ops), \
.state = &sym##_touch_state, \
.props = {__VA_ARGS__}, \
}
#define PBL_DEVICE_INIT_CLASS(sym, _name, _init, _parent, _cls)
Initializer for the struct pbl_device of device instance sym, in class _cls.
Definition device.h:153

Initialize a struct pbl_touch.

Parameters
symSymbol of the instance, as passed to PBL_TOUCH_STATE_DEFINE().
_nameDevice name.
_parentParent device.
_opsDriver operations.
...Properties, designated initializers of struct pbl_touch_props.

◆ PBL_TOUCH_STATE_DEFINE

#define PBL_TOUCH_STATE_DEFINE (   sym)
Value:
static struct pbl_touch_state sym##_touch_state = {.lock = PBL_MUTEX_INITIALIZER}
#define PBL_DEVICE_STATE_DEFINE(sym)
Define the runtime state of device instance sym.
Definition device.h:132
struct pbl_mutex lock
Device lock.
Definition driver.h:40
Touchscreen runtime state.
Definition driver.h:38
#define PBL_MUTEX_INITIALIZER
Static initializer for an unlocked mutex.
Definition mutex.h:50

Define the class state of a touchscreen.

Parameters
symSymbol of the instance.

Function Documentation

◆ pbl_touch_lock()

void pbl_touch_lock ( const struct pbl_touch *  touch)

Take the device lock.

Drivers take it around the hardware access of their interrupt bottom half.

Parameters
touchTouchscreen.

◆ pbl_touch_report()

void pbl_touch_report ( const struct pbl_touch *  touch,
bool  down,
uint16_t  x,
uint16_t  y 
)

Report a sample.

Called by the driver from thread context without the device lock held.

Parameters
touchTouchscreen.
downWhether there is a touch contact.
xX coordinate reported by the controller.
yY coordinate reported by the controller.

◆ pbl_touch_report_gesture()

void pbl_touch_report_gesture ( const struct pbl_touch *  touch,
uint16_t  code,
uint16_t  x,
uint16_t  y 
)

Report a gesture recognized by the controller.

Called by the driver from thread context without the device lock held.

Parameters
touchTouchscreen.
codePBL_INPUT_EV_GES code.
xX coordinate reported by the controller.
yY coordinate reported by the controller.

◆ pbl_touch_unlock()

void pbl_touch_unlock ( const struct pbl_touch *  touch)

Release the device lock.

Parameters
touchTouchscreen.