SDL3pp
A slim C++ wrapper for SDL3
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
SDL::HidDevice Class Reference

An opaque handle representing an open HID device. More...

Inheritance diagram for SDL::HidDevice:
Inheritance graph
[legend]

Public Member Functions

constexpr HidDevice (std::nullptr_t=nullptr) noexcept
 Default ctor.
 
constexpr HidDevice (const HidDeviceRaw resource) noexcept
 Constructs from HidDeviceParam. More...
 
constexpr HidDevice (HidDevice &&other) noexcept
 Move constructor.
 
constexpr HidDevice (const HidDeviceRef &other)=delete
 
constexpr HidDevice (HidDeviceRef &&other)=delete
 
 HidDevice (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. More...
 
 HidDevice (StringParam path)
 Open a HID device by its path name. More...
 
 ~HidDevice ()
 Destructor.
 
constexpr HidDeviceoperator= (HidDevice &&other) noexcept
 Assignment operator.
 
constexpr HidDeviceRaw get () const noexcept
 Retrieves underlying HidDeviceRaw.
 
constexpr HidDeviceRaw release () noexcept
 Retrieves underlying HidDeviceRaw and clear this.
 
constexpr auto operator<=> (const HidDevice &other) const noexcept=default
 Comparison.
 
constexpr operator bool () const noexcept
 Converts to bool.
 
constexpr operator HidDeviceParam () const noexcept
 Converts to HidDeviceParam.
 
void close ()
 Close a HID device. More...
 
PropertiesRef hid_get_properties ()
 Get the properties associated with an HidDevice. More...
 
int write (SourceBytes data)
 Write an Output report to a HID device. More...
 
int read_timeout (TargetBytes data, Milliseconds timeout)
 Read an Input report from a HID device with timeout. More...
 
int read (TargetBytes data)
 Read an Input report from a HID device. More...
 
void set_nonblocking (bool nonblock)
 Set the device handle to be non-blocking. More...
 
int send_feature_report (SourceBytes data)
 Send a Feature report to the device. More...
 
int get_feature_report (TargetBytes data)
 Get a feature report from a HID device. More...
 
int get_input_report (TargetBytes data)
 Get an input report from a HID device. More...
 
void get_manufacturer_string (wchar_t *string, size_t maxlen)
 Get The Manufacturer String from a HID device. More...
 
void get_product_string (wchar_t *string, size_t maxlen)
 Get The Product String from a HID device. More...
 
void get_serial_number_string (wchar_t *string, size_t maxlen)
 Get The Serial Number String from a HID device. More...
 
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. More...
 
hid_device_infoget_device_info ()
 Get the device info from a HID device. More...
 
int get_report_descriptor (TargetBytes buf)
 Get a report descriptor from a HID device. More...
 

Protected Member Functions

constexpr HidDevice (const HidDevice &other) noexcept=default
 Copy constructor.
 
constexpr HidDeviceoperator= (const HidDevice &other) noexcept=default
 Assignment operator.
 

Detailed Description

Since
This struct is available since SDL 3.2.0.
Category:
Resource

Constructor & Destructor Documentation

◆ HidDevice() [1/3]

constexpr SDL::HidDevice::HidDevice ( const HidDeviceRaw  resource)
inlineexplicitconstexprnoexcept
Parameters
resourcea HidDeviceRaw to be wrapped.

This assumes the ownership, call release() if you need to take back.

◆ HidDevice() [2/3]

SDL::HidDevice::HidDevice ( unsigned short  vendor_id,
unsigned short  product_id,
const wchar_t *  serial_number 
)
inline

If serial_number is nullptr, the first device with the specified VID and PID is opened.

Parameters
vendor_idthe Vendor ID (VID) of the device to open.
product_idthe Product ID (PID) of the device to open.
serial_numberthe Serial Number of the device to open (Optionally nullptr).
Exceptions
Erroron failure.
Since
This function is available since SDL 3.2.0.

◆ HidDevice() [3/3]

SDL::HidDevice::HidDevice ( StringParam  path)
inline

The path name be determined by calling hid_enumerate(), or a platform-specific path name can be used (eg: /dev/hidraw0 on Linux).

Parameters
paththe path name of the device to open.
Exceptions
Erroron failure.
Since
This function is available since SDL 3.2.0.

The documentation for this class was generated from the following file: