SDL 3.0
SDL_pen.h File Reference
+ 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
 

Enumerations

enum  SDL_PenAxis {
  SDL_PEN_AXIS_PRESSURE ,
  SDL_PEN_AXIS_XTILT ,
  SDL_PEN_AXIS_YTILT ,
  SDL_PEN_AXIS_DISTANCE ,
  SDL_PEN_AXIS_ROTATION ,
  SDL_PEN_AXIS_SLIDER ,
  SDL_PEN_AXIS_TANGENTIAL_PRESSURE ,
  SDL_PEN_AXIS_COUNT
}
 
enum  SDL_PenDeviceType {
  SDL_PEN_DEVICE_TYPE_INVALID = -1 ,
  SDL_PEN_DEVICE_TYPE_UNKNOWN ,
  SDL_PEN_DEVICE_TYPE_DIRECT ,
  SDL_PEN_DEVICE_TYPE_INDIRECT
}
 

Functions

SDL_PenDeviceType SDL_GetPenDeviceType (SDL_PenID instance_id)
 

Macro Definition Documentation

◆ SDL_PEN_INPUT_BUTTON_1

#define SDL_PEN_INPUT_BUTTON_1   (1u << 1)

button 1 is pressed

Definition at line 96 of file SDL_pen.h.

◆ SDL_PEN_INPUT_BUTTON_2

#define SDL_PEN_INPUT_BUTTON_2   (1u << 2)

button 2 is pressed

Definition at line 97 of file SDL_pen.h.

◆ SDL_PEN_INPUT_BUTTON_3

#define SDL_PEN_INPUT_BUTTON_3   (1u << 3)

button 3 is pressed

Definition at line 98 of file SDL_pen.h.

◆ SDL_PEN_INPUT_BUTTON_4

#define SDL_PEN_INPUT_BUTTON_4   (1u << 4)

button 4 is pressed

Definition at line 99 of file SDL_pen.h.

◆ SDL_PEN_INPUT_BUTTON_5

#define SDL_PEN_INPUT_BUTTON_5   (1u << 5)

button 5 is pressed

Definition at line 100 of file SDL_pen.h.

◆ SDL_PEN_INPUT_DOWN

#define SDL_PEN_INPUT_DOWN   (1u << 0)

pen is pressed down

Definition at line 95 of file SDL_pen.h.

◆ SDL_PEN_INPUT_ERASER_TIP

#define SDL_PEN_INPUT_ERASER_TIP   (1u << 30)

eraser tip is used

Definition at line 101 of file SDL_pen.h.

◆ SDL_PEN_MOUSEID

#define SDL_PEN_MOUSEID   ((SDL_MouseID)-2)

The SDL_MouseID for mouse events simulated with pen input.

Since
This macro is available since SDL 3.2.0.

Definition at line 79 of file SDL_pen.h.

◆ SDL_PEN_TOUCHID

#define SDL_PEN_TOUCHID   ((SDL_TouchID)-2)

The SDL_TouchID for touch events simulated with pen input.

Since
This macro is available since SDL 3.2.0.

Definition at line 86 of file SDL_pen.h.

Typedef Documentation

◆ SDL_PenID

typedef Uint32 SDL_PenID

CategoryPen

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.

Since
This datatype is available since SDL 3.2.0.

Definition at line 72 of file SDL_pen.h.

◆ SDL_PenInputFlags

Pen input flags, as reported by various pen events' pen_state field.

Since
This datatype is available since SDL 3.2.0.

Definition at line 93 of file SDL_pen.h.

Enumeration Type Documentation

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

Since
This enum is available since SDL 3.2.0.
Enumerator
SDL_PEN_AXIS_PRESSURE 

Pen pressure. Unidirectional: 0 to 1.0

SDL_PEN_AXIS_XTILT 

Pen horizontal tilt angle. Bidirectional: -90.0 to 90.0 (left-to-right).

SDL_PEN_AXIS_YTILT 

Pen vertical tilt angle. Bidirectional: -90.0 to 90.0 (top-to-down).

SDL_PEN_AXIS_DISTANCE 

Pen distance to drawing surface. Unidirectional: 0.0 to 1.0

SDL_PEN_AXIS_ROTATION 

