|
4 | 4 | #include "utils/StringHelper.h"
|
5 | 5 | #include "libultraship/libultra/controller.h"
|
6 | 6 | #include "Context.h"
|
7 |
| -#include "controller/deviceindex/ShipDeviceIndexToSDLDeviceIndexMapping.h" |
8 | 7 |
|
9 | 8 | namespace Ship {
|
10 | 9 | std::shared_ptr<ControllerGyroMapping> GyroMappingFactory::CreateGyroMappingFromConfig(uint8_t portIndex,
|
@@ -46,66 +45,68 @@ std::shared_ptr<ControllerGyroMapping> GyroMappingFactory::CreateGyroMappingFrom
|
46 | 45 | std::shared_ptr<ControllerGyroMapping> GyroMappingFactory::CreateGyroMappingFromSDLInput(uint8_t portIndex) {
|
47 | 46 | std::unordered_map<PhysicalDeviceType, SDL_GameController*> sdlControllersWithGyro;
|
48 | 47 | std::shared_ptr<ControllerGyroMapping> mapping = nullptr;
|
49 |
| - for (auto [lusIndex, indexMapping] : |
50 |
| - Context::GetInstance()->GetControlDeck()->GetDeviceIndexMappingManager()->GetAllDeviceIndexMappings()) { |
51 |
| - auto sdlIndexMapping = std::dynamic_pointer_cast<ShipDeviceIndexToSDLDeviceIndexMapping>(indexMapping); |
52 | 48 |
|
53 |
| - if (sdlIndexMapping == nullptr) { |
54 |
| - // this LUS index isn't mapped to an SDL index |
55 |
| - continue; |
56 |
| - } |
57 |
| - |
58 |
| - auto sdlIndex = sdlIndexMapping->GetSDLDeviceIndex(); |
59 |
| - |
60 |
| - if (!SDL_IsGameController(sdlIndex)) { |
61 |
| - // this SDL device isn't a game controller |
62 |
| - continue; |
63 |
| - } |
64 |
| - |
65 |
| - auto controller = SDL_GameControllerOpen(sdlIndex); |
66 |
| - if (SDL_GameControllerHasSensor(controller, SDL_SENSOR_GYRO)) { |
67 |
| - sdlControllersWithGyro[lusIndex] = SDL_GameControllerOpen(sdlIndex); |
68 |
| - } else { |
69 |
| - SDL_GameControllerClose(controller); |
70 |
| - } |
71 |
| - } |
72 |
| - |
73 |
| - for (auto [lusIndex, controller] : sdlControllersWithGyro) { |
74 |
| - for (int32_t button = SDL_CONTROLLER_BUTTON_A; button < SDL_CONTROLLER_BUTTON_MAX; button++) { |
75 |
| - if (SDL_GameControllerGetButton(controller, static_cast<SDL_GameControllerButton>(button))) { |
76 |
| - mapping = std::make_shared<SDLGyroMapping>(portIndex, 1.0f, 0.0f, 0.0f, 0.0f); |
77 |
| - mapping->Recalibrate(); |
78 |
| - break; |
79 |
| - } |
80 |
| - } |
81 |
| - |
82 |
| - if (mapping != nullptr) { |
83 |
| - break; |
84 |
| - } |
85 |
| - |
86 |
| - for (int32_t i = SDL_CONTROLLER_AXIS_LEFTX; i < SDL_CONTROLLER_AXIS_MAX; i++) { |
87 |
| - const auto axis = static_cast<SDL_GameControllerAxis>(i); |
88 |
| - const auto axisValue = SDL_GameControllerGetAxis(controller, axis) / 32767.0f; |
89 |
| - int32_t axisDirection = 0; |
90 |
| - if (axisValue < -0.7f) { |
91 |
| - axisDirection = NEGATIVE; |
92 |
| - } else if (axisValue > 0.7f) { |
93 |
| - axisDirection = POSITIVE; |
94 |
| - } |
95 |
| - |
96 |
| - if (axisDirection == 0) { |
97 |
| - continue; |
98 |
| - } |
99 |
| - |
100 |
| - mapping = std::make_shared<SDLGyroMapping>(portIndex, 1.0f, 0.0f, 0.0f, 0.0f); |
101 |
| - mapping->Recalibrate(); |
102 |
| - break; |
103 |
| - } |
104 |
| - } |
105 |
| - |
106 |
| - for (auto [i, controller] : sdlControllersWithGyro) { |
107 |
| - SDL_GameControllerClose(controller); |
108 |
| - } |
| 49 | + // todo: gyro |
| 50 | + // for (auto [lusIndex, indexMapping] : |
| 51 | + // Context::GetInstance()->GetControlDeck()->GetDeviceIndexMappingManager()->GetAllDeviceIndexMappings()) { |
| 52 | + // auto sdlIndexMapping = std::dynamic_pointer_cast<ShipDeviceIndexToSDLDeviceIndexMapping>(indexMapping); |
| 53 | + |
| 54 | + // if (sdlIndexMapping == nullptr) { |
| 55 | + // // this LUS index isn't mapped to an SDL index |
| 56 | + // continue; |
| 57 | + // } |
| 58 | + |
| 59 | + // auto sdlIndex = sdlIndexMapping->GetSDLDeviceIndex(); |
| 60 | + |
| 61 | + // if (!SDL_IsGameController(sdlIndex)) { |
| 62 | + // // this SDL device isn't a game controller |
| 63 | + // continue; |
| 64 | + // } |
| 65 | + |
| 66 | + // auto controller = SDL_GameControllerOpen(sdlIndex); |
| 67 | + // if (SDL_GameControllerHasSensor(controller, SDL_SENSOR_GYRO)) { |
| 68 | + // sdlControllersWithGyro[lusIndex] = SDL_GameControllerOpen(sdlIndex); |
| 69 | + // } else { |
| 70 | + // SDL_GameControllerClose(controller); |
| 71 | + // } |
| 72 | + // } |
| 73 | + |
| 74 | + // for (auto [lusIndex, controller] : sdlControllersWithGyro) { |
| 75 | + // for (int32_t button = SDL_CONTROLLER_BUTTON_A; button < SDL_CONTROLLER_BUTTON_MAX; button++) { |
| 76 | + // if (SDL_GameControllerGetButton(controller, static_cast<SDL_GameControllerButton>(button))) { |
| 77 | + // mapping = std::make_shared<SDLGyroMapping>(portIndex, 1.0f, 0.0f, 0.0f, 0.0f); |
| 78 | + // mapping->Recalibrate(); |
| 79 | + // break; |
| 80 | + // } |
| 81 | + // } |
| 82 | + |
| 83 | + // if (mapping != nullptr) { |
| 84 | + // break; |
| 85 | + // } |
| 86 | + |
| 87 | + // for (int32_t i = SDL_CONTROLLER_AXIS_LEFTX; i < SDL_CONTROLLER_AXIS_MAX; i++) { |
| 88 | + // const auto axis = static_cast<SDL_GameControllerAxis>(i); |
| 89 | + // const auto axisValue = SDL_GameControllerGetAxis(controller, axis) / 32767.0f; |
| 90 | + // int32_t axisDirection = 0; |
| 91 | + // if (axisValue < -0.7f) { |
| 92 | + // axisDirection = NEGATIVE; |
| 93 | + // } else if (axisValue > 0.7f) { |
| 94 | + // axisDirection = POSITIVE; |
| 95 | + // } |
| 96 | + |
| 97 | + // if (axisDirection == 0) { |
| 98 | + // continue; |
| 99 | + // } |
| 100 | + |
| 101 | + // mapping = std::make_shared<SDLGyroMapping>(portIndex, 1.0f, 0.0f, 0.0f, 0.0f); |
| 102 | + // mapping->Recalibrate(); |
| 103 | + // break; |
| 104 | + // } |
| 105 | + // } |
| 106 | + |
| 107 | + // for (auto [i, controller] : sdlControllersWithGyro) { |
| 108 | + // SDL_GameControllerClose(controller); |
| 109 | + // } |
109 | 110 |
|
110 | 111 | return mapping;
|
111 | 112 | }
|
|
0 commit comments