Skip to content

Commit 6162887

Browse files
committed
some naming and cleanup
1 parent f0c03ea commit 6162887

8 files changed

+18
-36
lines changed

src/controller/controldevice/controller/Controller.cpp

-6
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,6 @@ std::shared_ptr<ControllerButton> Controller::GetButtonByBitmask(CONTROLLERBUTTO
175175
return mButtons[bitmask];
176176
}
177177

178-
void Controller::MoveMappingsToDifferentController(std::shared_ptr<Controller> newController,
179-
PhysicalDeviceType lusIndex) {
180-
// todo: remove this entirely
181-
return;
182-
}
183-
184178
std::vector<std::shared_ptr<ControllerMapping>> Controller::GetAllMappings() {
185179
std::vector<std::shared_ptr<ControllerMapping>> allMappings;
186180
for (auto [bitmask, button] : GetAllButtons()) {

src/controller/controldevice/controller/Controller.h

-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ class Controller : public ControlDevice {
5252
bool ProcessMouseButtonEvent(bool isPressed, MouseBtn button);
5353

5454
bool HasMappingsForPhysicalDeviceType(PhysicalDeviceType physicalDeviceType);
55-
void MoveMappingsToDifferentController(std::shared_ptr<Controller> newController, PhysicalDeviceType lusIndex);
5655

5756
protected:
5857
std::unordered_map<CONTROLLERBUTTONS_T, std::shared_ptr<ControllerButton>> mButtons;

src/controller/controldevice/controller/ControllerGyro.h

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ class ControllerGyro {
1111
ControllerGyro(uint8_t portIndex);
1212
~ControllerGyro();
1313

14-
// void AddOrReplaceGyroMapping(std::shared_ptr<ControllerGyroMapping> mapping);
1514
void ReloadGyroMappingFromConfig();
1615
void ClearGyroMapping();
1716
void SaveGyroMappingIdToConfig();

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,11 @@ AxisDirectionMappingFactory::CreateAxisDirectionMappingFromSDLInput(uint8_t port
143143
Direction direction) {
144144
std::shared_ptr<ControllerAxisDirectionMapping> mapping = nullptr;
145145

146-
for (auto [lusIndex, controller] :
146+
for (auto [instanceId, gamepad] :
147147
Context::GetInstance()->GetControlDeck()->GetConnectedPhysicalDeviceManager()->GetConnectedSDLGamepadsForPort(
148148
portIndex)) {
149149
for (int32_t button = SDL_CONTROLLER_BUTTON_A; button < SDL_CONTROLLER_BUTTON_MAX; button++) {
150-
if (SDL_GameControllerGetButton(controller, static_cast<SDL_GameControllerButton>(button))) {
150+
if (SDL_GameControllerGetButton(gamepad, static_cast<SDL_GameControllerButton>(button))) {
151151
mapping = std::make_shared<SDLButtonToAxisDirectionMapping>(portIndex, stickIndex, direction, button);
152152
break;
153153
}
@@ -159,7 +159,7 @@ AxisDirectionMappingFactory::CreateAxisDirectionMappingFromSDLInput(uint8_t port
159159

160160
for (int32_t i = SDL_CONTROLLER_AXIS_LEFTX; i < SDL_CONTROLLER_AXIS_MAX; i++) {
161161
const auto axis = static_cast<SDL_GameControllerAxis>(i);
162-
const auto axisValue = SDL_GameControllerGetAxis(controller, axis) / 32767.0f;
162+
const auto axisValue = SDL_GameControllerGetAxis(gamepad, axis) / 32767.0f;
163163
int32_t axisDirection = 0;
164164
if (axisValue < -0.7f) {
165165
axisDirection = NEGATIVE;

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,11 @@ std::shared_ptr<ControllerButtonMapping>
214214
ButtonMappingFactory::CreateButtonMappingFromSDLInput(uint8_t portIndex, CONTROLLERBUTTONS_T bitmask) {
215215
std::shared_ptr<ControllerButtonMapping> mapping = nullptr;
216216

217-
for (auto [lusIndex, controller] :
217+
for (auto [instanceId, gamepad] :
218218
Context::GetInstance()->GetControlDeck()->GetConnectedPhysicalDeviceManager()->GetConnectedSDLGamepadsForPort(
219219
portIndex)) {
220220
for (int32_t button = SDL_CONTROLLER_BUTTON_A; button < SDL_CONTROLLER_BUTTON_MAX; button++) {
221-
if (SDL_GameControllerGetButton(controller, static_cast<SDL_GameControllerButton>(button))) {
221+
if (SDL_GameControllerGetButton(gamepad, static_cast<SDL_GameControllerButton>(button))) {
222222
mapping = std::make_shared<SDLButtonToButtonMapping>(portIndex, bitmask, button);
223223
break;
224224
}
@@ -230,7 +230,7 @@ ButtonMappingFactory::CreateButtonMappingFromSDLInput(uint8_t portIndex, CONTROL
230230

231231
for (int32_t i = SDL_CONTROLLER_AXIS_LEFTX; i < SDL_CONTROLLER_AXIS_MAX; i++) {
232232
const auto axis = static_cast<SDL_GameControllerAxis>(i);
233-
const auto axisValue = SDL_GameControllerGetAxis(controller, axis) / 32767.0f;
233+
const auto axisValue = SDL_GameControllerGetAxis(gamepad, axis) / 32767.0f;
234234
int32_t axisDirection = 0;
235235
if (axisValue < -0.7f) {
236236
axisDirection = NEGATIVE;

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

+4-14
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,6 @@ std::shared_ptr<ControllerGyroMapping> GyroMappingFactory::CreateGyroMappingFrom
2121
}
2222

2323
if (mappingClass == "SDLGyroMapping") {
24-
int32_t shipDeviceIndex =
25-
CVarGetInteger(StringHelper::Sprintf("%s.ShipDeviceIndex", mappingCvarKey.c_str()).c_str(), -1);
26-
27-
if (shipDeviceIndex < 0) {
28-
// something about this mapping is invalid
29-
CVarClear(mappingCvarKey.c_str());
30-
CVarSave();
31-
return nullptr;
32-
}
33-
3424
float neutralPitch =
3525
CVarGetFloat(StringHelper::Sprintf("%s.NeutralPitch", mappingCvarKey.c_str()).c_str(), 0.0f);
3626
float neutralYaw = CVarGetFloat(StringHelper::Sprintf("%s.NeutralYaw", mappingCvarKey.c_str()).c_str(), 0.0f);
@@ -45,15 +35,15 @@ std::shared_ptr<ControllerGyroMapping> GyroMappingFactory::CreateGyroMappingFrom
4535
std::shared_ptr<ControllerGyroMapping> GyroMappingFactory::CreateGyroMappingFromSDLInput(uint8_t portIndex) {
4636
std::shared_ptr<ControllerGyroMapping> mapping = nullptr;
4737

48-
for (auto [lusIndex, controller] :
38+
for (auto [instanceId, gamepad] :
4939
Context::GetInstance()->GetControlDeck()->GetConnectedPhysicalDeviceManager()->GetConnectedSDLGamepadsForPort(
5040
portIndex)) {
51-
if (!SDL_GameControllerHasSensor(controller, SDL_SENSOR_GYRO)) {
41+
if (!SDL_GameControllerHasSensor(gamepad, SDL_SENSOR_GYRO)) {
5242
continue;
5343
}
5444

5545
for (int32_t button = SDL_CONTROLLER_BUTTON_A; button < SDL_CONTROLLER_BUTTON_MAX; button++) {
56-
if (SDL_GameControllerGetButton(controller, static_cast<SDL_GameControllerButton>(button))) {
46+
if (SDL_GameControllerGetButton(gamepad, static_cast<SDL_GameControllerButton>(button))) {
5747
mapping = std::make_shared<SDLGyroMapping>(portIndex, 1.0f, 0.0f, 0.0f, 0.0f);
5848
mapping->Recalibrate();
5949
break;
@@ -66,7 +56,7 @@ std::shared_ptr<ControllerGyroMapping> GyroMappingFactory::CreateGyroMappingFrom
6656

6757
for (int32_t i = SDL_CONTROLLER_AXIS_LEFTX; i < SDL_CONTROLLER_AXIS_MAX; i++) {
6858
const auto axis = static_cast<SDL_GameControllerAxis>(i);
69-
const auto axisValue = SDL_GameControllerGetAxis(controller, axis) / 32767.0f;
59+
const auto axisValue = SDL_GameControllerGetAxis(gamepad, axis) / 32767.0f;
7060
int32_t axisDirection = 0;
7161
if (axisValue < -0.7f) {
7262
axisDirection = NEGATIVE;

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ std::shared_ptr<ControllerLEDMapping> LEDMappingFactory::CreateLEDMappingFromCon
3333
std::shared_ptr<ControllerLEDMapping> LEDMappingFactory::CreateLEDMappingFromSDLInput(uint8_t portIndex) {
3434
std::shared_ptr<ControllerLEDMapping> mapping = nullptr;
3535

36-
for (auto [lusIndex, controller] :
36+
for (auto [instanceId, gamepad] :
3737
Context::GetInstance()->GetControlDeck()->GetConnectedPhysicalDeviceManager()->GetConnectedSDLGamepadsForPort(
3838
portIndex)) {
39-
if (!SDL_GameControllerHasLED(controller)) {
39+
if (!SDL_GameControllerHasLED(gamepad)) {
4040
continue;
4141
}
4242

4343
for (int32_t button = SDL_CONTROLLER_BUTTON_A; button < SDL_CONTROLLER_BUTTON_MAX; button++) {
44-
if (SDL_GameControllerGetButton(controller, static_cast<SDL_GameControllerButton>(button))) {
44+
if (SDL_GameControllerGetButton(gamepad, static_cast<SDL_GameControllerButton>(button))) {
4545
mapping = std::make_shared<SDLLEDMapping>(portIndex, 0, Color_RGB8({ 0, 0, 0 }));
4646
break;
4747
}
@@ -53,7 +53,7 @@ std::shared_ptr<ControllerLEDMapping> LEDMappingFactory::CreateLEDMappingFromSDL
5353

5454
for (int32_t i = SDL_CONTROLLER_AXIS_LEFTX; i < SDL_CONTROLLER_AXIS_MAX; i++) {
5555
const auto axis = static_cast<SDL_GameControllerAxis>(i);
56-
const auto axisValue = SDL_GameControllerGetAxis(controller, axis) / 32767.0f;
56+
const auto axisValue = SDL_GameControllerGetAxis(gamepad, axis) / 32767.0f;
5757
int32_t axisDirection = 0;
5858
if (axisValue < -0.7f) {
5959
axisDirection = NEGATIVE;

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ RumbleMappingFactory::CreateDefaultSDLRumbleMappings(PhysicalDeviceType physical
5454
std::shared_ptr<ControllerRumbleMapping> RumbleMappingFactory::CreateRumbleMappingFromSDLInput(uint8_t portIndex) {
5555
std::shared_ptr<ControllerRumbleMapping> mapping = nullptr;
5656

57-
for (auto [lusIndex, controller] :
57+
for (auto [instanceId, gamepad] :
5858
Context::GetInstance()->GetControlDeck()->GetConnectedPhysicalDeviceManager()->GetConnectedSDLGamepadsForPort(
5959
portIndex)) {
60-
if (!SDL_GameControllerHasLED(controller)) {
60+
if (!SDL_GameControllerHasLED(gamepad)) {
6161
continue;
6262
}
6363

6464
for (int32_t button = SDL_CONTROLLER_BUTTON_A; button < SDL_CONTROLLER_BUTTON_MAX; button++) {
65-
if (SDL_GameControllerGetButton(controller, static_cast<SDL_GameControllerButton>(button))) {
65+
if (SDL_GameControllerGetButton(gamepad, static_cast<SDL_GameControllerButton>(button))) {
6666
mapping = std::make_shared<SDLRumbleMapping>(portIndex, DEFAULT_LOW_FREQUENCY_RUMBLE_PERCENTAGE,
6767
DEFAULT_HIGH_FREQUENCY_RUMBLE_PERCENTAGE);
6868
break;
@@ -75,7 +75,7 @@ std::shared_ptr<ControllerRumbleMapping> RumbleMappingFactory::CreateRumbleMappi
7575

7676
for (int32_t i = SDL_CONTROLLER_AXIS_LEFTX; i < SDL_CONTROLLER_AXIS_MAX; i++) {
7777
const auto axis = static_cast<SDL_GameControllerAxis>(i);
78-
const auto axisValue = SDL_GameControllerGetAxis(controller, axis) / 32767.0f;
78+
const auto axisValue = SDL_GameControllerGetAxis(gamepad, axis) / 32767.0f;
7979
int32_t axisDirection = 0;
8080
if (axisValue < -0.7f) {
8181
axisDirection = NEGATIVE;

0 commit comments

Comments
 (0)