summaryrefslogtreecommitdiff
path: root/src/setup/joystick.c
diff options
context:
space:
mode:
authorSimon Howard2014-05-03 23:19:41 -0400
committerSimon Howard2014-05-03 23:19:41 -0400
commit9ec075b0249b8b63bb5725551d2cbf95f8b0bd9d (patch)
tree72841926cd91d6bb995d96946b71fc57780da88d /src/setup/joystick.c
parentf56a8ac302a9ef2f5ff668d13f20cb4bb787fab0 (diff)
downloadchocolate-doom-9ec075b0249b8b63bb5725551d2cbf95f8b0bd9d.tar.gz
chocolate-doom-9ec075b0249b8b63bb5725551d2cbf95f8b0bd9d.tar.bz2
chocolate-doom-9ec075b0249b8b63bb5725551d2cbf95f8b0bd9d.zip
setup: Add configuration for Wii remote.
The Wii remote is not a HID device, meaning it cannot be supported in a proper cross-platform way. However, it can be supported for individual platforms. Add a fingerprint and configuration for a Wii remote under OS X using the WJoy tool.
Diffstat (limited to 'src/setup/joystick.c')
-rw-r--r--src/setup/joystick.c45
1 files changed, 43 insertions, 2 deletions
diff --git a/src/setup/joystick.c b/src/setup/joystick.c
index 725cc287..654041f7 100644
--- a/src/setup/joystick.c
+++ b/src/setup/joystick.c
@@ -198,6 +198,24 @@ static const joystick_config_t airflo_controller[] =
{NULL, 0},
};
+// Wii controller is weird, so we have to take some liberties.
+// Also it's not a HID device, so it won't appear the same everywhere.
+// Assume there is no nunchuk or classic controller attached.
+
+// When using WJoy on OS X.
+static const joystick_config_t wii_controller_wjoy[] =
+{
+ {"joystick_x_axis", CREATE_BUTTON_AXIS(2, 3)},
+ {"joystick_y_axis", CREATE_BUTTON_AXIS(1, 0)},
+ {"joyb_fire", 9}, // Button 1
+ {"joyb_speed", 10}, // Button 2
+ {"joyb_use", 5}, // Button B (trigger)
+ {"joyb_prevweapon", 7}, // -
+ {"joyb_nextweapon", 6}, // +
+ {"joyb_menu_activate", 9}, // Button A
+ {NULL, 0},
+};
+
static const known_joystick_t known_joysticks[] =
{
{
@@ -211,6 +229,12 @@ static const known_joystick_t known_joysticks[] =
4, 13, 1,
airflo_controller,
},
+
+ {
+ "Wiimote (*", // WJoy includes the Wiimote MAC address.
+ 6, 26, 0,
+ wii_controller_wjoy,
+ },
};
static const known_joystick_t *GetJoystickType(int index)
@@ -228,8 +252,25 @@ static const known_joystick_t *GetJoystickType(int index)
for (i = 0; i < arrlen(known_joysticks); ++i)
{
- if (!strcmp(known_joysticks[i].name, name)
- && known_joysticks[i].axes == axes
+ // Check for a name match. If the name ends in '*', this means
+ // ignore the rest.
+ if (M_StringEndsWith(known_joysticks[i].name, "*"))
+ {
+ if (strncmp(known_joysticks[i].name, name,
+ strlen(known_joysticks[i].name) - 1) != 0)
+ {
+ continue;
+ }
+ }
+ else
+ {
+ if (strcmp(known_joysticks[i].name, name) != 0)
+ {
+ continue;
+ }
+ }
+
+ if (known_joysticks[i].axes == axes
&& known_joysticks[i].buttons == buttons
&& known_joysticks[i].hats == hats)
{