Remove hidapi headers from our headers

This commit is contained in:
wheaney 2025-10-04 21:02:28 -07:00
parent e4ef953662
commit 62d51d9efb
4 changed files with 15 additions and 5 deletions

View File

@ -9,7 +9,11 @@
#include <cstdint>
#endif
#include <hidapi/hidapi.h>
typedef struct imu_hid_info {
uint16_t product_id;
int interface_number;
const char* path;
} imu_hid_info;
#ifdef __cplusplus
extern "C" {
@ -28,7 +32,7 @@ typedef struct imu_sample {
} imu_sample;
typedef struct imu_protocol {
bool (*open)(struct device_imu_t* dev, struct hid_device_info* info);
bool (*open)(struct device_imu_t* dev, const struct imu_hid_info* info);
void (*close)(struct device_imu_t* dev);
bool (*start_stream)(struct device_imu_t* dev);

View File

@ -241,7 +241,13 @@ device_imu_error_type device_imu_open(device_imu_type* device, device_imu_event_
struct hid_device_info* it = info;
while (it) {
const imu_protocol* protocol = xreal_imu_protocol(it->product_id);
if (protocol && protocol->open(device, it)) {
// Convert to minimal info for protocol open
imu_hid_info mini = {
.product_id = it->product_id,
.interface_number = it->interface_number,
.path = it->path,
};
if (protocol && protocol->open(device, &mini)) {
device->product_id = it->product_id;
device->protocol = protocol;
break;

View File

@ -26,7 +26,7 @@
#define device_imu_error(msg) (0)
#endif
static bool hid_open_impl(device_imu_type* device, struct hid_device_info* info) {
static bool hid_open_impl(device_imu_type* device, const struct imu_hid_info* info) {
int iface = xreal_imu_interface_id(info->product_id);
if (iface != -1 && info->interface_number == iface) {
#ifndef NDEBUG

View File

@ -18,7 +18,7 @@ typedef struct {
XrealOneHandle* h;
} xo_ctx;
static bool xo_open_impl(device_imu_type* device, struct hid_device_info* info) {
static bool xo_open_impl(device_imu_type* device, const struct imu_hid_info* info) {
if (!device) return false;
device->handle = NULL;