diff options
author | Simon Ser <contact@emersion.fr> | 2024-03-07 12:16:11 +0100 |
---|---|---|
committer | Simon Zeni <simon@bl4ckb0ne.ca> | 2024-03-07 09:53:40 -0500 |
commit | f2a0e81b2438853e12a2b8fe9bddde154852d85d (patch) | |
tree | 9cb5da9be6a8c3d0bc3fcaeacce36ab2e3f4569c | |
parent | config: add fallback without env vars for keysym translation XKB keymap (diff) | |
download | sway-f2a0e81b2438853e12a2b8fe9bddde154852d85d.tar.gz sway-f2a0e81b2438853e12a2b8fe9bddde154852d85d.tar.zst sway-f2a0e81b2438853e12a2b8fe9bddde154852d85d.zip |
Fetch input device vendor/product from libinput
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4582
-rw-r--r-- | sway/input/input-manager.c | 11 | ||||
-rw-r--r-- | sway/ipc-json.c | 8 |
2 files changed, 13 insertions, 6 deletions
diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c index 056cc3ea..089e1e71 100644 --- a/sway/input/input-manager.c +++ b/sway/input/input-manager.c | |||
@@ -65,8 +65,15 @@ struct sway_seat *input_manager_sway_seat_from_wlr_seat(struct wlr_seat *wlr_sea | |||
65 | } | 65 | } |
66 | 66 | ||
67 | char *input_device_get_identifier(struct wlr_input_device *device) { | 67 | char *input_device_get_identifier(struct wlr_input_device *device) { |
68 | int vendor = device->vendor; | 68 | int vendor = 0, product = 0; |
69 | int product = device->product; | 69 | #if WLR_HAS_LIBINPUT_BACKEND |
70 | if (wlr_input_device_is_libinput(device)) { | ||
71 | struct libinput_device *libinput_dev = wlr_libinput_get_device_handle(device); | ||
72 | vendor = libinput_device_get_id_vendor(libinput_dev); | ||
73 | product = libinput_device_get_id_product(libinput_dev); | ||
74 | } | ||
75 | #endif | ||
76 | |||
70 | char *name = strdup(device->name ? device->name : ""); | 77 | char *name = strdup(device->name ? device->name : ""); |
71 | strip_whitespace(name); | 78 | strip_whitespace(name); |
72 | 79 | ||
diff --git a/sway/ipc-json.c b/sway/ipc-json.c index dfbb7a6e..81ca3483 100644 --- a/sway/ipc-json.c +++ b/sway/ipc-json.c | |||
@@ -1097,10 +1097,6 @@ json_object *ipc_json_describe_input(struct sway_input_device *device) { | |||
1097 | json_object_new_string(device->identifier)); | 1097 | json_object_new_string(device->identifier)); |
1098 | json_object_object_add(object, "name", | 1098 | json_object_object_add(object, "name", |
1099 | json_object_new_string(device->wlr_device->name)); | 1099 | json_object_new_string(device->wlr_device->name)); |
1100 | json_object_object_add(object, "vendor", | ||
1101 | json_object_new_int(device->wlr_device->vendor)); | ||
1102 | json_object_object_add(object, "product", | ||
1103 | json_object_new_int(device->wlr_device->product)); | ||
1104 | json_object_object_add(object, "type", | 1100 | json_object_object_add(object, "type", |
1105 | json_object_new_string( | 1101 | json_object_new_string( |
1106 | input_device_get_type(device))); | 1102 | input_device_get_type(device))); |
@@ -1154,6 +1150,10 @@ json_object *ipc_json_describe_input(struct sway_input_device *device) { | |||
1154 | libinput_dev = wlr_libinput_get_device_handle(device->wlr_device); | 1150 | libinput_dev = wlr_libinput_get_device_handle(device->wlr_device); |
1155 | json_object_object_add(object, "libinput", | 1151 | json_object_object_add(object, "libinput", |
1156 | describe_libinput_device(libinput_dev)); | 1152 | describe_libinput_device(libinput_dev)); |
1153 | json_object_object_add(object, "vendor", | ||
1154 | json_object_new_int(libinput_device_get_id_vendor(libinput_dev))); | ||
1155 | json_object_object_add(object, "product", | ||
1156 | json_object_new_int(libinput_device_get_id_product(libinput_dev))); | ||
1157 | } | 1157 | } |
1158 | #endif | 1158 | #endif |
1159 | 1159 | ||