Skip to content

Commit 2bb7917

Browse files
committed
all sdl mappings are always ShipDeviceType::SDLGamepad
1 parent 03fa9c1 commit 2bb7917

25 files changed

+73
-74
lines changed

src/controller/controldevice/controller/mapping/factories/AxisDirectionMappingFactory.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ AxisDirectionMappingFactory::CreateAxisDirectionMappingFromConfig(uint8_t portIn
4040
}
4141

4242
return std::make_shared<SDLAxisDirectionToAxisDirectionMapping>(
43-
ShipDeviceType::SDLGamepad, portIndex, stickIndex, static_cast<Direction>(direction),
43+
portIndex, stickIndex, static_cast<Direction>(direction),
4444
sdlControllerAxis, axisDirection);
4545
}
4646

@@ -60,7 +60,7 @@ AxisDirectionMappingFactory::CreateAxisDirectionMappingFromConfig(uint8_t portIn
6060
}
6161

6262
return std::make_shared<SDLButtonToAxisDirectionMapping>(
63-
ShipDeviceType::SDLGamepad, portIndex, stickIndex, static_cast<Direction>(direction),
63+
portIndex, stickIndex, static_cast<Direction>(direction),
6464
sdlControllerButton);
6565
}
6666

@@ -142,13 +142,13 @@ AxisDirectionMappingFactory::CreateDefaultSDLAxisDirectionMappings(ShipDeviceTyp
142142
}
143143

