From 6b66a879c41e5a0f24e17d1b9889e01b441d1186 Mon Sep 17 00:00:00 2001 From: Fabio Cavallo Date: Thu, 1 Aug 2024 12:03:24 +0200 Subject: [PATCH] Check that the environment is Linux. --- src/core/jstick.c | 18 +++++++++++------- src/core/jstick.h | 4 +++- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/core/jstick.c b/src/core/jstick.c index 587d56a86..f0b20a126 100644 --- a/src/core/jstick.c +++ b/src/core/jstick.c @@ -154,15 +154,19 @@ 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; - - BYTE *byte = (BYTE *)&word[2]; - int idx = 0; - for (const char *s = jdev->uniq; *s; ++s) { - byte[idx++] ^= *s; - if (idx > 11) { - idx = 0; +#if defined (_linux__) + if (ustrlen(jdev->uniq)) { + 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 61f2b4b0f..6c4eb06ff 100644 --- a/src/core/jstick.h +++ b/src/core/jstick.h @@ -161,11 +161,13 @@ typedef struct _js_device { int size; } report; #endif +#endif +#if defined (__linux__) + uTCHAR uniq[64]; #endif // comuni enum _js_gamepad_type type; uTCHAR desc[128]; - uTCHAR uniq[64]; _js_info info; _js_data data; _input_guid guid;