SDL_PenAxis(3type)

✨ SDL_PenAxis ✨

okay bestie, welcome to the SDL_PenAxis(3type) page β€” it lives in the SDL3 DATATYPES section of the manual, and it's literally just the vibe check for every axis a pen can report. short page, big slay πŸ’…


🌸 NAME 🌸

SDL_PenAxis β€” the pen axis indices, i.e. the official list of "which direction/number is this pen talking about" πŸ’–


πŸŽ€ SYNOPSIS πŸŽ€

#include <SDL3/SDL_pen.h>

typedef enum SDL_PenAxis
{
    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! */
} SDL_PenAxis;

yes queen, that's the whole enum, no crumbs left behind 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

So these are the valid values for the axis field in SDL_PenAxisEvent. That's the whole point of this enum, bestie β€” it's the menu you pick from when a pen event tells you "hey, something moved."

Every single axis is either normalised to 0..1 or it reports a (positive or negative) angle in degrees, and in the angle case 0.0 represents the centre. Like, the middle. The neutral. The main character resting pose. 🧚

⚠️ Not all pens/backends support all axes β€” and unsupported axes are always zero. So if your pen isn't giving, it's not being shady, it just literally cannot. zero means "not supported here," no cap.

🌈 converting angles to vectors 🌈

Wanna turn tilt and rotation into vector representation? You use SDL_sinf on the XTILT, YTILT, or ROTATION component, like this:

SDL_sinf(xtilt * SDL_PI_F / 180.0).

that's the exact incantation, character for character, don't improvise ✨


⭐ AVAILABILITY ⭐

This enum has been available since SDL 3.2.0. it's not new-new, but it's not ancient either. iconic behavior. πŸ‘‘


πŸ’€ quick reminder that SDL_PEN_AXIS_COUNT is the total known pen axis types in this version of SDL, and this number may grow in future releases β€” so don't you dare hardcode assumptions around it, fr fr.

and that's the page!! go forth and read your pen axes correctly, bestie πŸŽ€

this has been SDL_PenAxis(3type) from the Simple Directmedia Layer, SDL 3.4.18 β€” love u, bye πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from