{"id":16186921,"url":"https://github.com/robloach/nuklear_gamepad","last_synced_at":"2025-04-07T13:26:37.248Z","repository":{"id":231939092,"uuid":"782850441","full_name":"RobLoach/nuklear_gamepad","owner":"RobLoach","description":"Gamepad API for Nuklear GUI","archived":false,"fork":false,"pushed_at":"2025-03-05T02:32:37.000Z","size":157,"stargazers_count":5,"open_issues_count":6,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-30T18:02:04.276Z","etag":null,"topics":["header-only","nuklear"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"zlib","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RobLoach.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-04-06T08:04:23.000Z","updated_at":"2025-03-05T02:32:40.000Z","dependencies_parsed_at":"2024-04-15T07:18:35.974Z","dependency_job_id":null,"html_url":"https://github.com/RobLoach/nuklear_gamepad","commit_stats":null,"previous_names":["robloach/nuklear_gamepad"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobLoach%2Fnuklear_gamepad","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobLoach%2Fnuklear_gamepad/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobLoach%2Fnuklear_gamepad/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobLoach%2Fnuklear_gamepad/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RobLoach","download_url":"https://codeload.github.com/RobLoach/nuklear_gamepad/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247659504,"owners_count":20974729,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["header-only","nuklear"],"created_at":"2024-10-10T07:19:50.561Z","updated_at":"2025-04-07T13:26:37.242Z","avatar_url":"https://github.com/RobLoach.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nuklear_gamepad\n\nGamepad API for [Nuklear](https://github.com/Immediate-Mode-UI/Nuklear).\n\n![Screenshot](demo/common/nuklear_gamepad_demo.png)\n\n## Example\n\n``` c\n#define NK_GAMEPAD_IMPLEMENTATION\n#define NK_GAMEPAD_SDL\n//#define NK_GAMEPAD_GLFW\n//#define NK_GAMEPAD_RAYLIB\n//#define NK_GAMEPAD_PNTR\n//#define NK_GAMEPAD_KEYBOARD\n//#define NK_GAMEPAD_NONE\n#include \"nuklear_gamepad.h\"\n\n// Initialize the gamepad system.\nstruct nk_gamepads gamepads;\nnk_gamepad_init(\u0026gamepads, ctx, NULL);\n\n// Act on whether or not the A button is pushed\nif (nk_gamepad_is_button_down(\u0026gamepads, 0, NK_GAMEPAD_BUTTON_A)) {\n    nk_label(ctx, \"Button A is down\", NK_TEXT_LEFT);\n}\n\n// Clear the gamepad state.\nnk_gamepad_free(\u0026gamepads);\n```\n\n## Platform Support\n\n- [SDL](https://www.libsdl.org/)\n- [GLFW](https://www.glfw.org/)\n- [raylib](https://www.raylib.com/)\n- [pntr](https://github.com/robloach/pntr) with [pntr_app](https://github.com/robloach/pntr_app)\n- [Add more!](https://github.com/RobLoach/nuklear_gamepad/issues)\n\n## API\n\n``` c\nnk_bool nk_gamepad_init(struct nk_gamepads* gamepads, struct nk_context* ctx, void* user_data);\nnk_bool nk_gamepad_init_with_source(struct nk_gamepads* gamepads, struct nk_context* ctx, struct nk_gamepad_input_source input_source);\nvoid nk_gamepad_free(struct nk_gamepads* gamepads);\nvoid nk_gamepad_update(struct nk_gamepads* gamepads);\nnk_bool nk_gamepad_is_available(struct nk_gamepads* gamepads, int num);\nvoid nk_gamepad_set_available(struct nk_gamepads* gamepads, int num, nk_bool available);\nnk_bool nk_gamepad_is_button_down(struct nk_gamepads* gamepads, int num, enum nk_gamepad_button button);\nnk_bool nk_gamepad_is_button_pressed(struct nk_gamepads* gamepads, int num, enum nk_gamepad_button button);\nnk_bool nk_gamepad_is_button_released(struct nk_gamepads* gamepads, int num, enum nk_gamepad_button button);\nnk_bool nk_gamepad_any_button_pressed(struct nk_gamepads* gamepads, int num, int* out_num, enum nk_gamepad_button* out_button);\nvoid nk_gamepad_button(struct nk_gamepads* gamepads, int num, enum nk_gamepad_button button, nk_bool down);\nint nk_gamepad_count(struct nk_gamepads* gamepads);\nconst char* nk_gamepad_name(struct nk_gamepads* gamepads, int num);\nstruct nk_gamepad_input_source* nk_gamepad_input_source(struct nk_gamepads* gamepads);\nnk_bool nk_gamepad_set_input_source(struct nk_gamepads* gamepads, struct nk_gamepad_input_source input_source);\nnk_gamepad_input_source_fn nk_gamepad_input_sources[];\n```\n\n## Custom Integration\n\nTo define your own custom input source, use `NK_GAMEPAD_NONE` and pass in your own `struct nk_gamepad_input_source`...\n\n```c\n#define NK_GAMEPAD_NONE\n#define NK_GAMEPAD_IMPLEMENTATION\n#include \"nk_gamepad.h\"\n\n// Globals\nstruct nk_gamepads gamepads;\n\n// Initialize the gamepad.\nstruct nk_gamepad_input_source source = {\n    .user_data = NULL, // Optional user_data pointer\n    .init = NULL, // Function to initialize the input source\n    .update = \u0026my_own_gamepad_update, // Function to update the status of the gamepad\n    .free = NULL, // Function used to free up the gamepad data\n    .name = NULL, // Function used to get the name of each gamepad\n    .input_source_name = \"my_own_gamepad\", // The optional name of the input source\n    .id = 1234, // Optional identification for the input source\n};\nnk_gamepad_init_with_source(\u0026gamepads, ctx, struct nk_gamepad_input_source input_source);\n\n// Update the gamepad status\nnk_gamepad_update(\u0026gamepads);\n\n// Free it\nnk_gamepad_free(\u0026gamepads);\n```\n\n## Configuration\n\n| Define | Description  |\n| ------ | ------------ |\n| `NK_GAMEPAD_NONE`     | When set, will avoid detecting which platform to use |\n| `NK_GAMEPAD_SDL`      | Use [SDL](https://www.libsdl.org/) |\n| `NK_GAMEPAD_GLFW`     | Use [glfw](https://www.glfw.org/) |\n| `NK_GAMEPAD_RAYLIB`   | Use [raylib](https://github.com/raysan5/raylib) |\n| `NK_GAMEPAD_PNTR`     | Use [pntr_app](https://github.com/robloach/pntr_app) |\n| `NK_GAMEPAD_KEYBOARD` | Use Nuklear's keyboard interface to emulate gamepad input |\n| `NK_GAMEPAD_INIT`     | Callback used to initialize gamepads |\n| `NK_GAMEPAD_UPDATE`   | Callback used to update all gamepad states |\n| `NK_GAMEPAD_NAME`     | Callback used to get a controller's name |\n| `NK_GAMEPAD_FREE`     | Callback used to disconnect the controllers |\n\n## License\n\nUnless stated otherwise, all works are:\n\n- Copyright (c) 2024 [Rob Loach](https://robloach.net)\n\n... and licensed under:\n\n- [zlib License](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobloach%2Fnuklear_gamepad","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobloach%2Fnuklear_gamepad","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobloach%2Fnuklear_gamepad/lists"}