diff --git a/src/core/jstick.c b/src/core/jstick.c index 9457c778a..8d2bf2487 100644 --- a/src/core/jstick.c +++ b/src/core/jstick.c @@ -154,6 +154,17 @@ void js_guid_create(_js_device *jdev) { (*(word + 5)) = jdev->usb.product_id - 300; (*(word + 6)) = jdev->usb.version; (*(word + 7)) = jdev->usb.version - 400; +#if defined (__linux__) + BYTE *byte = (BYTE *)&word[2]; + int idx = 0; + + for (const char *s = jdev->uniq; *s; ++s) { + byte[idx++] ^= *s; + if (idx > 11) { + idx = 0; + } + } +#endif } else { word += 2; memcpy((char *)word, (char *)jdev->desc, sizeof(jdev->guid.data) - 4); diff --git a/src/core/jstick.h b/src/core/jstick.h index 5e070ea25..6c4eb06ff 100644 --- a/src/core/jstick.h +++ b/src/core/jstick.h @@ -161,6 +161,9 @@ typedef struct _js_device { int size; } report; #endif +#endif +#if defined (__linux__) + uTCHAR uniq[64]; #endif // comuni enum _js_gamepad_type type; diff --git a/src/gui/linux/os_jstick.c b/src/gui/linux/os_jstick.c index d3d834e4a..4b140c995 100644 --- a/src/gui/linux/os_jstick.c +++ b/src/gui/linux/os_jstick.c @@ -73,12 +73,15 @@ void js_os_jdev_open(_js_device *jdev, void *arg) { const char *vid = udev_device_get_sysattr_value(udevd, "id/vendor"); const char *ver = udev_device_get_sysattr_value(udevd, "id/version"); const char *name = udev_device_get_sysattr_value(udevd, "name"); + const char *uniq = udev_device_get_sysattr_value(udevd, "uniq"); jdev->usb.bustype = strtoul(btype, NULL, 16); jdev->usb.vendor_id = strtoul(vid, NULL, 16); jdev->usb.product_id = strtoul(pid, NULL, 16); jdev->usb.version = strtoul(ver, NULL, 16); + ustrncpy(jdev->desc, name, usizeof(jdev->desc) - 1); + ustrncpy(jdev->uniq, uniq, usizeof(jdev->uniq) - 1); } else { return; }