SDL 3.0
|
Go to the source code of this file.
Data Structures | |
struct | SDL_PenCapabilityInfo |
Typedefs | |
typedef Uint32 | SDL_PenID |
Enumerations | |
enum | SDL_PenAxis { SDL_PEN_AXIS_PRESSURE = 0 , SDL_PEN_AXIS_XTILT , SDL_PEN_AXIS_YTILT , SDL_PEN_AXIS_DISTANCE , SDL_PEN_AXIS_ROTATION , SDL_PEN_AXIS_SLIDER , SDL_PEN_NUM_AXES , SDL_PEN_AXIS_LAST = SDL_PEN_NUM_AXES - 1 } |
enum | SDL_PenSubtype { SDL_PEN_TYPE_UNKNOWN = 0 , SDL_PEN_TYPE_ERASER = 1 , SDL_PEN_TYPE_PEN , SDL_PEN_TYPE_PENCIL , SDL_PEN_TYPE_BRUSH , SDL_PEN_TYPE_AIRBRUSH , SDL_PEN_TYPE_LAST = SDL_PEN_TYPE_AIRBRUSH } |
Functions | |
SDL_PenID * | SDL_GetPens (int *count) |
Uint32 | SDL_GetPenStatus (SDL_PenID instance_id, float *x, float *y, float *axes, size_t num_axes) |
SDL_PenID | SDL_GetPenFromGUID (SDL_GUID guid) |
SDL_GUID | SDL_GetPenGUID (SDL_PenID instance_id) |
SDL_bool | SDL_PenConnected (SDL_PenID instance_id) |
const char * | SDL_GetPenName (SDL_PenID instance_id) |
Uint32 | SDL_GetPenCapabilities (SDL_PenID instance_id, SDL_PenCapabilityInfo *capabilities) |
SDL_PenSubtype | SDL_GetPenType (SDL_PenID instance_id) |
Include file for SDL pen event handling.
This file describes operations for pressure-sensitive pen (stylus and/or eraser) handling, e.g., for input and drawing tablets or suitably equipped mobile / tablet devices.
To get started with pens:
This header file describes advanced functionality that can be useful for managing user configuration and understanding the capabilities of the attached pens.
We primarily identify pens by SDL_PenID. The implementation makes a best effort to relate each :SDL_PenID to the same physical device during a session. Formerly valid SDL_PenID values remain valid even if a device disappears.
For identifying pens across sessions, the API provides the type SDL_GUID .
Definition in file SDL_pen.h.
#define SDL_PEN_AXIS_CAPABILITY | ( | axis | ) | SDL_PEN_CAPABILITY((axis) + SDL_PEN_FLAG_AXIS_BIT_OFFSET) |
#define SDL_PEN_FLAG_AXIS_BIT_OFFSET 16 /* Bit for storing has-axis-0 property */ |
#define SDL_PEN_FLAG_DOWN_BIT_INDEX 13 /* Bit for storing that pen is touching the surface */ |
#define SDL_PEN_FLAG_ERASER_BIT_INDEX 15 /* Bit for storing is-eraser or has-eraser-capability property */ |
#define SDL_PEN_FLAG_INK_BIT_INDEX 14 /* Bit for storing has-non-eraser-capability status */ |
#define SDL_PEN_INFO_UNKNOWN (-1) |
#define SDL_PEN_INVALID ((SDL_PenID)0) |
#define SDL_PEN_MOUSEID ((SDL_MouseID)-2) |
#define SDL_PEN_TIP_ERASER SDL_PEN_FLAG_ERASER_BIT_INDEX |
#define SDL_PEN_TIP_INK SDL_PEN_FLAG_INK_BIT_INDEX |
enum SDL_PenAxis |
Pen axis indices
Below are the valid indices to the "axis" array from SDL_PenMotionEvent and SDL_PenButtonEvent. The axis indices form a contiguous range of ints from 0 to SDL_PEN_AXIS_LAST, inclusive. All "axis[]" entries are either normalised to 0..1 or report a (positive or negative) angle in degrees, with 0.0 representing the centre. Not all pens/backends support all axes: unsupported entries are always "0.0f".
To convert angles for tilt and rotation into vector representation, use SDL_sinf on the XTILT, YTILT, or ROTATION component, e.g., "SDL_sinf(xtilt * SDL_PI_F / 180.0)".
Enumerator | |
---|---|
SDL_PEN_AXIS_PRESSURE | Pen pressure. Unidirectional: 0..1.0 |
SDL_PEN_AXIS_XTILT | Pen horizontal tilt angle. Bidirectional: -90.0..90.0 (left-to-right). The physical max/min tilt may be smaller than -90.0 / 90.0, cf. SDL_PenCapabilityInfo |
SDL_PEN_AXIS_YTILT | Pen vertical tilt angle. Bidirectional: -90.0..90.0 (top-to-down). The physical max/min tilt may be smaller than -90.0 / 90.0, cf. SDL_PenCapabilityInfo |
SDL_PEN_AXIS_DISTANCE | Pen distance to drawing surface. Unidirectional: 0.0..1.0 |
SDL_PEN_AXIS_ROTATION | Pen barrel rotation. Bidirectional: -180..179.9 (clockwise, 0 is facing up, -180.0 is facing down). |
SDL_PEN_AXIS_SLIDER | Pen finger wheel or slider (e.g., Airbrush Pen). Unidirectional: 0..1.0 |
SDL_PEN_NUM_AXES | Last valid axis index |
SDL_PEN_AXIS_LAST | Last axis index plus 1 |
Definition at line 77 of file SDL_pen.h.
enum SDL_PenSubtype |
Pen types
Some pens identify as a particular type of drawing device (e.g., an airbrush or a pencil).
|
extern |
Retrieves capability flags for a given SDL_PenID.
instance_id | The pen to query. |
capabilities | Detail information about pen capabilities, such as the number of buttons |
Retrieves an SDL_PenID for the given SDL_GUID.
guid | A pen GUID. |
Retrieves the SDL_GUID for a given SDL_PenID.
instance_id | The pen to query. |
|
extern |
Retrieves a human-readable description for a SDL_PenID.
instance_id | The pen to query. |
|
extern |
Retrieves all pens that are connected to the system.
Yields an array of SDL_PenID values. These identify and track pens throughout a session. To track pens across sessions (program restart), use SDL_GUID .
count | The number of pens in the array (number of array elements minus 1, i.e., not counting the terminator 0). |
|
extern |
Retrieves the pen's current status.
If the pen is detached (cf. SDL_PenConnected), this operation may return default values.
instance_id | The pen to query. |
x | Out-mode parameter for pen x coordinate. May be NULL. |
y | Out-mode parameter for pen y coordinate. May be NULL. |
axes | Out-mode parameter for axis information. May be null. The axes are in the same order as SDL_PenAxis. |
num_axes | Maximum number of axes to write to "axes". |
|
extern |
Retrieves the pen type for a given SDL_PenID.
instance_id | The pen to query. |
Checks whether a pen is still attached.
If a pen is detached, it will not show up for SDL_GetPens(). Other operations will still be available but may return default values.
instance_id | A pen ID. |