Pen barrel rotation. Bidirectional: -180 to 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 to 1.0

SDL_PEN_AXIS_TANGENTIAL_PRESSURE 

Pressure from squeezing the pen ("barrel pressure").

SDL_PEN_AXIS_COUNT 

Total known pen axis types in this version of SDL. This number may grow in future releases!

Definition at line 118 of file SDL_pen.h.

119{
120 SDL_PEN_AXIS_PRESSURE, /**< Pen pressure. Unidirectional: 0 to 1.0 */
121 SDL_PEN_AXIS_XTILT, /**< Pen horizontal tilt angle. Bidirectional: -90.0 to 90.0 (left-to-right). */
122 SDL_PEN_AXIS_YTILT, /**< Pen vertical tilt angle. Bidirectional: -90.0 to 90.0 (top-to-down). */
123 SDL_PEN_AXIS_DISTANCE, /**< Pen distance to drawing surface. Unidirectional: 0.0 to 1.0 */
124 SDL_PEN_AXIS_ROTATION, /**< Pen barrel rotation. Bidirectional: -180 to 179.9 (clockwise, 0 is facing up, -180.0 is facing down). */
125 SDL_PEN_AXIS_SLIDER, /**< Pen finger wheel or slider (e.g., Airbrush Pen). Unidirectional: 0 to 1.0 */
126 SDL_PEN_AXIS_TANGENTIAL_PRESSURE, /**< Pressure from squeezing the pen ("barrel pressure"). */
127 SDL_PEN_AXIS_COUNT /**< Total known pen axis types in this version of SDL. This number may grow in future releases! */
SDL_PenAxis
Definition SDL_pen.h:119
@ SDL_PEN_AXIS_PRESSURE
Definition SDL_pen.h:120
@ SDL_PEN_AXIS_XTILT
Definition SDL_pen.h:121
@ SDL_PEN_AXIS_SLIDER
Definition SDL_pen.h:125
@ SDL_PEN_AXIS_DISTANCE
Definition SDL_pen.h:123
@ SDL_PEN_AXIS_YTILT
Definition SDL_pen.h:122
@ SDL_PEN_AXIS_ROTATION
Definition SDL_pen.h:124
@ SDL_PEN_AXIS_TANGENTIAL_PRESSURE
Definition SDL_pen.h:126
@ SDL_PEN_AXIS_COUNT
Definition SDL_pen.h:127

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

Since
This enum is available since SDL 3.4.0.
Enumerator
SDL_PEN_DEVICE_TYPE_INVALID 

Not a valid pen device.

SDL_PEN_DEVICE_TYPE_UNKNOWN 

Don't know specifics of this pen.

SDL_PEN_DEVICE_TYPE_DIRECT 

Pen touches display.

SDL_PEN_DEVICE_TYPE_INDIRECT 

Pen touches something that isn't the display.

Definition at line 145 of file SDL_pen.h.

146{
147 SDL_PEN_DEVICE_TYPE_INVALID = -1, /**< Not a valid pen device. */
148 SDL_PEN_DEVICE_TYPE_UNKNOWN, /**< Don't know specifics of this pen. */
149 SDL_PEN_DEVICE_TYPE_DIRECT, /**< Pen touches display. */
150 SDL_PEN_DEVICE_TYPE_INDIRECT /**< Pen touches something that isn't the display. */
SDL_PenDeviceType
Definition SDL_pen.h:146
@ SDL_PEN_DEVICE_TYPE_INVALID
Definition SDL_pen.h:147
@ SDL_PEN_DEVICE_TYPE_UNKNOWN
Definition SDL_pen.h:148
@ SDL_PEN_DEVICE_TYPE_DIRECT
Definition SDL_pen.h:149
@ SDL_PEN_DEVICE_TYPE_INDIRECT
Definition SDL_pen.h:150

Function Documentation

◆ SDL_GetPenDeviceType()

SDL_PenDeviceType SDL_GetPenDeviceType ( SDL_PenID  instance_id)
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.

Parameters
instance_idthe pen instance ID.
Returns
the device type of the given pen, or SDL_PEN_DEVICE_TYPE_INVALID on failure; call SDL_GetError() for more information.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.4.0.