1 /+
2 +            Copyright 2022 – 2024 Aya Partridge
3 +          Copyright 2018 - 2022 Michael D. Parker
4 + Distributed under the Boost Software License, Version 1.0.
5 +     (See accompanying file LICENSE_1_0.txt or copy at
6 +           http://www.boost.org/LICENSE_1_0.txt)
7 +/
8 module sdl.hidapi;
9 
10 import bindbc.sdl.config;
11 import bindbc.sdl.codegen;
12 
13 import sdl.stdinc: SDL_bool;
14 
15 static if(sdlSupport >= SDLSupport.v2_0_18){
16 	struct SDL_hid_device;
17 	
18 	struct SDL_hid_device_info{
19 		char* path;
20 		ushort vendor_id;
21 		ushort product_id;
22 		wchar_t* serial_number;
23 		ushort release_number;
24 		wchar_t* manufacturer_string;
25 		wchar_t* product_string;
26 		ushort usage_page;
27 		ushort usage;
28 		int interface_number;
29 		int interface_class;
30 		int interface_subclass;
31 		int interface_protocol;
32 		SDL_hid_device_info* next;
33 	}
34 }
35 
36 mixin(joinFnBinds((){
37 	FnBind[] ret;
38 	if(sdlSupport >= SDLSupport.v2_0_18){
39 		FnBind[] add = [
40 			{q{int}, q{SDL_hid_init}, q{}},
41 			{q{int}, q{SDL_hid_exit}, q{}},
42 			{q{uint}, q{SDL_hid_device_change_count}, q{}},
43 			{q{SDL_hid_device_info*}, q{SDL_hid_enumerate}, q{ushort vendorID, ushort productID}},
44 			{q{void}, q{SDL_hid_free_enumeration}, q{SDL_hid_device_info* devs}},
45 			{q{SDL_hid_device*}, q{SDL_hid_open}, q{ushort vendorID, ushort productID, const(wchar_t)* serialNumber}},
46 			{q{SDL_hid_device*}, q{SDL_hid_open_path}, q{const(char)* path, int bExclusive=false}},
47 			{q{int}, q{SDL_hid_write}, q{SDL_hid_device* dev, const(ubyte*) data, size_t length}},
48 			{q{int}, q{SDL_hid_read_timeout}, q{SDL_hid_device* dev, ubyte* data, size_t length, int milliseconds}},
49 			{q{int}, q{SDL_hid_read}, q{SDL_hid_device* dev, ubyte* data, size_t length}},
50 			{q{int}, q{SDL_hid_set_nonblocking}, q{SDL_hid_device* dev, int nonBlock}},
51 			{q{int}, q{SDL_hid_send_feature_report}, q{SDL_hid_device* dev, const(ubyte)* data, size_t length}},
52 			{q{int}, q{SDL_hid_get_feature_report}, q{SDL_hid_device* dev, ubyte* data, size_t length}},
53 			{q{int}, q{SDL_hid_get_manufacturer_string}, q{SDL_hid_device* dev, wchar_t* string, size_t maxLen}},
54 			{q{int}, q{SDL_hid_get_product_string}, q{SDL_hid_device* dev, wchar_t* string, size_t maxLen}},
55 			{q{int}, q{SDL_hid_get_serial_number_string}, q{SDL_hid_device* dev, wchar_t* string, size_t maxLen}},
56 			{q{int}, q{SDL_hid_get_indexed_string}, q{SDL_hid_device* dev, int stringIndex, wchar_t* string, size_t maxLen}},
57 			{q{void}, q{SDL_hid_ble_scan}, q{SDL_bool active}},
58 		];
59 		ret ~= add;
60 	}
61 	return ret;
62 }()));