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"
65 SDL_HID_API_BUS_UNKNOWN;
122#if SDL_VERSION_ATLEAST(3, 4, 0)
359 using HidDeviceBase::HidDeviceBase;
395 unsigned short product_id,
396 const wchar_t* serial_number);
476 return SDL_hid_device_change_count();
506 unsigned short product_id)
508 return CheckError(SDL_hid_enumerate(vendor_id, product_id));
522 SDL_hid_free_enumeration(devs);
542 unsigned short product_id,
543 const wchar_t* serial_number)
545 return HidDevice(vendor_id, product_id, serial_number);
549 unsigned short product_id,
550 const wchar_t* serial_number)
577#if SDL_VERSION_ATLEAST(3, 4, 0)
595 return CheckError(SDL_hid_get_properties(dev));
613 SDL_PROP_HIDAPI_LIBUSB_DEVICE_HANDLE_POINTER;
671 return SDL_hid_read_timeout(
753 return SDL_hid_send_feature_report(
783 return SDL_hid_get_feature_report(
813 return SDL_hid_get_input_report(
851 CheckErrorIfNot(SDL_hid_get_manufacturer_string(dev,
string, maxlen), 0);
896 CheckErrorIfNot(SDL_hid_get_serial_number_string(dev,
string, maxlen), 0);
921 CheckErrorIfNot(SDL_hid_get_indexed_string(dev, string_index,
string, maxlen),
945 return CheckError(SDL_hid_get_device_info(dev));
968 return SDL_hid_get_report_descriptor(
constexpr RawPointer release() noexcept
Definition SDL3pp_resource.h:57
friend constexpr void swap(ResourceBaseT &lhs, ResourceBaseT &rhs) noexcept
Definition SDL3pp_resource.h:65
constexpr RawPointer get() const noexcept
Definition SDL3pp_resource.h:54
constexpr ResourceBaseT()=default
Default constructor, creates null/invalid resource.
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:830
int hid_get_report_descriptor(HidDeviceRef dev, TargetBytes buf)
Get a report descriptor from a HID device.
Definition SDL3pp_hidapi.h:966
hid_device_info * get_device_info()
Get the device info from a HID device.
Definition SDL3pp_hidapi.h:948
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:925
void close()
Close a HID device.
Definition SDL3pp_hidapi.h:835
int hid_write(HidDeviceRef dev, SourceBytes data)
Write an Output report to a HID device.
Definition SDL3pp_hidapi.h:641
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:870
ResourceRefT< HidDeviceBase > HidDeviceRef
Reference for HidDevice.
Definition SDL3pp_hidapi.h:55
int get_input_report(TargetBytes data)
Get an input report from a HID device.
Definition SDL3pp_hidapi.h:817
void get_manufacturer_string(wchar_t *string, size_t maxlen)
Get The Manufacturer String from a HID device.
Definition SDL3pp_hidapi.h:854
void hid_set_nonblocking(HidDeviceRef dev, bool nonblock)
Set the device handle to be non-blocking.
Definition SDL3pp_hidapi.h:721
int send_feature_report(SourceBytes data)
Send a Feature report to the device.
Definition SDL3pp_hidapi.h:757
int hid_get_input_report(HidDeviceRef dev, TargetBytes data)
Get an input report from a HID device.
Definition SDL3pp_hidapi.h:811
hid_device_info * hid_enumerate(unsigned short vendor_id, unsigned short product_id)
Enumerate the HID Devices.
Definition SDL3pp_hidapi.h:505
void get_product_string(wchar_t *string, size_t maxlen)
Get The Product String from a HID device.
Definition SDL3pp_hidapi.h:877
PropertiesRef hid_get_properties()
Get the properties associated with an HidDevice.
Definition SDL3pp_hidapi.h:598
int hid_read(HidDeviceRef dev, TargetBytes data)
Read an Input report from a HID device.
Definition SDL3pp_hidapi.h:695
hid_device_info * hid_get_device_info(HidDeviceRef dev)
Get the device info from a HID device.
Definition SDL3pp_hidapi.h:943
constexpr hid_bus_type HID_API_BUS_I2C
I2C bus Specifications:
Definition SDL3pp_hidapi.h:88
void hid_exit()
Finalize the HIDAPI library.
Definition SDL3pp_hidapi.h:453
void get_serial_number_string(wchar_t *string, size_t maxlen)
Get The Serial Number String from a HID device.
Definition SDL3pp_hidapi.h:899
int hid_read_timeout(HidDeviceRef dev, TargetBytes data, Milliseconds timeout)
Read an Input report from a HID device with timeout.
Definition SDL3pp_hidapi.h:667
SDL_hid_device_info hid_device_info
Information about a connected HID device.
Definition SDL3pp_hidapi.h:102
int write(SourceBytes data)
Write an Output report to a HID device.
Definition SDL3pp_hidapi.h:646
void set_nonblocking(bool nonblock)
Set the device handle to be non-blocking.
Definition SDL3pp_hidapi.h:726
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:892
constexpr hid_bus_type HID_API_BUS_UNKNOWN
Unknown bus type.
Definition SDL3pp_hidapi.h:64
SDL_hid_bus_type hid_bus_type
HID underlying bus types.
Definition SDL3pp_hidapi.h:62
Uint32 hid_device_change_count()
Check to see if devices may have been added or removed.
Definition SDL3pp_hidapi.h:474
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:541
void hid_free_enumeration(hid_device_info *devs)
Free an enumeration linked list.
Definition SDL3pp_hidapi.h:520
void hid_ble_scan(bool active)
Start or stop a BLE scan on iOS and tvOS to pair Steam Controllers.
Definition SDL3pp_hidapi.h:984
int get_feature_report(TargetBytes data)
Get a feature report from a HID device.
Definition SDL3pp_hidapi.h:787
void hid_init()
Initialize the HIDAPI library.
Definition SDL3pp_hidapi.h:439
int hid_get_feature_report(HidDeviceRef dev, TargetBytes data)
Get a feature report from a HID device.
Definition SDL3pp_hidapi.h:781
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:916
constexpr hid_bus_type HID_API_BUS_BLUETOOTH
Bluetooth or Bluetooth LE bus Specifications:
Definition SDL3pp_hidapi.h:81
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:847
constexpr hid_bus_type HID_API_BUS_USB
USB bus Specifications:
Definition SDL3pp_hidapi.h:72
int hid_send_feature_report(HidDeviceRef dev, SourceBytes data)
Send a Feature report to the device.
Definition SDL3pp_hidapi.h:751
constexpr hid_bus_type HID_API_BUS_SPI
SPI bus Specifications:
Definition SDL3pp_hidapi.h:95
HidDevice hid_open_path(StringParam path)
Open a HID device by its path name.
Definition SDL3pp_hidapi.h:572
int read(TargetBytes data)
Read an Input report from a HID device.
Definition SDL3pp_hidapi.h:700
int get_report_descriptor(TargetBytes buf)
Get a report descriptor from a HID device.
Definition SDL3pp_hidapi.h:972
SDL_hid_device * HidDeviceRaw
Alias to raw representation for HidDevice.
Definition SDL3pp_hidapi.h:48
int read_timeout(TargetBytes data, Milliseconds timeout)
Read an Input report from a HID device with timeout.
Definition SDL3pp_hidapi.h:675
PropertiesRef hid_get_properties(HidDeviceRef dev)
Get the properties associated with an HidDevice.
Definition SDL3pp_hidapi.h:593
ResourceRefT< PropertiesBase > PropertiesRef
Reference for Properties.
Definition SDL3pp_properties.h:53
::Uint32 Uint32
An unsigned 32-bit integer type.
Definition SDL3pp_stdinc.h:296
::Uint8 Uint8
An unsigned 8-bit integer type.
Definition SDL3pp_stdinc.h:244
std::chrono::milliseconds Milliseconds
Duration in Miliseconds (Uint32).
Definition SDL3pp_stdinc.h:341
HIDAPI properties.
Definition SDL3pp_hidapi.h:610
constexpr auto LIBUSB_DEVICE_HANDLE_POINTER
Pointer to libusb device handle.
Definition SDL3pp_hidapi.h:612
Main include header for the SDL3pp library.
Sint32 narrowS32(T value)
Narrows to Sint32.
Definition SDL3pp_stdinc.h:6263
Base class to HidDevice.
Definition SDL3pp_hidapi.h:110
constexpr ResourceBaseT()=default
Default constructor, creates null/invalid resource.
An opaque handle representing an open HID device.
Definition SDL3pp_hidapi.h:358
constexpr HidDevice(HidDeviceRaw resource) noexcept
Constructs from raw HidDevice.
Definition SDL3pp_hidapi.h:368
~HidDevice()
Destructor.
Definition SDL3pp_hidapi.h:412
constexpr HidDevice & operator=(HidDevice &&other) noexcept
Assignment operator.
Definition SDL3pp_hidapi.h:415
constexpr HidDevice(HidDevice &&other) noexcept
Move constructor.
Definition SDL3pp_hidapi.h:374
A non-owning reference wrapper for a given resource.
Definition SDL3pp_resource.h:93