mirror of
				https://github.com/libsdl-org/SDL.git
				synced 2025-10-26 12:27:44 +00:00 
			
		
		
		
	Added support for the HOTAS Warthog throttle
This commit is contained in:
		| @@ -83,7 +83,8 @@ typedef enum | |||||||
|     SDL_JOYSTICK_TYPE_DANCE_PAD, |     SDL_JOYSTICK_TYPE_DANCE_PAD, | ||||||
|     SDL_JOYSTICK_TYPE_GUITAR, |     SDL_JOYSTICK_TYPE_GUITAR, | ||||||
|     SDL_JOYSTICK_TYPE_DRUM_KIT, |     SDL_JOYSTICK_TYPE_DRUM_KIT, | ||||||
|     SDL_JOYSTICK_TYPE_ARCADE_PAD |     SDL_JOYSTICK_TYPE_ARCADE_PAD, | ||||||
|  | 	SDL_JOYSTICK_TYPE_THROTTLE, | ||||||
| } SDL_JoystickType; | } SDL_JoystickType; | ||||||
|  |  | ||||||
| typedef enum | typedef enum | ||||||
|   | |||||||
| @@ -966,7 +966,7 @@ static void SDL_GetJoystickGUIDInfo(SDL_JoystickGUID guid, Uint16 *vendor, Uint1 | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| static SDL_bool SDL_IsJoystickGUIDWheel(Uint32 vidpid) | static SDL_bool SDL_IsJoystickProductWheel(Uint32 vidpid) | ||||||
| { | { | ||||||
|     static Uint32 wheel_joysticks[] = { |     static Uint32 wheel_joysticks[] = { | ||||||
|         MAKE_VIDPID(0x046d, 0xc294),    /* Logitech generic wheel */ |         MAKE_VIDPID(0x046d, 0xc294),    /* Logitech generic wheel */ | ||||||
| @@ -993,7 +993,7 @@ static SDL_bool SDL_IsJoystickGUIDWheel(Uint32 vidpid) | |||||||
|     return SDL_FALSE; |     return SDL_FALSE; | ||||||
| } | } | ||||||
|  |  | ||||||
| static SDL_bool SDL_IsJoystickGUIDFlightStick(Uint32 vidpid) | static SDL_bool SDL_IsJoystickProductFlightStick(Uint32 vidpid) | ||||||
| { | { | ||||||
|     static Uint32 flightstick_joysticks[] = { |     static Uint32 flightstick_joysticks[] = { | ||||||
|         MAKE_VIDPID(0x044f, 0x0402),    /* HOTAS Warthog */ |         MAKE_VIDPID(0x044f, 0x0402),    /* HOTAS Warthog */ | ||||||
| @@ -1008,6 +1008,21 @@ static SDL_bool SDL_IsJoystickGUIDFlightStick(Uint32 vidpid) | |||||||
|     return SDL_FALSE; |     return SDL_FALSE; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | static SDL_bool SDL_IsJoystickProductThrottle(Uint32 vidpid) | ||||||
|  | { | ||||||
|  |     static Uint32 throttle_joysticks[] = { | ||||||
|  |         MAKE_VIDPID(0x044f, 0x0404),    /* HOTAS Warthog */ | ||||||
|  |     }; | ||||||
|  |     int i; | ||||||
|  |  | ||||||
|  |     for (i = 0; i < SDL_arraysize(throttle_joysticks); ++i) { | ||||||
|  |         if (vidpid == throttle_joysticks[i]) { | ||||||
|  |             return SDL_TRUE; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |     return SDL_FALSE; | ||||||
|  | } | ||||||
|  |  | ||||||
| static SDL_JoystickType SDL_GetJoystickGUIDType(SDL_JoystickGUID guid) | static SDL_JoystickType SDL_GetJoystickGUIDType(SDL_JoystickGUID guid) | ||||||
| { | { | ||||||
|     Uint16 vendor; |     Uint16 vendor; | ||||||
| @@ -1043,14 +1058,18 @@ static SDL_JoystickType SDL_GetJoystickGUIDType(SDL_JoystickGUID guid) | |||||||
|     SDL_GetJoystickGUIDInfo(guid, &vendor, &product, NULL); |     SDL_GetJoystickGUIDInfo(guid, &vendor, &product, NULL); | ||||||
|     vidpid = MAKE_VIDPID(vendor, product); |     vidpid = MAKE_VIDPID(vendor, product); | ||||||
|  |  | ||||||
|     if (SDL_IsJoystickGUIDWheel(vidpid)) { |     if (SDL_IsJoystickProductWheel(vidpid)) { | ||||||
|         return SDL_JOYSTICK_TYPE_WHEEL; |         return SDL_JOYSTICK_TYPE_WHEEL; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (SDL_IsJoystickGUIDFlightStick(vidpid)) { |     if (SDL_IsJoystickProductFlightStick(vidpid)) { | ||||||
|         return SDL_JOYSTICK_TYPE_FLIGHT_STICK; |         return SDL_JOYSTICK_TYPE_FLIGHT_STICK; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     if (SDL_IsJoystickProductThrottle(vidpid)) { | ||||||
|  |         return SDL_JOYSTICK_TYPE_THROTTLE; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     return SDL_JOYSTICK_TYPE_UNKNOWN; |     return SDL_JOYSTICK_TYPE_UNKNOWN; | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -293,6 +293,9 @@ main(int argc, char *argv[]) | |||||||
|             case SDL_JOYSTICK_TYPE_ARCADE_PAD: |             case SDL_JOYSTICK_TYPE_ARCADE_PAD: | ||||||
|                 type = "Arcade Pad"; |                 type = "Arcade Pad"; | ||||||
|                 break; |                 break; | ||||||
|  |             case SDL_JOYSTICK_TYPE_THROTTLE: | ||||||
|  |                 type = "Throttle"; | ||||||
|  |                 break; | ||||||
|             default: |             default: | ||||||
|                 type = "Unknown"; |                 type = "Unknown"; | ||||||
|                 break; |                 break; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Sam Lantinga
					Sam Lantinga