Module pen

Available on crate feature dep_sdl3 only.
Expand description

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

Structs§

SDL_PenAxis
Pen axis indices.

Constants§

SDL_PEN_AXIS_COUNT
Total known pen axis types in this version of SDL. This number may grow in future releases!
SDL_PEN_AXIS_DISTANCE
Pen distance to drawing surface. Unidirectional: 0.0 to 1.0
SDL_PEN_AXIS_PRESSURE
Pen pressure. Unidirectional: 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_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_INPUT_BUTTON_1
button 1 is pressed
SDL_PEN_INPUT_BUTTON_2
button 2 is pressed
SDL_PEN_INPUT_BUTTON_3
button 3 is pressed
SDL_PEN_INPUT_BUTTON_4
button 4 is pressed
SDL_PEN_INPUT_BUTTON_5
button 5 is pressed
SDL_PEN_INPUT_DOWN
pen is pressed down
SDL_PEN_INPUT_ERASER_TIP
eraser tip is used
SDL_PEN_MOUSEID
The SDL_MouseID for mouse events simulated with pen input.
SDL_PEN_TOUCHID
The SDL_TouchID for touch events simulated with pen input.

Type Aliases§

SDL_PenID
SDL pen instance IDs.
SDL_PenInputFlags
Pen input flags, as reported by various pen events’ pen_state field.