| 124 | } |
| 125 | |
| 126 | void XInputDriver::initialize() { |
| 127 | xinputReport = { |
| 128 | .report_id = 0, |
| 129 | .report_size = XINPUT_ENDPOINT_SIZE, |
| 130 | .buttons1 = 0, |
| 131 | .buttons2 = 0, |
| 132 | .lt = 0, |
| 133 | .rt = 0, |
| 134 | .lx = GAMEPAD_JOYSTICK_MID, |
| 135 | .ly = GAMEPAD_JOYSTICK_MID, |
| 136 | .rx = GAMEPAD_JOYSTICK_MID, |
| 137 | .ry = GAMEPAD_JOYSTICK_MID, |
| 138 | ._reserved = { }, |
| 139 | }; |
| 140 | |
| 141 | GamepadOptions & gamepadOptions = Storage::getInstance().getGamepadOptions(); |
| 142 | deviceType = gamepadOptions.inputDeviceType; |
| 143 | |
| 144 | // controller type bindings |
| 145 | if (deviceType == InputModeDeviceType::INPUT_MODE_DEVICE_TYPE_WHEEL) { |
| 146 | // wheel |
| 147 | buttonGas = new GamepadButtonMapping(0); |
| 148 | buttonBrake = new GamepadButtonMapping(0); |
| 149 | buttonSteerLeft = new GamepadButtonMapping(0); |
| 150 | buttonSteerRight = new GamepadButtonMapping(0); |
| 151 | } else if (deviceType == InputModeDeviceType::INPUT_MODE_DEVICE_TYPE_GUITAR) { |
| 152 | // guitar |
| 153 | buttonFretGreen = new GamepadButtonMapping(0); |
| 154 | buttonFretRed = new GamepadButtonMapping(0); |
| 155 | buttonFretYellow = new GamepadButtonMapping(0); |
| 156 | buttonFretBlue = new GamepadButtonMapping(0); |
| 157 | buttonFretOrange = new GamepadButtonMapping(0); |
| 158 | buttonFretSoloGreen = new GamepadButtonMapping(0); |
| 159 | buttonFretSoloRed = new GamepadButtonMapping(0); |
| 160 | buttonFretSoloYellow = new GamepadButtonMapping(0); |
| 161 | buttonFretSoloBlue = new GamepadButtonMapping(0); |
| 162 | buttonFretSoloOrange = new GamepadButtonMapping(0); |
| 163 | buttonWhammy = new GamepadButtonMapping(0); |
| 164 | buttonTilt = new GamepadButtonMapping(0); |
| 165 | } else if (deviceType == InputModeDeviceType::INPUT_MODE_DEVICE_TYPE_DRUM) { |
| 166 | // drum |
| 167 | buttonDrumPadRed = new GamepadButtonMapping(0); |
| 168 | buttonDrumPadBlue = new GamepadButtonMapping(0); |
| 169 | buttonDrumPadYellow = new GamepadButtonMapping(0); |
| 170 | buttonDrumPadGreen = new GamepadButtonMapping(0); |
| 171 | buttonCymbalYellow = new GamepadButtonMapping(0); |
| 172 | buttonCymbalBlue = new GamepadButtonMapping(0); |
| 173 | buttonCymbalGreen = new GamepadButtonMapping(0); |
| 174 | buttonKickPedalLeft = new GamepadButtonMapping(0); |
| 175 | buttonKickPedalRight = new GamepadButtonMapping(0); |
| 176 | } else { |
| 177 | // assume gamepad if not special cased |
| 178 | } |
| 179 | |
| 180 | GpioMappingInfo* pinMappings = Storage::getInstance().getProfilePinMappings(); |
| 181 | for (Pin_t pin = 0; pin < (Pin_t)NUM_BANK0_GPIOS; pin++) { |
| 182 | switch (pinMappings[pin].action) { |
| 183 | case GpioAction::MODE_GUITAR_FRET_GREEN: buttonFretGreen->pinMask |= 1 << pin; break; |
no test coverage detected