|
8 | 8 | #include "controller/controldevice/controller/mapping/mouse/MouseWheelToButtonMapping.h"
|
9 | 9 | #include "controller/controldevice/controller/mapping/sdl/SDLButtonToButtonMapping.h"
|
10 | 10 | #include "controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToButtonMapping.h"
|
11 |
| -#include "controller/deviceindex/ShipDeviceIndexToSDLDeviceIndexMapping.h" |
12 | 11 | #include "controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h"
|
13 | 12 | #include "controller/controldevice/controller/mapping/mouse/WheelHandler.h"
|
| 13 | +#include <cstdint> |
| 14 | +#include <memory> |
14 | 15 |
|
15 | 16 | namespace Ship {
|
16 | 17 | std::shared_ptr<ControllerButtonMapping> ButtonMappingFactory::CreateButtonMappingFromConfig(uint8_t portIndex,
|
@@ -154,90 +155,63 @@ ButtonMappingFactory::CreateDefaultKeyboardButtonMappings(uint8_t portIndex, CON
|
154 | 155 | }
|
155 | 156 |
|
156 | 157 | std::vector<std::shared_ptr<ControllerButtonMapping>>
|
157 |
| -ButtonMappingFactory::CreateDefaultSDLButtonMappings(ShipDeviceIndex shipDeviceIndex, uint8_t portIndex, |
| 158 | +ButtonMappingFactory::CreateDefaultSDLButtonMappings(uint8_t portIndex, |
158 | 159 | CONTROLLERBUTTONS_T bitmask) {
|
159 | 160 | std::vector<std::shared_ptr<ControllerButtonMapping>> mappings;
|
160 | 161 |
|
161 |
| - auto sdlIndexMapping = std::dynamic_pointer_cast<ShipDeviceIndexToSDLDeviceIndexMapping>( |
162 |
| - Context::GetInstance() |
163 |
| - ->GetControlDeck() |
164 |
| - ->GetDeviceIndexMappingManager() |
165 |
| - ->GetDeviceIndexMappingFromShipDeviceIndex(shipDeviceIndex)); |
166 |
| - if (sdlIndexMapping == nullptr) { |
167 |
| - return std::vector<std::shared_ptr<ControllerButtonMapping>>(); |
168 |
| - } |
169 |
| - |
170 |
| - bool isGameCube = sdlIndexMapping->GetSDLControllerName() == "Nintendo GameCube Controller"; |
171 |
| - |
172 | 162 | switch (bitmask) {
|
173 | 163 | case BTN_A:
|
174 | 164 | mappings.push_back(
|
175 |
| - std::make_shared<SDLButtonToButtonMapping>(shipDeviceIndex, portIndex, BTN_A, SDL_CONTROLLER_BUTTON_A)); |
| 165 | + std::make_shared<SDLButtonToButtonMapping>(portIndex, BTN_A, SDL_CONTROLLER_BUTTON_A)); |
176 | 166 | break;
|
177 | 167 | case BTN_B:
|
178 | 168 | mappings.push_back(
|
179 |
| - std::make_shared<SDLButtonToButtonMapping>(shipDeviceIndex, portIndex, BTN_B, SDL_CONTROLLER_BUTTON_B)); |
| 169 | + std::make_shared<SDLButtonToButtonMapping>(portIndex, BTN_B, SDL_CONTROLLER_BUTTON_B)); |
180 | 170 | break;
|
181 | 171 | case BTN_L:
|
182 |
| - if (!isGameCube) { |
183 |
| - mappings.push_back(std::make_shared<SDLButtonToButtonMapping>(shipDeviceIndex, portIndex, BTN_L, |
184 |
| - SDL_CONTROLLER_BUTTON_LEFTSHOULDER)); |
185 |
| - } |
186 | 172 | break;
|
187 | 173 | case BTN_R:
|
188 |
| - mappings.push_back(std::make_shared<SDLAxisDirectionToButtonMapping>(shipDeviceIndex, portIndex, BTN_R, |
| 174 | + mappings.push_back(std::make_shared<SDLAxisDirectionToButtonMapping>(portIndex, BTN_R, |
189 | 175 | SDL_CONTROLLER_AXIS_TRIGGERRIGHT, 1));
|
190 | 176 | break;
|
191 | 177 | case BTN_Z:
|
192 |
| - mappings.push_back(std::make_shared<SDLAxisDirectionToButtonMapping>(shipDeviceIndex, portIndex, BTN_Z, |
| 178 | + mappings.push_back(std::make_shared<SDLAxisDirectionToButtonMapping>(portIndex, BTN_Z, |
193 | 179 | SDL_CONTROLLER_AXIS_TRIGGERLEFT, 1));
|
194 | 180 | break;
|
195 | 181 | case BTN_START:
|
196 |
| - mappings.push_back(std::make_shared<SDLButtonToButtonMapping>(shipDeviceIndex, portIndex, BTN_START, |
| 182 | + mappings.push_back(std::make_shared<SDLButtonToButtonMapping>(portIndex, BTN_START, |
197 | 183 | SDL_CONTROLLER_BUTTON_START));
|
198 | 184 | break;
|
199 | 185 | case BTN_CUP:
|
200 |
| - mappings.push_back(std::make_shared<SDLAxisDirectionToButtonMapping>(shipDeviceIndex, portIndex, BTN_CUP, |
| 186 | + mappings.push_back(std::make_shared<SDLAxisDirectionToButtonMapping>(portIndex, BTN_CUP, |
201 | 187 | SDL_CONTROLLER_AXIS_RIGHTY, -1));
|
202 | 188 | break;
|
203 | 189 | case BTN_CDOWN:
|
204 |
| - mappings.push_back(std::make_shared<SDLAxisDirectionToButtonMapping>(shipDeviceIndex, portIndex, BTN_CDOWN, |
| 190 | + mappings.push_back(std::make_shared<SDLAxisDirectionToButtonMapping>(portIndex, BTN_CDOWN, |
205 | 191 | SDL_CONTROLLER_AXIS_RIGHTY, 1));
|
206 |
| - if (isGameCube) { |
207 |
| - mappings.push_back(std::make_shared<SDLButtonToButtonMapping>(shipDeviceIndex, portIndex, BTN_CDOWN, |
208 |
| - SDL_CONTROLLER_BUTTON_RIGHTSHOULDER)); |
209 |
| - } |
210 | 192 | break;
|
211 | 193 | case BTN_CLEFT:
|
212 |
| - mappings.push_back(std::make_shared<SDLAxisDirectionToButtonMapping>(shipDeviceIndex, portIndex, BTN_CLEFT, |
| 194 | + mappings.push_back(std::make_shared<SDLAxisDirectionToButtonMapping>(portIndex, BTN_CLEFT, |
213 | 195 | SDL_CONTROLLER_AXIS_RIGHTX, -1));
|
214 |
| - if (isGameCube) { |
215 |
| - mappings.push_back(std::make_shared<SDLButtonToButtonMapping>(shipDeviceIndex, portIndex, BTN_CLEFT, |
216 |
| - SDL_CONTROLLER_BUTTON_Y)); |
217 |
| - } |
218 | 196 | break;
|
219 | 197 | case BTN_CRIGHT:
|
220 |
| - mappings.push_back(std::make_shared<SDLAxisDirectionToButtonMapping>(shipDeviceIndex, portIndex, BTN_CRIGHT, |
| 198 | + mappings.push_back(std::make_shared<SDLAxisDirectionToButtonMapping>(portIndex, BTN_CRIGHT, |
221 | 199 | SDL_CONTROLLER_AXIS_RIGHTX, 1));
|
222 |
| - if (isGameCube) { |
223 |
| - mappings.push_back(std::make_shared<SDLButtonToButtonMapping>(shipDeviceIndex, portIndex, BTN_CRIGHT, |
224 |
| - SDL_CONTROLLER_BUTTON_X)); |
225 |
| - } |
226 | 200 | break;
|
227 | 201 | case BTN_DUP:
|
228 |
| - mappings.push_back(std::make_shared<SDLButtonToButtonMapping>(shipDeviceIndex, portIndex, BTN_DUP, |
| 202 | + mappings.push_back(std::make_shared<SDLButtonToButtonMapping>(portIndex, BTN_DUP, |
229 | 203 | SDL_CONTROLLER_BUTTON_DPAD_UP));
|
230 | 204 | break;
|
231 | 205 | case BTN_DDOWN:
|
232 |
| - mappings.push_back(std::make_shared<SDLButtonToButtonMapping>(shipDeviceIndex, portIndex, BTN_DDOWN, |
| 206 | + mappings.push_back(std::make_shared<SDLButtonToButtonMapping>(portIndex, BTN_DDOWN, |
233 | 207 | SDL_CONTROLLER_BUTTON_DPAD_DOWN));
|
234 | 208 | break;
|
235 | 209 | case BTN_DLEFT:
|
236 |
| - mappings.push_back(std::make_shared<SDLButtonToButtonMapping>(shipDeviceIndex, portIndex, BTN_DLEFT, |
| 210 | + mappings.push_back(std::make_shared<SDLButtonToButtonMapping>(portIndex, BTN_DLEFT, |
237 | 211 | SDL_CONTROLLER_BUTTON_DPAD_LEFT));
|
238 | 212 | break;
|
239 | 213 | case BTN_DRIGHT:
|
240 |
| - mappings.push_back(std::make_shared<SDLButtonToButtonMapping>(shipDeviceIndex, portIndex, BTN_DRIGHT, |
| 214 | + mappings.push_back(std::make_shared<SDLButtonToButtonMapping>(portIndex, BTN_DRIGHT, |
241 | 215 | SDL_CONTROLLER_BUTTON_DPAD_RIGHT));
|
242 | 216 | break;
|
243 | 217 | }
|
|
0 commit comments