1#ifndef SDL3PP_HIDAPI_H_
2#define SDL3PP_HIDAPI_H_
4#include <SDL3/SDL_hidapi.h>
5#include "SDL3pp_error.h"
6#include "SDL3pp_properties.h"
7#include "SDL3pp_stdinc.h"
62 SDL_HID_API_BUS_UNKNOWN;
153 unsigned short product_id,
154 const wchar_t* serial_number);
191#if SDL_VERSION_ATLEAST(3, 4, 0)
474 return SDL_hid_device_change_count();
504 unsigned short product_id)
506 return CheckError(SDL_hid_enumerate(vendor_id, product_id));
520 SDL_hid_free_enumeration(devs);
540 unsigned short product_id,
541 const wchar_t* serial_number)
543 return HidDevice(vendor_id, product_id, serial_number);
547 unsigned short product_id,
548 const wchar_t* serial_number)
575#if SDL_VERSION_ATLEAST(3, 4, 0)
593 return CheckError(SDL_hid_get_properties(dev));
610constexpr auto LIBUSB_DEVICE_HANDLE_POINTER =
611 SDL_PROP_HIDAPI_LIBUSB_DEVICE_HANDLE_POINTER;
669 return SDL_hid_read_timeout(
751 return SDL_hid_send_feature_report(
781 return SDL_hid_get_feature_report(
811 return SDL_hid_get_input_report(
849 CheckErrorIfNot(SDL_hid_get_manufacturer_string(dev,
string, maxlen), 0);
893 CheckErrorIfNot(SDL_hid_get_serial_number_string(dev,
string, maxlen), 0);
917 CheckErrorIfNot(SDL_hid_get_indexed_string(dev, string_index,
string, maxlen),
941 return CheckError(SDL_hid_get_device_info(dev));
964 return SDL_hid_get_report_descriptor(
constexpr RawPointer get() const noexcept
Definition SDL3pp_resource.h:53
constexpr RawPointer release() noexcept
Definition SDL3pp_resource.h:56
constexpr ResourceBase(RawPointer resource)
Constructs from resource pointer.
Definition SDL3pp_resource.h:29
Source byte stream.
Definition SDL3pp_strings.h:237
constexpr size_t size_bytes() const
Retrieves contained size in bytes.
Definition SDL3pp_strings.h:301
constexpr const T * data_as() const
Retrieves contained data.
Definition SDL3pp_strings.h:311
Helpers to use C++ strings parameters.
Definition SDL3pp_strings.h:43
Target byte stream.
Definition SDL3pp_strings.h:323
constexpr T * data_as() const
Retrieves contained data.
Definition SDL3pp_strings.h:413
constexpr size_t size_bytes() const
Retrieves contained size in bytes.
Definition SDL3pp_strings.h:406
constexpr void CheckErrorIfNot(T result, T validValue)
Check and throw if returned value from SDL is an error.
Definition SDL3pp_error.h:246
constexpr void CheckError(bool result)
Check and throw if returned value from SDL is an error.
Definition SDL3pp_error.h:199
void hid_close(HidDeviceRaw dev)
Close a HID device.
Definition SDL3pp_hidapi.h:828
void get_manufacturer_string(wchar_t *string, size_t maxlen)
Get The Manufacturer String from a HID device.
Definition SDL3pp_hidapi.h:852
int hid_get_report_descriptor(HidDeviceRef dev, TargetBytes buf)
Get a report descriptor from a HID device.
Definition SDL3pp_hidapi.h:962
PropertiesRef hid_get_properties()
Get the properties associated with an HidDevice.
Definition SDL3pp_hidapi.h:596
int hid_write(HidDeviceRef dev, SourceBytes data)
Write an Output report to a HID device.
Definition SDL3pp_hidapi.h:639
void hid_get_product_string(HidDeviceRef dev, wchar_t *string, size_t maxlen)
Get The Product String from a HID device.
Definition SDL3pp_hidapi.h:867
void hid_set_nonblocking(HidDeviceRef dev, bool nonblock)
Set the device handle to be non-blocking.
Definition SDL3pp_hidapi.h:719
void set_nonblocking(bool nonblock)
Set the device handle to be non-blocking.
Definition SDL3pp_hidapi.h:724
int hid_get_input_report(HidDeviceRef dev, TargetBytes data)
Get an input report from a HID device.
Definition SDL3pp_hidapi.h:809
hid_device_info * hid_enumerate(unsigned short vendor_id, unsigned short product_id)
Enumerate the HID Devices.
Definition SDL3pp_hidapi.h:503
int get_feature_report(TargetBytes data)
Get a feature report from a HID device.
Definition SDL3pp_hidapi.h:785
int read(TargetBytes data)
Read an Input report from a HID device.
Definition SDL3pp_hidapi.h:698
hid_device_info * get_device_info()
Get the device info from a HID device.
Definition SDL3pp_hidapi.h:944
int hid_read(HidDeviceRef dev, TargetBytes data)
Read an Input report from a HID device.
Definition SDL3pp_hidapi.h:693
hid_device_info * hid_get_device_info(HidDeviceRef dev)
Get the device info from a HID device.
Definition SDL3pp_hidapi.h:939
constexpr hid_bus_type HID_API_BUS_I2C
I2C bus Specifications:
Definition SDL3pp_hidapi.h:85
void hid_exit()
Finalize the HIDAPI library.
Definition SDL3pp_hidapi.h:451
void get_product_string(wchar_t *string, size_t maxlen)
Get The Product String from a HID device.
Definition SDL3pp_hidapi.h:874
int hid_read_timeout(HidDeviceRef dev, TargetBytes data, Milliseconds timeout)
Read an Input report from a HID device with timeout.
Definition SDL3pp_hidapi.h:665
SDL_hid_device_info hid_device_info
Information about a connected HID device.
Definition SDL3pp_hidapi.h:99
int send_feature_report(SourceBytes data)
Send a Feature report to the device.
Definition SDL3pp_hidapi.h:755
int read_timeout(TargetBytes data, Milliseconds timeout)
Read an Input report from a HID device with timeout.
Definition SDL3pp_hidapi.h:673
int get_input_report(TargetBytes data)
Get an input report from a HID device.
Definition SDL3pp_hidapi.h:815
ResourceRef< HidDevice > HidDeviceRef
Reference for HidDevice.
Definition SDL3pp_hidapi.h:52
void close()
Close a HID device.
Definition SDL3pp_hidapi.h:833
void hid_get_serial_number_string(HidDeviceRef dev, wchar_t *string, size_t maxlen)
Get The Serial Number String from a HID device.
Definition SDL3pp_hidapi.h:889
constexpr hid_bus_type HID_API_BUS_UNKNOWN
Unknown bus type.
Definition SDL3pp_hidapi.h:61
SDL_hid_bus_type hid_bus_type
HID underlying bus types.
Definition SDL3pp_hidapi.h:59
Uint32 hid_device_change_count()
Check to see if devices may have been added or removed.
Definition SDL3pp_hidapi.h:472
HidDevice hid_open(unsigned short vendor_id, unsigned short product_id, const wchar_t *serial_number)
Open a HID device using a Vendor ID (VID), Product ID (PID) and optionally a serial number.
Definition SDL3pp_hidapi.h:539
void get_indexed_string(int string_index, wchar_t *string, size_t maxlen)
Get a string from a HID device, based on its string index.
Definition SDL3pp_hidapi.h:921
void hid_free_enumeration(hid_device_info *devs)
Free an enumeration linked list.
Definition SDL3pp_hidapi.h:518
void hid_ble_scan(bool active)
Start or stop a BLE scan on iOS and tvOS to pair Steam Controllers.
Definition SDL3pp_hidapi.h:980
void get_serial_number_string(wchar_t *string, size_t maxlen)
Get The Serial Number String from a HID device.
Definition SDL3pp_hidapi.h:896
int write(SourceBytes data)
Write an Output report to a HID device.
Definition SDL3pp_hidapi.h:644
void hid_init()
Initialize the HIDAPI library.
Definition SDL3pp_hidapi.h:437
int hid_get_feature_report(HidDeviceRef dev, TargetBytes data)
Get a feature report from a HID device.
Definition SDL3pp_hidapi.h:779
void hid_get_indexed_string(HidDeviceRef dev, int string_index, wchar_t *string, size_t maxlen)
Get a string from a HID device, based on its string index.
Definition SDL3pp_hidapi.h:912
constexpr hid_bus_type HID_API_BUS_BLUETOOTH
Bluetooth or Bluetooth LE bus Specifications:
Definition SDL3pp_hidapi.h:78
void hid_get_manufacturer_string(HidDeviceRef dev, wchar_t *string, size_t maxlen)
Get The Manufacturer String from a HID device.
Definition SDL3pp_hidapi.h:845
constexpr hid_bus_type HID_API_BUS_USB
USB bus Specifications:
Definition SDL3pp_hidapi.h:69
int hid_send_feature_report(HidDeviceRef dev, SourceBytes data)
Send a Feature report to the device.
Definition SDL3pp_hidapi.h:749
constexpr hid_bus_type HID_API_BUS_SPI
SPI bus Specifications:
Definition SDL3pp_hidapi.h:92
HidDevice hid_open_path(StringParam path)
Open a HID device by its path name.
Definition SDL3pp_hidapi.h:570
SDL_hid_device * HidDeviceRaw
Alias to raw representation for HidDevice.
Definition SDL3pp_hidapi.h:45
int get_report_descriptor(TargetBytes buf)
Get a report descriptor from a HID device.
Definition SDL3pp_hidapi.h:968
PropertiesRef hid_get_properties(HidDeviceRef dev)
Get the properties associated with an HidDevice.
Definition SDL3pp_hidapi.h:591
ResourceRef< Properties > PropertiesRef
Reference for Properties.
Definition SDL3pp_properties.h:54
::Uint32 Uint32
An unsigned 32-bit integer type.
Definition SDL3pp_stdinc.h:290
::Uint8 Uint8
An unsigned 8-bit integer type.
Definition SDL3pp_stdinc.h:238
std::chrono::milliseconds Milliseconds
Duration in Miliseconds (Uint32).
Definition SDL3pp_stdinc.h:335
HIDAPI properties.
Definition SDL3pp_hidapi.h:608
Main include header for the SDL3pp library.
Sint32 narrowS32(T value)
Narrows to Sint32.
Definition SDL3pp_stdinc.h:6257
An opaque handle representing an open HID device.
Definition SDL3pp_hidapi.h:109
constexpr HidDevice(HidDeviceRaw resource) noexcept
Constructs from raw HidDevice.
Definition SDL3pp_hidapi.h:119
constexpr HidDevice(const HidDevice &other)=delete
Copy constructor.
HidDevice & operator=(const HidDevice &other)=delete
Assignment operator.
constexpr ResourceBase(RawPointer resource)
Constructs from resource pointer.
Definition SDL3pp_resource.h:29
~HidDevice()
Destructor.
Definition SDL3pp_hidapi.h:170
constexpr HidDevice & operator=(HidDevice &&other) noexcept
Assignment operator.
Definition SDL3pp_hidapi.h:173
constexpr HidDevice(HidDevice &&other) noexcept
Move constructor.
Definition SDL3pp_hidapi.h:128
A non-owning reference wrapper for a given resource.
Definition SDL3pp_resource.h:156