Added support for the HOTAS Warthog throttle
authorSam Lantinga <slouken@libsdl.org>
Tue, 31 Jan 2017 12:23:29 -0800
changeset 10868a06c32b64184
parent 10867 a512396c9f3f
child 10869 73ddd78f7776
Added support for the HOTAS Warthog throttle
include/SDL_joystick.h
src/joystick/SDL_joystick.c
test/testjoystick.c
     1.1 --- a/include/SDL_joystick.h	Tue Jan 31 10:20:09 2017 -0800
     1.2 +++ b/include/SDL_joystick.h	Tue Jan 31 12:23:29 2017 -0800
     1.3 @@ -83,7 +83,8 @@
     1.4      SDL_JOYSTICK_TYPE_DANCE_PAD,
     1.5      SDL_JOYSTICK_TYPE_GUITAR,
     1.6      SDL_JOYSTICK_TYPE_DRUM_KIT,
     1.7 -    SDL_JOYSTICK_TYPE_ARCADE_PAD
     1.8 +    SDL_JOYSTICK_TYPE_ARCADE_PAD,
     1.9 +	SDL_JOYSTICK_TYPE_THROTTLE,
    1.10  } SDL_JoystickType;
    1.11  
    1.12  typedef enum
     2.1 --- a/src/joystick/SDL_joystick.c	Tue Jan 31 10:20:09 2017 -0800
     2.2 +++ b/src/joystick/SDL_joystick.c	Tue Jan 31 12:23:29 2017 -0800
     2.3 @@ -966,7 +966,7 @@
     2.4      }
     2.5  }
     2.6  
     2.7 -static SDL_bool SDL_IsJoystickGUIDWheel(Uint32 vidpid)
     2.8 +static SDL_bool SDL_IsJoystickProductWheel(Uint32 vidpid)
     2.9  {
    2.10      static Uint32 wheel_joysticks[] = {
    2.11          MAKE_VIDPID(0x046d, 0xc294),    /* Logitech generic wheel */
    2.12 @@ -993,7 +993,7 @@
    2.13      return SDL_FALSE;
    2.14  }
    2.15  
    2.16 -static SDL_bool SDL_IsJoystickGUIDFlightStick(Uint32 vidpid)
    2.17 +static SDL_bool SDL_IsJoystickProductFlightStick(Uint32 vidpid)
    2.18  {
    2.19      static Uint32 flightstick_joysticks[] = {
    2.20          MAKE_VIDPID(0x044f, 0x0402),    /* HOTAS Warthog */
    2.21 @@ -1008,6 +1008,21 @@
    2.22      return SDL_FALSE;
    2.23  }
    2.24  
    2.25 +static SDL_bool SDL_IsJoystickProductThrottle(Uint32 vidpid)
    2.26 +{
    2.27 +    static Uint32 throttle_joysticks[] = {
    2.28 +        MAKE_VIDPID(0x044f, 0x0404),    /* HOTAS Warthog */
    2.29 +    };
    2.30 +    int i;
    2.31 +
    2.32 +    for (i = 0; i < SDL_arraysize(throttle_joysticks); ++i) {
    2.33 +        if (vidpid == throttle_joysticks[i]) {
    2.34 +            return SDL_TRUE;
    2.35 +        }
    2.36 +    }
    2.37 +    return SDL_FALSE;
    2.38 +}
    2.39 +
    2.40  static SDL_JoystickType SDL_GetJoystickGUIDType(SDL_JoystickGUID guid)
    2.41  {
    2.42      Uint16 vendor;
    2.43 @@ -1043,14 +1058,18 @@
    2.44      SDL_GetJoystickGUIDInfo(guid, &vendor, &product, NULL);
    2.45      vidpid = MAKE_VIDPID(vendor, product);
    2.46  
    2.47 -    if (SDL_IsJoystickGUIDWheel(vidpid)) {
    2.48 +    if (SDL_IsJoystickProductWheel(vidpid)) {
    2.49          return SDL_JOYSTICK_TYPE_WHEEL;
    2.50      }
    2.51  
    2.52 -    if (SDL_IsJoystickGUIDFlightStick(vidpid)) {
    2.53 +    if (SDL_IsJoystickProductFlightStick(vidpid)) {
    2.54          return SDL_JOYSTICK_TYPE_FLIGHT_STICK;
    2.55      }
    2.56  
    2.57 +    if (SDL_IsJoystickProductThrottle(vidpid)) {
    2.58 +        return SDL_JOYSTICK_TYPE_THROTTLE;
    2.59 +    }
    2.60 +
    2.61      return SDL_JOYSTICK_TYPE_UNKNOWN;
    2.62  }
    2.63  
     3.1 --- a/test/testjoystick.c	Tue Jan 31 10:20:09 2017 -0800
     3.2 +++ b/test/testjoystick.c	Tue Jan 31 12:23:29 2017 -0800
     3.3 @@ -293,6 +293,9 @@
     3.4              case SDL_JOYSTICK_TYPE_ARCADE_PAD:
     3.5                  type = "Arcade Pad";
     3.6                  break;
     3.7 +            case SDL_JOYSTICK_TYPE_THROTTLE:
     3.8 +                type = "Throttle";
     3.9 +                break;
    3.10              default:
    3.11                  type = "Unknown";
    3.12                  break;