RobLoach / nuklear_gamepad

Gamepad API for Nuklear GUI

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

nuklear_gamepad

Gamepad API for Nuklear.

Screenshot

Example

#define NK_GAMEPAD_IMPLEMENTATION
#define NK_GAMEPAD_SDL
//#define NK_GAMEPAD_GLFW
//#define NK_GAMEPAD_RAYLIB
//#define NK_GAMEPAD_PNTR
//#define NK_GAMEPAD_NONE
#include "nuklear_gamepad.h"

// Initialize the gamepad system.
struct nk_gamepads gamepads;
nk_gamepad_init(&gamepads, ctx, NULL);

// Act on whether or not the A button is pushed
if (nk_gamepad_is_button_down(&gamepads, 0, NK_GAMEPAD_BUTTON_A)) {
    nk_label(ctx, "Button A is down", NK_TEXT_LEFT);
}

// Clear the gamepad state.
nk_gamepad_free(&gamepads);

Platform Support

API

nk_bool nk_gamepad_init(struct nk_gamepads* gamepads, struct nk_context* ctx, void* user_data);
void nk_gamepad_free(struct nk_gamepads* gamepads);
void nk_gamepad_update(struct nk_gamepads* gamepads);
nk_bool nk_gamepad_is_available(struct nk_gamepads* gamepads, int num);
nk_bool nk_gamepad_is_button_down(struct nk_gamepads* gamepads, int num, enum nk_gamepad_button button);
nk_bool nk_gamepad_is_button_pressed(struct nk_gamepads* gamepads, int num, enum nk_gamepad_button button);
nk_bool nk_gamepad_is_button_released(struct nk_gamepads* gamepads, int num, enum nk_gamepad_button button);
nk_bool nk_gamepad_any_button_pressed(struct nk_gamepads* gamepads, int num, int* out_num, enum nk_gamepad_button* out_button);
void nk_gamepad_button(struct nk_gamepads* gamepads, int num, enum nk_gamepad_button button, nk_bool down);
int nk_gamepad_count(struct nk_gamepads* gamepads);
const char* nk_gamepad_name(struct nk_gamepads* gamepads, int num);
void* nk_gamepad_user_data(struct nk_gamepads* gamepads);

Configuration

Define Description
NK_GAMEPAD_NONE When set, will avoid detecting which platform to use
NK_GAMEPAD_SDL Use SDL
NK_GAMEPAD_GLFW Use glfw
NK_GAMEPAD_RAYLIB Use raylib
NK_GAMEPAD_PNTR Use pntr_app
NK_GAMEPAD_INIT Callback used to initialize gamepads
NK_GAMEPAD_UPDATE Callback used to update all gamepad states
NK_GAMEPAD_NAME Callback used to get a controller's name
NK_GAMEPAD_FREE Callback used to disconnect the controllers

License

Unless stated otherwise, all works are:

... and licensed under:

About

Gamepad API for Nuklear GUI

License:zlib License


Languages

Language:C 95.9%Language:CMake 3.7%Language:Makefile 0.4%