A simple, cross platform lightweight single-header gamepad library for handling controller input.
Written with support for C89, using overridable C99 features, eg. stdint.h and inline with #define MG_C89.
Note: this project is early in development so there are some things missing and bugs to be worked out.
#define MG_IMPLEMENTATION #include "minigamepad.h" #include <stdio.h> int main(void) { mg_gamepads gamepads = {0}; mg_gamepad* cur; mg_gamepads_init(&gamepads); while (mg_gamepads_update(&gamepads, NULL)); for (cur = gamepads.list.head; cur; cur = cur->next) { printf("%s\n", cur->name); } mg_gamepads_free(&gamepads); return 0; }Then compile with:
linux gcc main.c
macos: gcc main.c -framework IOKit -framework CoreFoundation
windows: gcc main.c OR cl main.c
wasm: emcc main.c -s ASYNCIFY
