SDL_GetKeyboards(3)
π SDL_GetKeyboards(3) π
okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, where we're about to find out exactly which keyboards are vibing with your app rn πΉβ¨
β¨ NAME β¨
SDL_GetKeyboards β get a list of currently connected keyboards π
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_keyboard.h>
SDL_KeyboardID * SDL_GetKeyboards(int *count);
like. that's it. that's the whole thing. one function call and you get the whole keyboard roster π
π¦ DESCRIPTION π¦
okay so heads up, bestie, because this is the part where it gets a lil unhinged: this list will include any device or virtual driver that includes keyboard functionality. and I do mean any. we're talking some mice π, KVM switches, motherboard power buttons, the whole chaotic ensemble. if it can theoretically squirt out a keystroke, it's showing up here. periodt.
so likeβ¦ don't just assume a thing is "actively in use" the second you see it in the list. the correct move is to wait for actual input from a device before you count it as actively in use. vibe check first, assumptions never π
π FUNCTION PARAMETERS π
countβ a pointer that gets filled in with the number of keyboards returned. and guess what? it may beNULL. so if you don't care about the count, you can just passNULLand move on with your life. iconic behavior honestly.
π RETURN VALUE π
Returns a 0 terminated array of keyboards instance IDs, or NULL on failure π (in which case, call SDL_GetError() for more info, she'll tell you what went wrong).
β οΈ and listen, this array? you gotta free it with SDL_free() when you're done with it. no leaving it lying around, bestie. that's not the vibe.
π₯ THREAD SAFETY π₯
this function should only be called on the main thread. main character energy only, no side-quest threads allowed π
π AVAILABILITY π
this function has been available since SDL 3.2.0 π«Ά
π SEE ALSO π
and that's the tea π β brought to you by Simple Directmedia Layer, SDL 3.4.18, the absolute icon herself. mwah, go forth and enumerate those keyboards πβ¨π
π¦ 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