SDL_GetMice(3)

๐Ÿ’– SDL_GetMice ๐Ÿ’–

okay bestie, this is a page from the SDL3 FUNCTIONS manual (yes, that SDL, the Simple Directmedia Layer one) and today's main character is SDL_GetMice ๐Ÿญโœจ

โœจ NAME โœจ

SDL_GetMice โ€” get a list of currently connected mice. that's it, that's the whole job, and she does it flawlessly ๐Ÿ’…


๐ŸŒธ SYNOPSIS ๐ŸŒธ

#include <SDL3/SDL_mouse.h>

SDL_MouseID * SDL_GetMice(int *count);

like. look at that signature. so clean. so minimal. iconic ๐Ÿซถ


๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

so here's the tea, and it's important tea โ˜• โ€” this list is not just physical mice, no ma'am. it will include any device or virtual driver that includes mouse functionality, which lowkey means some game controllers, KVM switches, etc. can show up in there too. so don't be out here acting surprised when your weird lil controller shows up on the guest list ๐ŸŽฎ

and listen โ€” you should wait for input from a device before you consider it actively in use. fr fr. just because something is listed doesn't mean it's out here doing anything. a device that's present but silent is not your business yet, bestie. let it speak first ๐Ÿ‘‘


๐ŸŽ€ FUNCTION PARAMETERS ๐ŸŽ€

  • count โ€” a pointer that gets filled in with the number of mice returned. and the best part? she may be NULL โœจ so if you truly don't care how many, you can just pass NULL and vibe. no judgment, we love a low-effort queen.

๐Ÿ’€ RETURN VALUE ๐Ÿ’€

returns a 0 terminated array of mouse instance IDs ๐Ÿญ๐Ÿญ๐Ÿญโ€ฆ๐Ÿ›‘ (the zero at the end is the little "we're done here" signal, very demure).

or, if things go sideways, it returns NULL on failure โ€” and in that case you gotta call SDL_GetError() for more information, she will tell you what went wrong, she's not mysterious, she's just busy ๐Ÿ˜ญ

โš ๏ธ and DO NOT forget: this array should be freed with SDL_free() when it is no longer needed. not me watching you leak memory because you forgot. free her. she's done her service ๐Ÿซก

๐Ÿงš THREAD SAFETY ๐Ÿงš

main thread only, bestie. this function should only be called on the main thread. no side-quest threads, no multitasking chaos, no "but it worked that one time." main character energy means knowing where you belong ๐Ÿ’…


๐ŸŒˆ AVAILABILITY ๐ŸŒˆ

this function is available since SDL 3.2.0 โญ so if you're on something older, this is not your era, sorry bestie.


๐Ÿ’œ SEE ALSO ๐Ÿ’œ


k that's the whole page, you ate it, you understood it, you're a mouse-API girlie now ๐Ÿญ๐Ÿ‘‘

this lil masterpiece lives in the Simple Directmedia Layer manual, riding along with SDL 3.4.18 โ€” mwah, catch you in the next man page, ily, bye ๐Ÿ’–๐ŸŽ€โœจ

๐Ÿ“ฆ where this page comes from