aboutsummaryrefslogtreecommitdiff
path: root/vendor/sdl3/sdl3_hidapi.odin
blob: 71286cb3d09933f8263e068bb15c9723171fd73b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package sdl3

import "core:c"


hid_device :: struct {}

hid_bus_type :: enum c.int {
	/** Unknown bus type */
	UNKNOWN = 0x00,

	/** USB bus
	    Specifications:
	    https://usb.org/hid */
	USB = 0x01,

	/** Bluetooth or Bluetooth LE bus
	    Specifications:
	    https://www.bluetooth.com/specifications/specs/human-interface-device-profile-1-1-1/
	    https://www.bluetooth.com/specifications/specs/hid-service-1-0/
	    https://www.bluetooth.com/specifications/specs/hid-over-gatt-profile-1-0/ */
	BLUETOOTH = 0x02,

	/** I2C bus
	    Specifications:
	    https://docs.microsoft.com/previous-versions/windows/hardware/design/dn642101(v=vs.85) */
	I2C = 0x03,

	/** SPI bus
	    Specifications:
	    https://www.microsoft.com/download/details.aspx?id=103325 */
	SPI = 0x04,
}

hid_device_info :: struct {
	/** Platform-specific device path */
	path: [^]c.char `fmt:"q,0"`,
	/** Device Vendor ID */
	vendor_id: c.ushort,
	/** Device Product ID */
	product_id: c.ushort,
	/** Serial Number */
	serial_number: [^]c.wchar_t `fmt:"q,0"`,
	/** Device Release Number in binary-coded decimal,
	also known as Device Version Number */
	release_number: c.ushort,
	/** Manufacturer String */
	manufacturer_string: [^]c.wchar_t `fmt:"q,0"`,
	/** Product string */
	product_string: [^]c.wchar_t `fmt:"q,0"`,
	/** Usage Page for this Device/Interface
	(Windows/Mac/hidraw only) */
	usage_page: c.ushort,
	/** Usage for this Device/Interface
	(Windows/Mac/hidraw only) */
	usage: c.ushort,
	/** The USB interface which this logical device
	    represents.

	    Valid only if the device is a USB HID device.
	    Set to -1 in all other cases.
	*/
	interface_number: c.int,

	/** Additional information about the USB interface.
	Valid on libusb and Android implementations. */
	interface_class: c.int,
	interface_subclass: c.int,
	interface_protocol: c.int,

	/** Underlying bus type */
	bus_type: hid_bus_type,

	/** Pointer to the next device */
	next: ^hid_device_info,
}

PROP_HIDAPI_LIBUSB_DEVICE_HANDLE_POINTER :: "SDL.hidapi.libusb.device.handle"

@(default_calling_convention="c", link_prefix="SDL_", require_results)
foreign lib {
	hid_init                     :: proc() -> c.int ---
	hid_exit                     :: proc() -> c.int ---
	hid_device_change_count      :: proc() -> Uint32 ---
	hid_enumerate                :: proc(vendor_id, product_id: c.ushort) -> ^hid_device_info ---
	hid_free_enumeration         :: proc(devs: ^hid_device_info) ---
	hid_open                     :: proc(vendor_id, product_id: c.ushort, serial_number: [^]c.wchar_t) -> ^hid_device ---
	hid_open_path                :: proc(path: cstring) -> ^hid_device ---
	hid_get_properties           :: proc(dev: ^hid_device) -> PropertiesID ---
	hid_write                    :: proc(dev: ^hid_device, data: [^]byte, length: uint) -> c.int ---
	hid_read_timeout             :: proc(dev: ^hid_device, data: [^]byte, length: uint, milliseconds: c.int) -> c.int ---
	hid_read                     :: proc(dev: ^hid_device, data: [^]byte, length: uint) -> c.int ---
	hid_set_nonblocking          :: proc(dev: ^hid_device, nonblock: c.int) -> c.int ---
	hid_send_feature_report      :: proc(dev: ^hid_device, data: [^]byte, length: uint) -> c.int ---
	hid_get_feature_report       :: proc(dev: ^hid_device, data: [^]byte, length: uint) -> c.int ---
	hid_get_input_report         :: proc(dev: ^hid_device, data: [^]byte, length: uint) -> c.int ---
	hid_close                    :: proc(dev: ^hid_device) -> c.int ---
	hid_get_manufacturer_string  :: proc(dev: ^hid_device, string: [^]c.wchar_t, maxlen: uint) -> c.int ---
	hid_get_product_string       :: proc(dev: ^hid_device, string: [^]c.wchar_t, maxlen: uint) -> c.int ---
	hid_get_serial_number_string :: proc(dev: ^hid_device, string: [^]c.wchar_t, maxlen: uint) -> c.int ---
	hid_get_indexed_string       :: proc(dev: ^hid_device, string_index: c.int, string: [^]c.wchar_t, maxlen: uint) -> c.int ---
	hid_get_device_info          :: proc(dev: ^hid_device) -> ^hid_device_info ---
	hid_get_report_descriptor    :: proc(dev: ^hid_device, buf: [^]byte, buf_size: uint) -> c.int ---
	hid_ble_scan                 :: proc(active: bool) ---
}