mirror of
https://gitlab.freedesktop.org/upower/upower.git
synced 2025-12-20 07:50:02 +01:00
linux: up-device-supply: Only update model name when the device is under the same parent
f17d3bf fixed the unstable joypad model name but led the hid++ devices
to show the incorrect model name if more than one device is paired to a
unifying receiver. The patch only updates the model name when the device
is under the same parent.
Resolves: #309
This commit is contained in:
parent
0f1506b61a
commit
7ae19b529f
1 changed files with 20 additions and 7 deletions
|
|
@ -331,9 +331,10 @@ static void
|
||||||
up_device_supply_sibling_discovered_guess_type (UpDevice *device,
|
up_device_supply_sibling_discovered_guess_type (UpDevice *device,
|
||||||
GObject *sibling)
|
GObject *sibling)
|
||||||
{
|
{
|
||||||
GUdevDevice *input;
|
GUdevDevice *input, *native_device, *parent_device, *parent_sibling;
|
||||||
UpDeviceKind cur_type, new_type;
|
UpDeviceKind cur_type, new_type;
|
||||||
const gchar *new_model_name = NULL;
|
gboolean is_same_parent = FALSE;
|
||||||
|
char *new_model_name;
|
||||||
char *model_name;
|
char *model_name;
|
||||||
char *serial_number;
|
char *serial_number;
|
||||||
int i;
|
int i;
|
||||||
|
|
@ -466,21 +467,33 @@ up_device_supply_sibling_discovered_guess_type (UpDevice *device,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cur_type != new_type) {
|
if (cur_type != new_type) {
|
||||||
|
native_device = G_UDEV_DEVICE (up_device_get_native (device));
|
||||||
|
parent_device = g_udev_device_get_parent (native_device);
|
||||||
|
parent_sibling = g_udev_device_get_parent (input);
|
||||||
|
|
||||||
g_debug ("Type changed from %s to %s",
|
g_debug ("Type changed from %s to %s",
|
||||||
up_device_kind_to_string(cur_type),
|
up_device_kind_to_string (cur_type),
|
||||||
up_device_kind_to_string(new_type));
|
up_device_kind_to_string (new_type));
|
||||||
new_model_name = g_udev_device_get_sysfs_attr (input, "name");
|
|
||||||
|
/* Check if the device and the sibling have the same parent. */
|
||||||
|
if (!g_strcmp0 (g_udev_device_get_sysfs_path (parent_device),
|
||||||
|
g_udev_device_get_sysfs_path (parent_sibling)))
|
||||||
|
is_same_parent = TRUE;
|
||||||
|
|
||||||
|
new_model_name = up_device_supply_get_string (input, "name");
|
||||||
/* The model name of a device component may be different. For example, DualSense
|
/* The model name of a device component may be different. For example, DualSense
|
||||||
* joystick owns "Sony Interactive Entertainment DualSense Wireless Controller"
|
* joystick owns "Sony Interactive Entertainment DualSense Wireless Controller"
|
||||||
* for the joystick and "Sony Interactive Entertainment DualSense Wireless Controller
|
* for the joystick and "Sony Interactive Entertainment DualSense Wireless Controller
|
||||||
* Motion Sensors" for the accelerometer. If the type is change, the corresponding
|
* Motion Sensors" for the accelerometer. If the type is change, the corresponding
|
||||||
* model name have to be changed too. */
|
* model name have to be changed too. */
|
||||||
if (new_model_name != NULL)
|
if (new_model_name != NULL && is_same_parent) {
|
||||||
|
up_make_safe_string (new_model_name);
|
||||||
g_object_set (device,
|
g_object_set (device,
|
||||||
"type", new_type,
|
"type", new_type,
|
||||||
"model", new_model_name,
|
"model", new_model_name,
|
||||||
NULL);
|
NULL);
|
||||||
else
|
g_free (new_model_name);
|
||||||
|
} else
|
||||||
g_object_set (device, "type", new_type, NULL);
|
g_object_set (device, "type", new_type, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue