#include "streamdeck.h" #include struct Image { void* data; size_t size; }; struct Key { bool isFolder; void* command; image* key; }; struct Screen { key* keys; }; struct Handler { hid_device* handler; }; handler* create_hid_handler() { handler* res = NULL; res = malloc(sizeof(handler)); if (!res) { return NULL; } /* * Init the HIDAPI library */ if (hid_init() < 0) { (void) fprintf(stderr, "Could not init the HID library\n"); free(res); return NULL; } /* * Create the device handler */ res->handler = hid_open(0x0fd9, 0x0063, NULL); if (!res->handler) { (void) fprintf(stderr, "Could not open Streamdeck!\n"); free(res); hid_exit(); return NULL; } /* * Set handler to be non-blocking */ if (hid_set_nonblocking(res->handler, 1) < 0) { (void) fprintf(stderr, "Could not set HIDAPI handler to be non-blocking\n"); free(res); hid_exit(); return NULL; } return res; }