From 3f165b02d928c9df58217299da0623af94427808 Mon Sep 17 00:00:00 2001 From: Thomas Perl Date: Sat, 2 Jun 2012 18:16:24 +0200 Subject: [PATCH] Fix serial number / connection detection for Linux/hidraw --- psmove.c | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/psmove.c b/psmove.c index b37f04d5..a4b6eb68 100644 --- a/psmove.c +++ b/psmove.c @@ -400,11 +400,6 @@ psmove_connect_internal(wchar_t *serial, char *path, int id) move->serial_number = (char*)calloc(PSMOVE_MAX_SERIAL_LENGTH, sizeof(char)); if (serial != NULL) { wcstombs(move->serial_number, serial, PSMOVE_MAX_SERIAL_LENGTH); - } else { - // FIXME - fprintf(stderr, "[PSMOVE] no serial, using path: %s\n", path); - strcpy(move->serial_number, "path:"); - strcat(move->serial_number, path); } /* Bookkeeping of open handles (for psmove_reinit) */ @@ -709,23 +704,15 @@ psmove_connection_type(PSMove *move) return Conn_Bluetooth; } - wstr[0] = 0x0000; - res = hid_get_serial_number_string(move->handle, - wstr, sizeof(wstr)/sizeof(wstr[0])); - - /** - * As it turns out, we don't get a serial number when connected via USB, - * so assume that when the serial number length is zero, then we have the - * USB connection type, and if we have a greater-than-zero length, then it - * is a Bluetooth connection. - **/ - if (res == 0) { + if (move->serial_number == NULL) { + return Conn_Unknown; + } + + if (strlen(move->serial_number) == 0) { return Conn_USB; - } else if (res > 0) { - return Conn_Bluetooth; } - return Conn_Unknown; + return Conn_Bluetooth; #endif }