#[repr(C)]pub struct HidDevice {
pub vendor_id: u16,
pub product_id: u16,
pub usage_page: u16,
pub usage: u16,
pub name: AzString,
pub serial: AzString,
pub instance: u64,
}Expand description
Identity of one HID device.
The four numbers are the HID descriptor’s own vocabulary, not azul’s:
usage_page + usage say what KIND of device it claims to be (page 0x01
usage 0x04 is a joystick, 0x05 a gamepad, 0x08 a multi-axis controller),
while vendor and product identify the model. An app matches on whichever
pair it needs — usage for “any joystick”, vid/pid for “this exact wheel”.
Fields§
§vendor_id: u16USB vendor id.
product_id: u16USB product id.
usage_page: u16HID usage page of the device’s top-level collection.
usage: u16HID usage within that page.
name: AzStringHuman-readable product string, empty when the device reports none.
serial: AzStringThe device’s SERIAL NUMBER as it reports it (USB iSerial; a
DualSense reports its Bluetooth address), empty when it reports none
or the platform does not expose it (Windows, see the backend).
instance: u64PER-INSTANCE identity (8f-i-a-i, user ruling: two identical pads must
stay distinct for multiplayer). Stable for the device’s connected
lifetime and never 0 for a real device. Derived from vendor,
product and serial when a serial is reported - so it survives a
reconnect - and from the platform’s own handle for the device
otherwise, which is unique among the devices present but may change
when the device is re-plugged. Reports carry it, so an app keyed on
this field reads each pad’s stream apart from its twin’s.
Implementations§
Source§impl HidDevice
impl HidDevice
Sourcepub fn serial_instance(
vendor_id: u16,
product_id: u16,
serial: &str,
) -> Option<u64>
pub fn serial_instance( vendor_id: u16, product_id: u16, serial: &str, ) -> Option<u64>
The reconnect-stable instance id of a device with a serial number:
an FNV-1a hash over vendor, product and serial. None when the
device reports no serial - the caller falls back to its platform
handle through Self::handle_instance.
Sourcepub fn handle_instance(handle: &[u8]) -> u64
pub fn handle_instance(handle: &[u8]) -> u64
An instance id from a platform handle (a device path, a kernel
object address, a hidraw number) for a device with no serial. Never
0, so “no identity” stays distinguishable from a real one.