1 2 // Copyright 2018 - 2022 Michael D. Parker 3 // Distributed under the Boost Software License, Version 1.0. 4 // (See accompanying file LICENSE_1_0.txt or copy at 5 // http://www.boost.org/LICENSE_1_0.txt) 6 7 module bindbc.sdl.bind.sdlhidapi; 8 9 import bindbc.sdl.config; 10 11 static if(sdlSupport >= SDLSupport.sdl2018) { 12 13 import bindbc.sdl.bind.sdlstdinc : SDL_bool; 14 15 struct SDL_hid_device; 16 17 struct SDL_hid_device_info { 18 char* path; 19 ushort vendor_id; 20 ushort product_id; 21 dchar* serial_number; 22 ushort release_number; 23 dchar* manufacturer_string; 24 dchar* product_string; 25 ushort usage_page; 26 ushort usage; 27 int interface_number; 28 int interface_class; 29 int interface_subclass; 30 int interface_protocol; 31 SDL_hid_device_info* next; 32 }; 33 34 static if(staticBinding) { 35 extern(C) @nogc nothrow { 36 int SDL_hid_init(); 37 int SDL_hid_exit(); 38 uint SDL_hid_device_change_count(); 39 SDL_hid_device_info* SDL_hid_enumerate(ushort vendor_id, ushort product_id); 40 void SDL_hid_free_enumeration(SDL_hid_device_info* devs); 41 SDL_hid_device* SDL_hid_open(ushort vendor_id, ushort product_id, const(dchar)* serial_number); 42 SDL_hid_device* SDL_hid_open_path(const(char)* path, int bExclusive = false); 43 int SDL_hid_write(SDL_hid_device* dev, const(ubyte*) data, size_t length); 44 int SDL_hid_read_timeout(SDL_hid_device* dev, ubyte* data, size_t length, int milliseconds); 45 int SDL_hid_read(SDL_hid_device* dev, ubyte* data, size_t length); 46 int SDL_hid_set_nonblocking(SDL_hid_device* dev, int nonblock); 47 int SDL_hid_send_feature_report(SDL_hid_device* dev, const(ubyte)* data, size_t length); 48 int SDL_hid_get_feature_report(SDL_hid_device* dev, ubyte* data, size_t length); 49 int SDL_hid_get_manufacturer_string(SDL_hid_device* dev, dchar* string_, size_t maxlen); 50 int SDL_hid_get_product_string(SDL_hid_device* dev, dchar* string_, size_t maxlen); 51 int SDL_hid_get_serial_number_string(SDL_hid_device* dev, dchar* string_, size_t maxlen); 52 int SDL_hid_get_indexed_string(SDL_hid_device* dev, int string_index, dchar* string_, size_t maxlen); 53 void SDL_hid_ble_scan(SDL_bool active); 54 } 55 } 56 else { 57 extern(C) @nogc nothrow { 58 alias pSDL_hid_init = int function(); 59 alias pSDL_hid_exit = int function(); 60 alias pSDL_hid_device_change_count = uint function(); 61 alias pSDL_hid_enumerate = SDL_hid_device_info* function(ushort vendor_id, ushort product_id); 62 alias pSDL_hid_free_enumeration = void function(SDL_hid_device_info* devs); 63 alias pSDL_hid_open = SDL_hid_device* function(ushort vendor_id, ushort product_id, const(dchar)* serial_number); 64 alias pSDL_hid_open_path = SDL_hid_device* function(const(char)* path, int bExclusive = false); 65 alias pSDL_hid_write = int function(SDL_hid_device* dev, const(ubyte*) data, size_t length); 66 alias pSDL_hid_read_timeout = int function(SDL_hid_device* dev, ubyte* data, size_t length, int milliseconds); 67 alias pSDL_hid_read = int function(SDL_hid_device* dev, ubyte* data, size_t length); 68 alias pSDL_hid_set_nonblocking = int function(SDL_hid_device* dev, int nonblock); 69 alias pSDL_hid_send_feature_report = int function(SDL_hid_device* dev, const(ubyte)* data, size_t length); 70 alias pSDL_hid_get_feature_report = int function(SDL_hid_device* dev, ubyte* data, size_t length); 71 alias pSDL_hid_get_manufacturer_string = int function(SDL_hid_device* dev, dchar* string_, size_t maxlen); 72 alias pSDL_hid_get_product_string = int function(SDL_hid_device* dev, dchar* string_, size_t maxlen); 73 alias pSDL_hid_get_serial_number_string = int function(SDL_hid_device* dev, dchar* string_, size_t maxlen); 74 alias pSDL_hid_get_indexed_string = int function(SDL_hid_device* dev, int string_index, dchar* string_, size_t maxlen); 75 alias pSDL_hid_ble_scan = void function(SDL_bool active); 76 } 77 78 __gshared { 79 pSDL_hid_init SDL_hid_init; 80 pSDL_hid_exit SDL_hid_exit; 81 pSDL_hid_device_change_count SDL_hid_device_change_count; 82 pSDL_hid_enumerate SDL_hid_enumerate; 83 pSDL_hid_free_enumeration SDL_hid_free_enumeration; 84 pSDL_hid_open SDL_hid_open; 85 pSDL_hid_open_path SDL_hid_open_path; 86 pSDL_hid_write SDL_hid_write; 87 pSDL_hid_read_timeout SDL_hid_read_timeout; 88 pSDL_hid_read SDL_hid_read; 89 pSDL_hid_set_nonblocking SDL_hid_set_nonblocking; 90 pSDL_hid_send_feature_report SDL_hid_send_feature_report; 91 pSDL_hid_get_feature_report SDL_hid_get_feature_report; 92 pSDL_hid_get_manufacturer_string SDL_hid_get_manufacturer_string; 93 pSDL_hid_get_product_string SDL_hid_get_product_string; 94 pSDL_hid_get_serial_number_string SDL_hid_get_serial_number_string; 95 pSDL_hid_get_indexed_string SDL_hid_get_indexed_string; 96 pSDL_hid_ble_scan SDL_hid_ble_scan; 97 } 98 } 99 }