144144
std::vector<std::shared_ptr<ControllerAxisDirectionMapping>> mappings = {
145-
std::make_shared<SDLAxisDirectionToAxisDirectionMapping>(shipDeviceIndex, portIndex, stickIndex, LEFT,
145+
std::make_shared<SDLAxisDirectionToAxisDirectionMapping>(portIndex, stickIndex, LEFT,
146146
stickIndex == LEFT_STICK ? 0 : 2, -1),
147-
std::make_shared<SDLAxisDirectionToAxisDirectionMapping>(shipDeviceIndex, portIndex, stickIndex, RIGHT,
147+
std::make_shared<SDLAxisDirectionToAxisDirectionMapping>(portIndex, stickIndex, RIGHT,
148148
stickIndex == LEFT_STICK ? 0 : 2, 1),
149-
std::make_shared<SDLAxisDirectionToAxisDirectionMapping>(shipDeviceIndex, portIndex, stickIndex, UP,
149+
std::make_shared<SDLAxisDirectionToAxisDirectionMapping>(portIndex, stickIndex, UP,
150150
stickIndex == LEFT_STICK ? 1 : 3, -1),
151-
std::make_shared<SDLAxisDirectionToAxisDirectionMapping>(shipDeviceIndex, portIndex, stickIndex, DOWN,
151+
std::make_shared<SDLAxisDirectionToAxisDirectionMapping>(portIndex, stickIndex, DOWN,
152152
stickIndex == LEFT_STICK ? 1 : 3, 1)
153153
};
154154

@@ -182,7 +182,7 @@ AxisDirectionMappingFactory::CreateAxisDirectionMappingFromSDLInput(uint8_t port
182182
for (auto [lusIndex, controller] : sdlControllers) {
183183
for (int32_t button = SDL_CONTROLLER_BUTTON_A; button < SDL_CONTROLLER_BUTTON_MAX; button++) {
184184
if (SDL_GameControllerGetButton(controller, static_cast<SDL_GameControllerButton>(button))) {
185-
mapping = std::make_shared<SDLButtonToAxisDirectionMapping>(lusIndex, portIndex, stickIndex, direction,
185+
mapping = std::make_shared<SDLButtonToAxisDirectionMapping>(portIndex, stickIndex, direction,
186186
button);
187187
break;
188188
}
@@ -206,7 +206,7 @@ AxisDirectionMappingFactory::CreateAxisDirectionMappingFromSDLInput(uint8_t port
206206
continue;
207207
}
208208

209-
mapping = std::make_shared<SDLAxisDirectionToAxisDirectionMapping>(lusIndex, portIndex, stickIndex,
209+
mapping = std::make_shared<SDLAxisDirectionToAxisDirectionMapping>(portIndex, stickIndex,
210210
direction, axis, axisDirection);
211211
break;
212212
}

src/controller/controldevice/controller/mapping/factories/ButtonMappingFactory.cpp

+18-18
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ std::shared_ptr<ControllerButtonMapping> ButtonMappingFactory::CreateButtonMappi
4040
return nullptr;
4141
}
4242

43-
return std::make_shared<SDLButtonToButtonMapping>(static_cast<ShipDeviceType>(shipDeviceIndex), portIndex,
43+
return std::make_shared<SDLButtonToButtonMapping>(portIndex,
4444
bitmask, sdlControllerButton);
4545
}
4646

@@ -59,7 +59,7 @@ std::shared_ptr<ControllerButtonMapping> ButtonMappingFactory::CreateButtonMappi
5959
return nullptr;
6060
}
6161

62-
return std::make_shared<SDLAxisDirectionToButtonMapping>(static_cast<ShipDeviceType>(shipDeviceIndex),
62+
return std::make_shared<SDLAxisDirectionToButtonMapping>(
6363
portIndex, bitmask, sdlControllerAxis, axisDirection);
6464
}
6565

@@ -161,58 +161,58 @@ ButtonMappingFactory::CreateDefaultSDLButtonMappings(uint8_t portIndex,
161161
switch (bitmask) {
162162
case BTN_A:
163163
mappings.push_back(
164-
std::make_shared<SDLButtonToButtonMapping>(ShipDeviceType::SDLGamepad, portIndex, BTN_A, SDL_CONTROLLER_BUTTON_A));
164+
std::make_shared<SDLButtonToButtonMapping>(portIndex, BTN_A, SDL_CONTROLLER_BUTTON_A));
165165
break;
166166
case BTN_B:
167167
mappings.push_back(
168-
std::make_shared<SDLButtonToButtonMapping>(ShipDeviceType::SDLGamepad, portIndex, BTN_B, SDL_CONTROLLER_BUTTON_B));
168+
std::make_shared<SDLButtonToButtonMapping>(portIndex, BTN_B, SDL_CONTROLLER_BUTTON_B));
169169
break;
170170
case BTN_L:
171-
mappings.push_back(std::make_shared<SDLButtonToButtonMapping>(ShipDeviceType::SDLGamepad, portIndex, BTN_L,
171+
mappings.push_back(std::make_shared<SDLButtonToButtonMapping>( portIndex, BTN_L,
172172
SDL_CONTROLLER_BUTTON_LEFTSHOULDER));
173173
break;
174174
case BTN_R:
175-
mappings.push_back(std::make_shared<SDLAxisDirectionToButtonMapping>(ShipDeviceType::SDLGamepad, portIndex, BTN_R,
175+
mappings.push_back(std::make_shared<SDLAxisDirectionToButtonMapping>( portIndex, BTN_R,
176176
SDL_CONTROLLER_AXIS_TRIGGERRIGHT, 1));
177177
break;
178178
case BTN_Z:
179-
mappings.push_back(std::make_shared<SDLAxisDirectionToButtonMapping>(ShipDeviceType::SDLGamepad, portIndex, BTN_Z,
179+
mappings.push_back(std::make_shared<SDLAxisDirectionToButtonMapping>( portIndex, BTN_Z,
180180
SDL_CONTROLLER_AXIS_TRIGGERLEFT, 1));
181181
break;
182182
case BTN_START:
183-
mappings.push_back(std::make_shared<SDLButtonToButtonMapping>(ShipDeviceType::SDLGamepad, portIndex, BTN_START,
183+
mappings.push_back(std::make_shared<SDLButtonToButtonMapping>( portIndex, BTN_START,
184184
SDL_CONTROLLER_BUTTON_START));
185185
break;
186186
case BTN_CUP:
187-
mappings.push_back(std::make_shared<SDLAxisDirectionToButtonMapping>(ShipDeviceType::SDLGamepad, portIndex, BTN_CUP,
187+
mappings.push_back(std::make_shared<SDLAxisDirectionToButtonMapping>( portIndex, BTN_CUP,
188188
SDL_CONTROLLER_AXIS_RIGHTY, -1));
189189
break;
190190
case BTN_CDOWN:
191-
mappings.push_back(std::make_shared<SDLAxisDirectionToButtonMapping>(ShipDeviceType::SDLGamepad, portIndex, BTN_CDOWN,
191+
mappings.push_back(std::make_shared<SDLAxisDirectionToButtonMapping>( portIndex, BTN_CDOWN,
192192
SDL_CONTROLLER_AXIS_RIGHTY, 1));
193193
break;
194194
case BTN_CLEFT:
195-
mappings.push_back(std::make_shared<SDLAxisDirectionToButtonMapping>(ShipDeviceType::SDLGamepad, portIndex, BTN_CLEFT,
195+
mappings.push_back(std::make_shared<SDLAxisDirectionToButtonMapping>( portIndex, BTN_CLEFT,
196196
SDL_CONTROLLER_AXIS_RIGHTX, -1));
197197
break;
198198
case BTN_CRIGHT:
199-
mappings.push_back(std::make_shared<SDLAxisDirectionToButtonMapping>(ShipDeviceType::SDLGamepad, portIndex, BTN_CRIGHT,
199+
mappings.push_back(std::make_shared<SDLAxisDirectionToButtonMapping>( portIndex, BTN_CRIGHT,
200200
SDL_CONTROLLER_AXIS_RIGHTX, 1));
201201
break;
202202
case BTN_DUP:
203-
mappings.push_back(std::make_shared<SDLButtonToButtonMapping>(ShipDeviceType::SDLGamepad, portIndex, BTN_DUP,
203+
mappings.push_back(std::make_shared<SDLButtonToButtonMapping>( portIndex, BTN_DUP,
204204
SDL_CONTROLLER_BUTTON_DPAD_UP));
205205
break;
206206
case BTN_DDOWN:
207-
mappings.push_back(std::make_shared<SDLButtonToButtonMapping>(ShipDeviceType::SDLGamepad, portIndex, BTN_DDOWN,
207+
mappings.push_back(std::make_shared<SDLButtonToButtonMapping>( portIndex, BTN_DDOWN,
208208
SDL_CONTROLLER_BUTTON_DPAD_DOWN));
209209
break;
210210
case BTN_DLEFT:
211-
mappings.push_back(std::make_shared<SDLButtonToButtonMapping>(ShipDeviceType::SDLGamepad, portIndex, BTN_DLEFT,
211+
mappings.push_back(std::make_shared<SDLButtonToButtonMapping>( portIndex, BTN_DLEFT,
212212
SDL_CONTROLLER_BUTTON_DPAD_LEFT));
213213
break;
214214
case BTN_DRIGHT:
215-
mappings.push_back(std::make_shared<SDLButtonToButtonMapping>(ShipDeviceType::SDLGamepad, portIndex, BTN_DRIGHT,
215+
mappings.push_back(std::make_shared<SDLButtonToButtonMapping>( portIndex, BTN_DRIGHT,
216216
SDL_CONTROLLER_BUTTON_DPAD_RIGHT));
217217
break;
218218
}
@@ -246,7 +246,7 @@ ButtonMappingFactory::CreateButtonMappingFromSDLInput(uint8_t portIndex, CONTROL
246246
for (auto [lusIndex, controller] : sdlControllers) {
247247
for (int32_t button = SDL_CONTROLLER_BUTTON_A; button < SDL_CONTROLLER_BUTTON_MAX; button++) {
248248
if (SDL_GameControllerGetButton(controller, static_cast<SDL_GameControllerButton>(button))) {
249-
mapping = std::make_shared<SDLButtonToButtonMapping>(lusIndex, portIndex, bitmask, button);
249+
mapping = std::make_shared<SDLButtonToButtonMapping>(portIndex, bitmask, button);
250250
break;
251251
}
252252
}
@@ -270,7 +270,7 @@ ButtonMappingFactory::CreateButtonMappingFromSDLInput(uint8_t portIndex, CONTROL
270270
}
271271

272272
mapping =
273-
std::make_shared<SDLAxisDirectionToButtonMapping>(lusIndex, portIndex, bitmask, axis, axisDirection);
273+
std::make_shared<SDLAxisDirectionToButtonMapping>(portIndex, bitmask, axis, axisDirection);
274274
break;
275275
}
276276
}

src/controller/controldevice/controller/mapping/factories/GyroMappingFactory.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ std::shared_ptr<ControllerGyroMapping> GyroMappingFactory::CreateGyroMappingFrom
3737
float neutralYaw = CVarGetFloat(StringHelper::Sprintf("%s.NeutralYaw", mappingCvarKey.c_str()).c_str(), 0.0f);
3838
float neutralRoll = CVarGetFloat(StringHelper::Sprintf("%s.NeutralRoll", mappingCvarKey.c_str()).c_str(), 0.0f);
3939

40-
return std::make_shared<SDLGyroMapping>(static_cast<ShipDeviceType>(shipDeviceIndex), portIndex, sensitivity,
40+
return std::make_shared<SDLGyroMapping>(portIndex, sensitivity,
4141
neutralPitch, neutralYaw, neutralRoll);
4242
}
4343

@@ -74,7 +74,7 @@ std::shared_ptr<ControllerGyroMapping> GyroMappingFactory::CreateGyroMappingFrom
7474
for (auto [lusIndex, controller] : sdlControllersWithGyro) {
7575
for (int32_t button = SDL_CONTROLLER_BUTTON_A; button < SDL_CONTROLLER_BUTTON_MAX; button++) {
7676
if (SDL_GameControllerGetButton(controller, static_cast<SDL_GameControllerButton>(button))) {
77-
mapping = std::make_shared<SDLGyroMapping>(lusIndex, portIndex, 1.0f, 0.0f, 0.0f, 0.0f);
77+
mapping = std::make_shared<SDLGyroMapping>(portIndex, 1.0f, 0.0f, 0.0f, 0.0f);
7878
mapping->Recalibrate();
7979
break;
8080
}
@@ -98,7 +98,7 @@ std::shared_ptr<ControllerGyroMapping> GyroMappingFactory::CreateGyroMappingFrom
9898
continue;
9999
}
100100

101-
mapping = std::make_shared<SDLGyroMapping>(lusIndex, portIndex, 1.0f, 0.0f, 0.0f, 0.0f);
101+
mapping = std::make_shared<SDLGyroMapping>(portIndex, 1.0f, 0.0f, 0.0f, 0.0f);
102102
mapping->Recalibrate();
103103
break;
104104
}

src/controller/controldevice/controller/mapping/factories/LEDMappingFactory.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ std::shared_ptr<ControllerLEDMapping> LEDMappingFactory::CreateLEDMappingFromCon
3535
return nullptr;
3636
}
3737

38-
return std::make_shared<SDLLEDMapping>(static_cast<ShipDeviceType>(shipDeviceIndex), portIndex, colorSource,
38+
return std::make_shared<SDLLEDMapping>(portIndex, colorSource,
3939
savedColor);
4040
}
4141

@@ -72,7 +72,7 @@ std::shared_ptr<ControllerLEDMapping> LEDMappingFactory::CreateLEDMappingFromSDL
7272
for (auto [lusIndex, controller] : sdlControllersWithLEDs) {
7373
for (int32_t button = SDL_CONTROLLER_BUTTON_A; button < SDL_CONTROLLER_BUTTON_MAX; button++) {
7474
if (SDL_GameControllerGetButton(controller, static_cast<SDL_GameControllerButton>(button))) {
75-
mapping = std::make_shared<SDLLEDMapping>(lusIndex, portIndex, 0, Color_RGB8({ 0, 0, 0 }));
75+
mapping = std::make_shared<SDLLEDMapping>(portIndex, 0, Color_RGB8({ 0, 0, 0 }));
7676
break;
7777
}
7878
}
@@ -95,7 +95,7 @@ std::shared_ptr<ControllerLEDMapping> LEDMappingFactory::CreateLEDMappingFromSDL
9595
continue;
9696
}
9797

98-
mapping = std::make_shared<SDLLEDMapping>(lusIndex, portIndex, 0, Color_RGB8({ 0, 0, 0 }));
98+
mapping = std::make_shared<SDLLEDMapping>(portIndex, 0, Color_RGB8({ 0, 0, 0 }));
9999
break;
100100
}
101101
}

src/controller/controldevice/controller/mapping/factories/RumbleMappingFactory.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ std::shared_ptr<ControllerRumbleMapping> RumbleMappingFactory::CreateRumbleMappi
3737
return nullptr;
3838
}
3939

40-
return std::make_shared<SDLRumbleMapping>(static_cast<ShipDeviceType>(shipDeviceIndex), portIndex,
40+
return std::make_shared<SDLRumbleMapping>(portIndex,
4141
lowFrequencyIntensityPercentage, highFrequencyIntensityPercentage);
4242
}
4343

@@ -56,7 +56,7 @@ RumbleMappingFactory::CreateDefaultSDLRumbleMappings(ShipDeviceType shipDeviceTy
5656
}
5757

5858
std::vector<std::shared_ptr<ControllerRumbleMapping>> mappings = { std::make_shared<SDLRumbleMapping>(
59-
shipDeviceType, portIndex, DEFAULT_LOW_FREQUENCY_RUMBLE_PERCENTAGE,
59+
portIndex, DEFAULT_LOW_FREQUENCY_RUMBLE_PERCENTAGE,
6060
DEFAULT_HIGH_FREQUENCY_RUMBLE_PERCENTAGE) };
6161

6262
return mappings;
@@ -95,7 +95,7 @@ std::shared_ptr<ControllerRumbleMapping> RumbleMappingFactory::CreateRumbleMappi
9595
for (int32_t button = SDL_CONTROLLER_BUTTON_A; button < SDL_CONTROLLER_BUTTON_MAX; button++) {
9696
if (SDL_GameControllerGetButton(controller, static_cast<SDL_GameControllerButton>(button))) {
9797
mapping =
98-
std::make_shared<SDLRumbleMapping>(lusIndex, portIndex, DEFAULT_LOW_FREQUENCY_RUMBLE_PERCENTAGE,
98+
std::make_shared<SDLRumbleMapping>(portIndex, DEFAULT_LOW_FREQUENCY_RUMBLE_PERCENTAGE,
9999
DEFAULT_HIGH_FREQUENCY_RUMBLE_PERCENTAGE);
100100
break;
101101
}
@@ -119,7 +119,7 @@ std::shared_ptr<ControllerRumbleMapping> RumbleMappingFactory::CreateRumbleMappi
119119
continue;
120120
}
121121

122-
mapping = std::make_shared<SDLRumbleMapping>(lusIndex, portIndex, DEFAULT_LOW_FREQUENCY_RUMBLE_PERCENTAGE,
122+
mapping = std::make_shared<SDLRumbleMapping>(portIndex, DEFAULT_LOW_FREQUENCY_RUMBLE_PERCENTAGE,
123123
DEFAULT_HIGH_FREQUENCY_RUMBLE_PERCENTAGE);
124124
break;
125125
}

src/controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToAnyMapping.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
#include "window/gui/IconsFontAwesome4.h"
55

66
namespace Ship {
7-
SDLAxisDirectionToAnyMapping::SDLAxisDirectionToAnyMapping(ShipDeviceType shipDeviceType, int32_t sdlControllerAxis,
7+
SDLAxisDirectionToAnyMapping::SDLAxisDirectionToAnyMapping(int32_t sdlControllerAxis,
88
int32_t axisDirection)
9-
: ControllerInputMapping(shipDeviceType), SDLMapping(shipDeviceType) {
9+
: ControllerInputMapping(ShipDeviceType::SDLGamepad), SDLMapping() {
1010
mControllerAxis = static_cast<SDL_GameControllerAxis>(sdlControllerAxis);
1111
mAxisDirection = static_cast<AxisDirection>(axisDirection);
1212
}

src/controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToAnyMapping.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace Ship {
77
class SDLAxisDirectionToAnyMapping : virtual public ControllerInputMapping, public SDLMapping {
88
public:
9-
SDLAxisDirectionToAnyMapping(ShipDeviceType shipDeviceType, int32_t sdlControllerAxis, int32_t axisDirection);
9+
SDLAxisDirectionToAnyMapping(int32_t sdlControllerAxis, int32_t axisDirection);
1010
~SDLAxisDirectionToAnyMapping();
1111
std::string GetPhysicalInputName() override;
1212
std::string GetPhysicalDeviceName() override;

src/controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToAxisDirectionMapping.cpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@
88
#define MAX_SDL_RANGE (float)INT16_MAX
99

1010
namespace Ship {
11-
SDLAxisDirectionToAxisDirectionMapping::SDLAxisDirectionToAxisDirectionMapping(ShipDeviceType shipDeviceType,
12-
uint8_t portIndex, StickIndex stickIndex,
11+
SDLAxisDirectionToAxisDirectionMapping::SDLAxisDirectionToAxisDirectionMapping(uint8_t portIndex, StickIndex stickIndex,
1312
Direction direction,
1413
int32_t sdlControllerAxis,
1514
int32_t axisDirection)
16-
: ControllerInputMapping(shipDeviceType),
17-
ControllerAxisDirectionMapping(shipDeviceType, portIndex, stickIndex, direction),
18-
SDLAxisDirectionToAnyMapping(shipDeviceType, sdlControllerAxis, axisDirection) {
15+
: ControllerInputMapping(ShipDeviceType::SDLGamepad),
16+
ControllerAxisDirectionMapping(ShipDeviceType::SDLGamepad, portIndex, stickIndex, direction),
17+
SDLAxisDirectionToAnyMapping(sdlControllerAxis, axisDirection) {
1918
}
2019

2120
float SDLAxisDirectionToAxisDirectionMapping::GetNormalizedAxisDirectionValue() {

src/controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToAxisDirectionMapping.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace Ship {
55
class SDLAxisDirectionToAxisDirectionMapping final : public ControllerAxisDirectionMapping,
66
public SDLAxisDirectionToAnyMapping {
77
public:
8-
SDLAxisDirectionToAxisDirectionMapping(ShipDeviceType shipDeviceType, uint8_t portIndex, StickIndex stickIndex,
8+
SDLAxisDirectionToAxisDirectionMapping(uint8_t portIndex, StickIndex stickIndex,
99
Direction direction, int32_t sdlControllerAxis, int32_t axisDirection);
1010
float GetNormalizedAxisDirectionValue() override;
1111
std::string GetAxisDirectionMappingId() override;

src/controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToButtonMapping.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
#include "Context.h"
77

88
namespace Ship {
9-
SDLAxisDirectionToButtonMapping::SDLAxisDirectionToButtonMapping(ShipDeviceType shipDeviceType, uint8_t portIndex,
9+
SDLAxisDirectionToButtonMapping::SDLAxisDirectionToButtonMapping(uint8_t portIndex,
1010
CONTROLLERBUTTONS_T bitmask, int32_t sdlControllerAxis,
1111
int32_t axisDirection)
12-
: ControllerInputMapping(shipDeviceType), ControllerButtonMapping(shipDeviceType, portIndex, bitmask),
13-
SDLAxisDirectionToAnyMapping(shipDeviceType, sdlControllerAxis, axisDirection) {
12+
: ControllerInputMapping(ShipDeviceType::SDLGamepad), ControllerButtonMapping(ShipDeviceType::SDLGamepad, portIndex, bitmask),
13+
SDLAxisDirectionToAnyMapping(sdlControllerAxis, axisDirection) {
1414
}
1515

1616
void SDLAxisDirectionToButtonMapping::UpdatePad(CONTROLLERBUTTONS_T& padButtons) {

0 commit comments

Comments
 (0)