ALLEGRO_JOYSTICK_STATE(3alleg5)

๐Ÿ“ฆ
version 5.2.11.3 ยท 4 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

๐Ÿ’– NAME ๐Ÿ’–

ALLEGRO_JOYSTICK_STATE โ€” it's the Allegro 5 API bestie, and this one is literally just a lil container for "what is my joystick doing rn" ๐ŸŽฎโœจ


๐ŸŒธ SYNOPSIS ๐ŸŒธ

#include <allegro5/allegro.h>

typedef struct ALLEGRO_JOYSTICK_STATE ALLEGRO_JOYSTICK_STATE;

okay so first thing, you gotta pull in the header with that #include, and then boom โ€” ALLEGRO_JOYSTICK_STATE is a typedef'd struct, that's the whole vibe ๐Ÿซถ


๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

So like. This struct is the snapshot machine ๐Ÿ“ธ โ€” it holds a picture of a joystick's axes and buttons at one particular instant. Not a live feed, not a stream, just a frozen lil moment, iykyk.

โš ๏ธ Every single field in here is public and read-only. You look, you do not touch, periodt ๐Ÿ’…

Here's the shape of it, verbatim:

struct {
   float axis[num_axes];             // -1.0 to 1.0
} stick[num_sticks];
int button[num_buttons];             // 0 to 32767

So you got your stick array, one entry per stick, num_sticks of them ๐Ÿ•น๏ธ and each one carries axis[num_axes] โ€” those are floats running from -1.0 to 1.0, that's the full range, no cap fr.

Then there's button[num_buttons] โ€” plain old ints, and they run from 0 to 32767 ๐Ÿ”ฅ (yes that's the documented range, don't come for me, it's in the source of truth).

That's it. That's the struct. Lowkey elegant, highkey useful ๐Ÿ’œ


โœจ SEE ALSO โœจ


and that's the whole page, bestie!! ๐ŸŽ€ this came straight out of the Allegro reference manual, filed under ALLEGRO_JOYSTICK_STATE(3alleg5) โ€” go forth and read those axes responsibly ๐Ÿงš๐ŸŒˆโญ

๐Ÿ“ฆ where this page comes from