hid: Cleanup Windows joystick blacklist code, to make additions easier.
authorRyan C. Gordon <icculus@icculus.org>
Wed, 06 May 2020 03:13:44 -0400
changeset 13792b3476f5917fe
parent 13791 c53bc3314e83
child 13793 015943013626
hid: Cleanup Windows joystick blacklist code, to make additions easier.
src/hidapi/windows/hid.c
     1.1 --- a/src/hidapi/windows/hid.c	Tue May 05 12:48:55 2020 -0400
     1.2 +++ b/src/hidapi/windows/hid.c	Wed May 06 03:13:44 2020 -0400
     1.3 @@ -314,31 +314,24 @@
     1.4  
     1.5  int hid_blacklist(unsigned short vendor_id, unsigned short product_id)
     1.6  {
     1.7 -	// Corsair Gaming keyboard - Causes deadlock when asking for device details
     1.8 -	if ( vendor_id == 0x1B1C && product_id == 0x1B3D )
     1.9 -	{
    1.10 -		return 1;
    1.11 -	}
    1.12 -
    1.13 -	// Razer Lycosa Gaming keyboard - Causes deadlock when asking for device details
    1.14 -	if ( vendor_id == 0x1532 && product_id == 0x0109 )
    1.15 -	{
    1.16 -		return 1;
    1.17 -	}
    1.18 +    size_t i;
    1.19 +    static const struct { unsigned short vid; unsigned short pid; } known_bad[] = {
    1.20 +        /* Causes deadlock when asking for device details... */
    1.21 +        { 0x1B1C, 0x1B3D },  /* Corsair Gaming keyboard */
    1.22 +        { 0x1532, 0x0109 },  /* Razer Lycosa Gaming keyboard */
    1.23 +        { 0x1532, 0x010B },  /* Razer Arctosa Gaming keyboard */
    1.24  
    1.25 -	// Razer Arctosa Gaming keyboard - Causes deadlock when asking for device details
    1.26 -	if ( vendor_id == 0x1532 && product_id == 0x010B )
    1.27 -	{
    1.28 -		return 1;
    1.29 -	}
    1.30 +        /* Turns into an Android controller when enumerated... */
    1.31 +        { 0x0738, 0x2217 }   /* SPEEDLINK COMPETITION PRO */
    1.32 +    };
    1.33  
    1.34 -	// SPEEDLINK COMPETITION PRO - turns into an Android controller when enumerated
    1.35 -	if ( vendor_id == 0x0738 && product_id == 0x2217 )
    1.36 -	{
    1.37 -		return 1;
    1.38 -	}
    1.39 +    for (i = 0; i < SDL_arraysize(known_bad); i++) {
    1.40 +        if ((vendor_id == known_bad[i].vid) && (product_id == known_bad[i].pid)) {
    1.41 +            return 1;
    1.42 +        }
    1.43 +    }
    1.44  
    1.45 -	return 0;
    1.46 +    return 0;
    1.47  }
    1.48  
    1.49  struct hid_device_info HID_API_EXPORT * HID_API_CALL hid_enumerate(unsigned short vendor_id, unsigned short product_id)