forked from drath/libratbag
hidpp: add hidpp_device_init()
Make this into a somewhat more sensible API and default to printf as log handler. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
@@ -226,9 +226,9 @@ hidpp10drv_probe(struct ratbag_device *device)
|
||||
}
|
||||
|
||||
drv_data = zalloc(sizeof(*drv_data));
|
||||
hidpp_device_init(&base, device->hidraw.fd);
|
||||
base.log_handler = hidpp10_log;
|
||||
base.userdata = device;
|
||||
base.hidraw_fd = device->hidraw.fd;
|
||||
|
||||
/* We can treat all devices as wired devices here. If we talk to the
|
||||
* correct hidraw device the kernel adjusts the device index for us,
|
||||
|
||||
@@ -290,3 +290,17 @@ hidpp_log_buffer(struct hidpp_device *dev,
|
||||
|
||||
hidpp_log(dev, priority, "%s\n", output_buf);
|
||||
}
|
||||
|
||||
static void
|
||||
simple_log(void *userdata, enum hidpp_log_priority priority, const char *format, va_list args)
|
||||
{
|
||||
vprintf(format, args);
|
||||
}
|
||||
|
||||
void
|
||||
hidpp_device_init(struct hidpp_device *dev, int fd)
|
||||
{
|
||||
dev->hidraw_fd = fd;
|
||||
dev->log_handler = simple_log;
|
||||
dev->userdata = NULL;
|
||||
}
|
||||
|
||||
@@ -89,6 +89,10 @@ struct hidpp_device {
|
||||
hidpp_log_handler log_handler;
|
||||
};
|
||||
|
||||
|
||||
void
|
||||
hidpp_device_init(struct hidpp_device *dev, int fd);
|
||||
|
||||
extern const char *hidpp_errors[0xFF];
|
||||
|
||||
const char *
|
||||
|
||||
@@ -50,6 +50,7 @@ hidpp10_device_new_from_wpid(const struct hidpp_device *base,
|
||||
struct hidpp10_device*
|
||||
hidpp10_device_new_from_idx(const struct hidpp_device *base,
|
||||
int idx);
|
||||
|
||||
void
|
||||
hidpp10_device_destroy(struct hidpp10_device *dev);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user