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 beNULLโจ so if you truly don't care how many, you can just passNULLand 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 ๐
SDL_GetMouseNameForID(3)โ because IDs are cute but names hit different ๐SDL_HasMouse(3)โ for when you just need a yes or no, no list required ๐
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
- fedora 43: SDL3-devel 3.4.18-1.fc43 ยท Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 ยท Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 ยท Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 ยท Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms