forked from drath/libratbag
keep track of opened devices
If we want to remove the duplicate nodes opened when using ratbag_find_hidraw(), we need to somehow keep track of all opened ratbag_device. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
This commit is contained in:
@@ -50,6 +50,7 @@ struct ratbag {
|
||||
|
||||
struct udev *udev;
|
||||
struct list drivers;
|
||||
struct list devices;
|
||||
|
||||
int refcount;
|
||||
ratbag_log_handler log_handler;
|
||||
@@ -74,6 +75,8 @@ struct ratbag_device {
|
||||
unsigned num_buttons;
|
||||
|
||||
void *drv_data;
|
||||
|
||||
struct list link;
|
||||
};
|
||||
|
||||
struct ratbag_id {
|
||||
|
||||
@@ -172,6 +172,7 @@ ratbag_device_new(struct ratbag *ratbag, struct udev_device *udev_device,
|
||||
device->ids = *id;
|
||||
list_init(&device->profiles);
|
||||
|
||||
list_insert(&ratbag->devices, &device->link);
|
||||
|
||||
return device;
|
||||
}
|
||||
@@ -196,6 +197,8 @@ ratbag_device_destroy(struct ratbag_device *device)
|
||||
if (device->udev_device)
|
||||
udev_device_unref(device->udev_device);
|
||||
|
||||
list_remove(&device->link);
|
||||
|
||||
ratbag_unref(device->ratbag);
|
||||
free(device->name);
|
||||
free(device);
|
||||
@@ -488,6 +491,7 @@ ratbag_create_context(const struct ratbag_interface *interface,
|
||||
ratbag->userdata = userdata;
|
||||
|
||||
list_init(&ratbag->drivers);
|
||||
list_init(&ratbag->devices);
|
||||
ratbag->udev = udev_new();
|
||||
if (!ratbag->udev) {
|
||||
free(ratbag);
|
||||
|
||||
Reference in New Issue
Block a user