mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-07 15:46:12 +00:00
os/hid: Add get_physical_address()
This commit is contained in:
parent
a4bde60e08
commit
42996d6b1c
|
@ -37,6 +37,8 @@ struct os_hid_device
|
||||||
|
|
||||||
int (*set_feature)(struct os_hid_device *hid_dev, const uint8_t *data, size_t size);
|
int (*set_feature)(struct os_hid_device *hid_dev, const uint8_t *data, size_t size);
|
||||||
|
|
||||||
|
int (*get_physical_address)(struct os_hid_device *hid_dev, uint8_t *data, size_t size);
|
||||||
|
|
||||||
void (*destroy)(struct os_hid_device *hid_dev);
|
void (*destroy)(struct os_hid_device *hid_dev);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -104,6 +106,21 @@ os_hid_set_feature(struct os_hid_device *hid_dev, const uint8_t *data, size_t si
|
||||||
return hid_dev->set_feature(hid_dev, data, size);
|
return hid_dev->set_feature(hid_dev, data, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Get the physical address.
|
||||||
|
*
|
||||||
|
* For USB devices, the string contains the physical path to the device (the
|
||||||
|
* USB controller, hubs, ports, etc). For Bluetooth *devices, the string
|
||||||
|
* contains the hardware (MAC) address of the device.
|
||||||
|
*
|
||||||
|
* @public @memberof os_hid_device
|
||||||
|
*/
|
||||||
|
static inline int
|
||||||
|
os_hid_get_physical_address(struct os_hid_device *hid_dev, uint8_t *data, size_t size)
|
||||||
|
{
|
||||||
|
return hid_dev->get_physical_address(hid_dev, data, size);
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Close and free the given device.
|
* Close and free the given device.
|
||||||
*
|
*
|
||||||
|
|
|
@ -89,6 +89,13 @@ os_hidraw_get_feature(struct os_hid_device *ohdev, uint8_t report_num, uint8_t *
|
||||||
return ioctl(hrdev->fd, HIDIOCGFEATURE(length), data);
|
return ioctl(hrdev->fd, HIDIOCGFEATURE(length), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
os_hidraw_get_physical_address(struct os_hid_device *ohdev, uint8_t *data, size_t length)
|
||||||
|
{
|
||||||
|
struct hid_hidraw *hrdev = (struct hid_hidraw *)ohdev;
|
||||||
|
return ioctl(hrdev->fd, HIDIOCGRAWPHYS(length), data);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
os_hidraw_get_feature_timeout(struct os_hid_device *ohdev, void *data, size_t length, uint32_t timeout)
|
os_hidraw_get_feature_timeout(struct os_hid_device *ohdev, void *data, size_t length, uint32_t timeout)
|
||||||
{
|
{
|
||||||
|
@ -138,6 +145,7 @@ os_hid_open_hidraw(const char *path, struct os_hid_device **out_hid)
|
||||||
hrdev->base.get_feature = os_hidraw_get_feature;
|
hrdev->base.get_feature = os_hidraw_get_feature;
|
||||||
hrdev->base.get_feature_timeout = os_hidraw_get_feature_timeout;
|
hrdev->base.get_feature_timeout = os_hidraw_get_feature_timeout;
|
||||||
hrdev->base.set_feature = os_hidraw_set_feature;
|
hrdev->base.set_feature = os_hidraw_set_feature;
|
||||||
|
hrdev->base.get_physical_address = os_hidraw_get_physical_address;
|
||||||
hrdev->base.destroy = os_hidraw_destroy;
|
hrdev->base.destroy = os_hidraw_destroy;
|
||||||
hrdev->fd = open(path, O_RDWR);
|
hrdev->fd = open(path, O_RDWR);
|
||||||
if (hrdev->fd < 0) {
|
if (hrdev->fd < 0) {
|
||||||
|
|
Loading…
Reference in a new issue