]> git.lizzy.rs Git - dragonfireclient.git/commitdiff
Add joystick layout for DragonRise GameCube controller (#11467)
authorIsabelle COWAN-BERGMAN <Izzette@users.noreply.github.com>
Sun, 31 Oct 2021 18:17:47 +0000 (19:17 +0100)
committerGitHub <noreply@github.com>
Sun, 31 Oct 2021 18:17:47 +0000 (19:17 +0100)
builtin/settingtypes.txt
src/client/joystick_controller.cpp

index af4f5eaa68cb19965e30b89526185409325d47d8..81ebef67d1c59c0a62460c2e7b6569e7331ef957 100644 (file)
@@ -146,7 +146,7 @@ enable_joysticks (Enable joysticks) bool false
 joystick_id (Joystick ID) int 0
 
 #    The type of joystick
-joystick_type (Joystick type) enum auto auto,generic,xbox
+joystick_type (Joystick type) enum auto auto,generic,xbox,dragonrise_gamecube
 
 #    The time in seconds it takes between repeated events
 #    when holding down a joystick button combination.
index 630565d8db41c42444c5db2ebb4219dbab355d13..aae73c62d205c783c5e4d038709e331bf2eefdb0 100644 (file)
@@ -154,6 +154,54 @@ JoystickLayout create_xbox_layout()
        return jlo;
 }
 
+JoystickLayout create_dragonrise_gamecube_layout()
+{
+       JoystickLayout jlo;
+
+       jlo.axes_deadzone = 7000;
+
+       const JoystickAxisLayout axes[JA_COUNT] = {
+               // Control Stick
+               {0, 1}, // JA_SIDEWARD_MOVE
+               {1, 1}, // JA_FORWARD_MOVE
+
+               // C-Stick
+               {3, 1}, // JA_FRUSTUM_HORIZONTAL
+               {4, 1}, // JA_FRUSTUM_VERTICAL
+       };
+       memcpy(jlo.axes, axes, sizeof(jlo.axes));
+
+       // The center button
+       JLO_B_PB(KeyType::ESC, 1 << 9, 1 << 9); // Start/Pause Button
+
+       // Front right buttons
+       JLO_B_PB(KeyType::JUMP,  1 << 2, 1 << 2); // A Button
+       JLO_B_PB(KeyType::SNEAK, 1 << 3, 1 << 3); // B Button
+       JLO_B_PB(KeyType::DROP,  1 << 0, 1 << 0); // Y Button
+       JLO_B_PB(KeyType::AUX1,  1 << 1, 1 << 1); // X Button
+
+       // Triggers
+       JLO_B_PB(KeyType::DIG,       1 << 4, 1 << 4); // L Trigger
+       JLO_B_PB(KeyType::PLACE,     1 << 5, 1 << 5); // R Trigger
+       JLO_B_PB(KeyType::INVENTORY, 1 << 6, 1 << 6); // Z Button
+
+       // D-Pad
+       JLO_A_PB(KeyType::HOTBAR_PREV, 5,  1, jlo.axes_deadzone); // left
+       JLO_A_PB(KeyType::HOTBAR_NEXT, 5, -1, jlo.axes_deadzone); // right
+       // Axis are hard to actuate independantly, best to leave up and down unused.
+       //JLO_A_PB(0, 6,  1, jlo.axes_deadzone); // up
+       //JLO_A_PB(0, 6, -1, jlo.axes_deadzone); // down
+
+       // Movements tied to Control Stick, important for vessels
+       JLO_A_PB(KeyType::LEFT,     0,  1, jlo.axes_deadzone);
+       JLO_A_PB(KeyType::RIGHT,    0, -1, jlo.axes_deadzone);
+       JLO_A_PB(KeyType::FORWARD,  1,  1, jlo.axes_deadzone);
+       JLO_A_PB(KeyType::BACKWARD, 1, -1, jlo.axes_deadzone);
+
+       return jlo;
+}
+
+
 JoystickController::JoystickController() :
                doubling_dtime(g_settings->getFloat("repeat_joystick_button_time"))
 {
@@ -188,6 +236,8 @@ void JoystickController::setLayoutFromControllerName(const std::string &name)
 {
        if (lowercase(name).find("xbox") != std::string::npos) {
                m_layout = create_xbox_layout();
+       } else if (lowercase(name).find("dragonrise_gamecube") != std::string::npos) {
+               m_layout = create_dragonrise_gamecube_layout();
        } else {
                m_layout = create_default_layout();
        }