PebbleOS v4.47.0-512-g5285d4236
Loading...
Searching...
No Matches
Touchscreen

Touchscreen class. More...

Modules

 CST816
 Hynitron CST816 touch controller.
 
 FT6x36
 Touchscreen driver for the FocalTech FT6x36 family, such as the FT6236 and the FT6146.
 
 QEMU
 QEMU touchscreen, covering the display.
 
 SDL
 Touchscreen of a native build, driven by the mouse through SDL.
 

Data Structures

struct  pbl_touch_props
 Touchscreen properties, the devicetree touchscreen-* properties. More...
 
struct  pbl_touch_ops
 Touchscreen driver operations, called with the device lock held. More...
 
struct  pbl_touch_sample
 Last sample reported by a touchscreen. 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

static const struct pbl_touch_props * pbl_touch_get_props (const struct pbl_touch *touch)
 Get the properties of a touchscreen.
 
int pbl_touch_enable (const struct pbl_touch *touch)
 Take a reference on the touchscreen, powering it up on the first one.
 
int pbl_touch_disable (const struct pbl_touch *touch)
 Drop a reference taken with pbl_touch_enable(), powering the touchscreen down on the last one.
 
bool pbl_touch_is_enabled (const struct pbl_touch *touch)
 Check whether the touchscreen has users.
 
void pbl_touch_get_last (const struct pbl_touch *touch, struct pbl_touch_sample *sample)
 Get the last sample reported.
 
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.
 

Variables

const struct pbl_touch *const TOUCH
 The board's touchscreen.
 

Detailed Description

Touchscreen class.

A touchscreen is a struct pbl_touch device and an Input device: its driver reports samples (PBL_INPUT_BTN_TOUCH, PBL_INPUT_ABS_X and PBL_INPUT_ABS_Y) and the gestures the controller recognizes through pbl_touch_report() and pbl_touch_report_gesture(), and input listeners consume them.

The board describes the touchscreen with the devicetree touchscreen properties (struct pbl_touch_props): the class maps the controller coordinates to the display with them before reporting.

The touchscreen is powered while it has users, counted by pbl_touch_enable() and pbl_touch_disable(). Every call into the driver runs with the device lock held, a recursive mutex. Drivers report without it, so that listeners may enable or disable the touchscreen.

// ...
const struct pbl_touch *const TOUCH
The board's touchscreen.
int pbl_touch_enable(const struct pbl_touch *touch)
Take a reference on the touchscreen, powering it up on the first one.
int pbl_touch_disable(const struct pbl_touch *touch)
Drop a reference taken with pbl_touch_enable(), powering the touchscreen down on the last one.

Data Structure Documentation

◆ pbl_touch_props

struct pbl_touch_props

Touchscreen properties, the devicetree touchscreen-* properties.

Data Fields
bool inverted_x X axis is inverted, touchscreen-inverted-x.
bool inverted_y Y axis is inverted, touchscreen-inverted-y.
uint16_t size_x Number of X coordinates the controller reports, touchscreen-size-x.
uint16_t size_y Number of Y coordinates the controller reports, touchscreen-size-y.
bool swapped_x_y X and Y axes are swapped, after inversion, touchscreen-swapped-x-y.

◆ pbl_touch_sample

struct pbl_touch_sample

Last sample reported by a touchscreen.

Data Fields
bool down Touch contact.
int16_t x X coordinate.
int16_t y Y coordinate.

◆ 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 touch.h:80
Touchscreen runtime state.
Definition touch.h:78
#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_disable()

int pbl_touch_disable ( const struct pbl_touch *  touch)

Drop a reference taken with pbl_touch_enable(), powering the touchscreen down on the last one.

Parameters
touchTouchscreen.
Returns
0, -ENODEV if the touchscreen is not ready, -EALREADY if it has no users, or a negative errno, in which case the reference is dropped anyway.

◆ pbl_touch_enable()

int pbl_touch_enable ( const struct pbl_touch *  touch)

Take a reference on the touchscreen, powering it up on the first one.

Parameters
touchTouchscreen.
Returns
0, -ENODEV if the touchscreen is not ready, or a negative errno, in which case no reference is taken.

◆ pbl_touch_get_last()

void pbl_touch_get_last ( const struct pbl_touch *  touch,
struct pbl_touch_sample *  sample 
)

Get the last sample reported.

Parameters
touchTouchscreen.
[out]sampleLast sample, in display coordinates.

◆ pbl_touch_get_props()

static const struct pbl_touch_props * pbl_touch_get_props ( const struct pbl_touch *  touch)
inlinestatic

Get the properties of a touchscreen.

Parameters
touchTouchscreen.
Returns
Its properties.

References pbl_touch::props.

◆ pbl_touch_is_enabled()

bool pbl_touch_is_enabled ( const struct pbl_touch *  touch)

Check whether the touchscreen has users.

Parameters
touchTouchscreen.
Returns
true while powered up.

◆ 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.

Variable Documentation

◆ TOUCH

const struct pbl_touch* const TOUCH
extern

The board's touchscreen.