diff options
author | Bastien Nocera <hadess@hadess.net> | 2023-06-30 18:35:52 +0200 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2023-07-03 16:07:46 +0200 |
commit | 801463a630c54156972c47c27de3d91c00dabfc4 (patch) | |
tree | 32785e66c471e7b93f9107311e3ba9a64d036860 | |
parent | ffe33934ae49182f416b548d6b304a8f29babd39 (diff) |
linux: Don't overwrite detected type with another less precise one
Fix a problem where if the input node of a headset appears after the
headset type has been detected, the type would get overwritten to be a
keyboard.
-rw-r--r-- | src/linux/up-device-supply.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/linux/up-device-supply.c b/src/linux/up-device-supply.c index 91386cf..83c29f2 100644 --- a/src/linux/up-device-supply.c +++ b/src/linux/up-device-supply.c @@ -438,11 +438,21 @@ up_device_supply_sibling_discovered (UpDevice *device, */ /* Fall back to "keyboard" if we didn't find anything. */ - if (new_type == UP_DEVICE_KIND_UNKNOWN) + if (new_type == UP_DEVICE_KIND_UNKNOWN) { + if (cur_type != UP_DEVICE_KIND_UNKNOWN) { + g_debug ("Not overwriting existing type '%s'", + up_device_kind_to_string(cur_type)); + return; + } new_type = UP_DEVICE_KIND_KEYBOARD; + } - if (cur_type != new_type) + if (cur_type != new_type) { + g_debug ("Type changed from %s to %s", + up_device_kind_to_string(cur_type), + up_device_kind_to_string(new_type)); g_object_set (device, "type", new_type, NULL); + } } static UpDeviceKind |