Added the HOTAS Warthog as a flight stick
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c
index 448d6ad..af01932 100644
--- a/src/joystick/SDL_joystick.c
+++ b/src/joystick/SDL_joystick.c
@@ -966,7 +966,7 @@ static void SDL_GetJoystickGUIDInfo(SDL_JoystickGUID guid, Uint16 *vendor, Uint1
}
}
-static SDL_bool SDL_IsJoystickGUIDWheel(SDL_JoystickGUID guid)
+static SDL_bool SDL_IsJoystickGUIDWheel(Uint32 vidpid)
{
static Uint32 wheel_joysticks[] = {
MAKE_VIDPID(0x046d, 0xc294), /* Logitech generic wheel */
@@ -983,16 +983,25 @@ static SDL_bool SDL_IsJoystickGUIDWheel(SDL_JoystickGUID guid)
MAKE_VIDPID(0x044f, 0xb664), /* Thrustmaster TX (initial mode) */
MAKE_VIDPID(0x044f, 0xb669), /* Thrustmaster TX (active mode) */
};
- Uint16 vendor;
- Uint16 product;
- Uint32 id;
int i;
- SDL_GetJoystickGUIDInfo(guid, &vendor, &product, NULL);
- id = MAKE_VIDPID(vendor, product);
-
for (i = 0; i < SDL_arraysize(wheel_joysticks); ++i) {
- if (id == wheel_joysticks[i]) {
+ if (vidpid == wheel_joysticks[i]) {
+ return SDL_TRUE;
+ }
+ }
+ return SDL_FALSE;
+}
+
+static SDL_bool SDL_IsJoystickGUIDFlightStick(Uint32 vidpid)
+{
+ static Uint32 flightstick_joysticks[] = {
+ MAKE_VIDPID(0x044f, 0x0402), /* HOTAS Warthog */
+ };
+ int i;
+
+ for (i = 0; i < SDL_arraysize(flightstick_joysticks); ++i) {
+ if (vidpid == flightstick_joysticks[i]) {
return SDL_TRUE;
}
}
@@ -1001,6 +1010,10 @@ static SDL_bool SDL_IsJoystickGUIDWheel(SDL_JoystickGUID guid)
static SDL_JoystickType SDL_GetJoystickGUIDType(SDL_JoystickGUID guid)
{
+ Uint16 vendor;
+ Uint16 product;
+ Uint32 vidpid;
+
if (guid.data[14] == 'x') {
/* XInput GUID, get the type based on the XInput device subtype */
switch (guid.data[15]) {
@@ -1027,10 +1040,17 @@ static SDL_JoystickType SDL_GetJoystickGUIDType(SDL_JoystickGUID guid)
}
}
- if (SDL_IsJoystickGUIDWheel(guid)) {
+ SDL_GetJoystickGUIDInfo(guid, &vendor, &product, NULL);
+ vidpid = MAKE_VIDPID(vendor, product);
+
+ if (SDL_IsJoystickGUIDWheel(vidpid)) {
return SDL_JOYSTICK_TYPE_WHEEL;
}
+ if (SDL_IsJoystickGUIDFlightStick(vidpid)) {
+ return SDL_JOYSTICK_TYPE_FLIGHT_STICK;
+ }
+
return SDL_JOYSTICK_TYPE_UNKNOWN;
}
diff --git a/test/testjoystick.c b/test/testjoystick.c
index 358b729..ce3a222 100644
--- a/test/testjoystick.c
+++ b/test/testjoystick.c
@@ -239,7 +239,7 @@ WatchJoystick(SDL_Joystick * joystick)
int
main(int argc, char *argv[])
{
- const char *name;
+ const char *name, *type;
int i;
SDL_Joystick *joystick;
@@ -268,6 +268,36 @@ main(int argc, char *argv[])
SDL_assert(SDL_JoystickFromInstanceID(SDL_JoystickInstanceID(joystick)) == joystick);
SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(joystick),
guid, sizeof (guid));
+ switch (SDL_JoystickGetType(joystick)) {
+ case SDL_JOYSTICK_TYPE_GAMECONTROLLER:
+ type = "Game Controller";
+ break;
+ case SDL_JOYSTICK_TYPE_WHEEL:
+ type = "Wheel";
+ break;
+ case SDL_JOYSTICK_TYPE_ARCADE_STICK:
+ type = "Arcade Stick";
+ break;
+ case SDL_JOYSTICK_TYPE_FLIGHT_STICK:
+ type = "Flight Stick";
+ break;
+ case SDL_JOYSTICK_TYPE_DANCE_PAD:
+ type = "Dance Pad";
+ break;
+ case SDL_JOYSTICK_TYPE_GUITAR:
+ type = "Guitar";
+ break;
+ case SDL_JOYSTICK_TYPE_DRUM_KIT:
+ type = "Drum Kit";
+ break;
+ case SDL_JOYSTICK_TYPE_ARCADE_PAD:
+ type = "Arcade Pad";
+ break;
+ default:
+ type = "Unknown";
+ break;
+ }
+ SDL_Log(" type: %s\n", type);
SDL_Log(" axes: %d\n", SDL_JoystickNumAxes(joystick));
SDL_Log(" balls: %d\n", SDL_JoystickNumBalls(joystick));
SDL_Log(" hats: %d\n", SDL_JoystickNumHats(joystick));