|
SDL 3.0
|
#include <SDL3/SDL_stdinc.h>#include <SDL3/SDL_mouse.h>#include <SDL3/SDL_touch.h>#include <SDL3/SDL_begin_code.h>#include <SDL3/SDL_close_code.h>
Include dependency graph for SDL_pen.h:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Macros | |
| #define | SDL_PEN_MOUSEID ((SDL_MouseID)-2) |
| #define | SDL_PEN_TOUCHID ((SDL_TouchID)-2) |
| #define | SDL_PEN_INPUT_DOWN (1u << 0) |
| #define | SDL_PEN_INPUT_BUTTON_1 (1u << 1) |
| #define | SDL_PEN_INPUT_BUTTON_2 (1u << 2) |
| #define | SDL_PEN_INPUT_BUTTON_3 (1u << 3) |
| #define | SDL_PEN_INPUT_BUTTON_4 (1u << 4) |
| #define | SDL_PEN_INPUT_BUTTON_5 (1u << 5) |
| #define | SDL_PEN_INPUT_ERASER_TIP (1u << 30) |
Typedefs | |
| typedef Uint32 | SDL_PenID |
| typedef Uint32 | SDL_PenInputFlags |
Functions | |
| SDL_PenDeviceType | SDL_GetPenDeviceType (SDL_PenID instance_id) |
| #define SDL_PEN_INPUT_BUTTON_1 (1u << 1) |
| #define SDL_PEN_INPUT_BUTTON_2 (1u << 2) |
| #define SDL_PEN_INPUT_BUTTON_3 (1u << 3) |
| #define SDL_PEN_INPUT_BUTTON_4 (1u << 4) |
| #define SDL_PEN_INPUT_BUTTON_5 (1u << 5) |
| #define SDL_PEN_INPUT_ERASER_TIP (1u << 30) |
| #define SDL_PEN_MOUSEID ((SDL_MouseID)-2) |
| #define SDL_PEN_TOUCHID ((SDL_TouchID)-2) |
SDL pen event handling.
SDL provides an API 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, simply handle pen events:
When a pen starts providing input, SDL will assign it a unique SDL_PenID, which will remain for the life of the process, as long as the pen stays connected.
Pens may provide more than simple touch input; they might have other axes, such as pressure, tilt, rotation, etc. SDL pen instance IDs.
Zero is used to signify an invalid/null device.
These show up in pen events when SDL sees input from them. They remain consistent as long as SDL can recognize a tool to be the same pen; but if a pen physically leaves the area and returns, it might get a new ID.
| typedef Uint32 SDL_PenInputFlags |
| enum SDL_PenAxis |
Pen axis indices.
These are the valid values for the axis field in SDL_PenAxisEvent. All axes 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 axes are always zero.
To convert angles for tilt and rotation into vector representation, use SDL_sinf on the XTILT, YTILT, or ROTATION component, for example:
SDL_sinf(xtilt * SDL_PI_F / 180.0).
Definition at line 118 of file SDL_pen.h.
| enum SDL_PenDeviceType |
An enum that describes the type of a pen device.
A "direct" device is a pen that touches a graphic display (like an Apple Pencil on an iPad's screen). "Indirect" devices touch an external tablet surface that is connected to the machine but is not a display (like a lower-end Wacom tablet connected over USB).
Apps may use this information to decide if they should draw a cursor; if the pen is touching the screen directly, a cursor doesn't make sense and can be in the way, but becomes necessary for indirect devices to know where on the display they are interacting.
Definition at line 145 of file SDL_pen.h.
|
extern |
Get the device type of the given pen.
Many platforms do not supply this information, so an app must always be prepared to get an SDL_PEN_DEVICE_TYPE_UNKNOWN result.
| instance_id | the pen instance ID. |
\threadsafety It is safe to call this function from any thread.