Touchscreen class.
More...
|
| | 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.
|
| |
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.
◆ 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
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
Touchscreen runtime state.
◆ pbl_touch
◆ PBL_TOUCH_INIT
| #define PBL_TOUCH_INIT |
( |
|
sym, |
|
|
|
_name, |
|
|
|
_parent, |
|
|
|
_ops, |
|
|
|
... |
|
) |
| |
Value: { \
.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
-
◆ PBL_TOUCH_STATE_DEFINE
| #define PBL_TOUCH_STATE_DEFINE |
( |
|
sym | ) |
|
Value:
#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
-
| sym | Symbol of the instance. |
◆ 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
-
- 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
-
- Returns
- 0, -ENODEV if the touchscreen is not ready, or a negative errno, in which case no reference is taken.
◆ pbl_touch_get_last()
Get the last sample reported.
- Parameters
-
| touch | Touchscreen. |
| [out] | sample | Last sample, in display coordinates. |
◆ pbl_touch_get_props()
Get the properties of a touchscreen.
- Parameters
-
- 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
-
- 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
-
◆ 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
-
| touch | Touchscreen. |
| down | Whether there is a touch contact. |
| x | X coordinate reported by the controller. |
| y | Y 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
-
| touch | Touchscreen. |
| code | PBL_INPUT_EV_GES code. |
| x | X coordinate reported by the controller. |
| y | Y coordinate reported by the controller. |
◆ pbl_touch_unlock()
| void pbl_touch_unlock |
( |
const struct pbl_touch * |
touch | ) |
|
Release the device lock.
- Parameters
-
◆ TOUCH