121 lines
4.1 KiB
Zig
121 lines
4.1 KiB
Zig
const std = @import("std");
|
|
pub const c = @import("c.zig").c;
|
|
|
|
pub const hid_device = opaque {
|
|
pub inline fn hid_write(hid_device: *hid_device, data: const unsigned char *, length: usize) c_int {
|
|
return c.SDL_hid_write(hid_device, data, length);
|
|
}
|
|
|
|
pub inline fn hid_read_timeout(hid_device: *hid_device, data: unsigned char *, length: usize, milliseconds: c_int) c_int {
|
|
return c.SDL_hid_read_timeout(hid_device, data, length, milliseconds);
|
|
}
|
|
|
|
pub inline fn hid_read(hid_device: *hid_device, data: unsigned char *, length: usize) c_int {
|
|
return c.SDL_hid_read(hid_device, data, length);
|
|
}
|
|
|
|
pub inline fn hid_set_nonblocking(hid_device: *hid_device, nonblock: c_int) c_int {
|
|
return c.SDL_hid_set_nonblocking(hid_device, nonblock);
|
|
}
|
|
|
|
pub inline fn hid_send_feature_report(hid_device: *hid_device, data: const unsigned char *, length: usize) c_int {
|
|
return c.SDL_hid_send_feature_report(hid_device, data, length);
|
|
}
|
|
|
|
pub inline fn hid_get_feature_report(hid_device: *hid_device, data: unsigned char *, length: usize) c_int {
|
|
return c.SDL_hid_get_feature_report(hid_device, data, length);
|
|
}
|
|
|
|
pub inline fn hid_get_input_report(hid_device: *hid_device, data: unsigned char *, length: usize) c_int {
|
|
return c.SDL_hid_get_input_report(hid_device, data, length);
|
|
}
|
|
|
|
pub inline fn hid_close(hid_device: *hid_device) c_int {
|
|
return c.SDL_hid_close(hid_device);
|
|
}
|
|
|
|
pub inline fn hid_get_manufacturer_string(hid_device: *hid_device, string: wchar_t *, maxlen: usize) c_int {
|
|
return c.SDL_hid_get_manufacturer_string(hid_device, string, maxlen);
|
|
}
|
|
|
|
pub inline fn hid_get_product_string(hid_device: *hid_device, string: wchar_t *, maxlen: usize) c_int {
|
|
return c.SDL_hid_get_product_string(hid_device, string, maxlen);
|
|
}
|
|
|
|
pub inline fn hid_get_serial_number_string(hid_device: *hid_device, string: wchar_t *, maxlen: usize) c_int {
|
|
return c.SDL_hid_get_serial_number_string(hid_device, string, maxlen);
|
|
}
|
|
|
|
pub inline fn hid_get_indexed_string(hid_device: *hid_device, string_index: c_int, string: wchar_t *, maxlen: usize) c_int {
|
|
return c.SDL_hid_get_indexed_string(hid_device, string_index, string, maxlen);
|
|
}
|
|
|
|
pub inline fn hid_get_device_info(hid_device: *hid_device) ?*hid_device_info {
|
|
return c.SDL_hid_get_device_info(hid_device);
|
|
}
|
|
|
|
pub inline fn hid_get_report_descriptor(hid_device: *hid_device, buf: unsigned char *, buf_size: usize) c_int {
|
|
return c.SDL_hid_get_report_descriptor(hid_device, buf, buf_size);
|
|
}
|
|
|
|
};
|
|
|
|
pub const hid_bus_type = enum(c_int) {
|
|
hidApiBusUnknown,
|
|
hidApiBusUsb,
|
|
hidApiBusBluetooth,
|
|
hidApiBusI2c,
|
|
hidApiBusSpi,
|
|
};
|
|
|
|
pub const hid_device_info = extern struct {
|
|
path: [*c]u8,
|
|
vendor_id: unsigned short,
|
|
product_id: unsigned short,
|
|
serial_number: wchar_t *,
|
|
release_number: unsigned short,
|
|
manufacturer_string: wchar_t *,
|
|
product_string: wchar_t *,
|
|
usage_page: unsigned short,
|
|
usage: unsigned short,
|
|
interface_number: c_int,
|
|
interface_class: c_int,
|
|
interface_subclass: c_int,
|
|
interface_protocol: c_int,
|
|
bus_type: hid_bus_type,
|
|
next: struct SDL_hid_device_info *,
|
|
};
|
|
|
|
pub inline fn hid_init() c_int {
|
|
return c.SDL_hid_init();
|
|
}
|
|
|
|
pub inline fn hid_exit() c_int {
|
|
return c.SDL_hid_exit();
|
|
}
|
|
|
|
pub inline fn hid_device_change_count() u32 {
|
|
return c.SDL_hid_device_change_count();
|
|
}
|
|
|
|
pub inline fn hid_enumerate(vendor_id: unsigned short, product_id: unsigned short) ?*hid_device_info {
|
|
return c.SDL_hid_enumerate(vendor_id, product_id);
|
|
}
|
|
|
|
pub inline fn hid_free_enumeration(devs: ?*hid_device_info) void {
|
|
return c.SDL_hid_free_enumeration(devs);
|
|
}
|
|
|
|
pub inline fn hid_open(vendor_id: unsigned short, product_id: unsigned short, serial_number: const wchar_t *) ?*hid_device {
|
|
return c.SDL_hid_open(vendor_id, product_id, serial_number);
|
|
}
|
|
|
|
pub inline fn hid_open_path(path: [*c]const u8) ?*hid_device {
|
|
return c.SDL_hid_open_path(path);
|
|
}
|
|
|
|
pub inline fn hid_ble_scan(active: bool) void {
|
|
return c.SDL_hid_ble_scan(active);
|
|
}
|
|
|