@@ -86,28 +86,28 @@ void Controller::ClearAllMappings() {
86
86
GetLED ()->ClearAllMappings ();
87
87
}
88
88
89
- void Controller::ClearAllMappingsForDevice (ShipDeviceIndex shipDeviceIndex ) {
89
+ void Controller::ClearAllMappingsForDeviceType (PhysicalDeviceType physicalDeviceType ) {
90
90
for (auto [bitmask, button] : GetAllButtons ()) {
91
- button->ClearAllButtonMappingsForDevice (shipDeviceIndex );
91
+ button->ClearAllButtonMappingsForDeviceType (physicalDeviceType );
92
92
}
93
- GetLeftStick ()->ClearAllMappingsForDevice (shipDeviceIndex );
94
- GetRightStick ()->ClearAllMappingsForDevice (shipDeviceIndex );
93
+ GetLeftStick ()->ClearAllMappingsForDeviceType (physicalDeviceType );
94
+ GetRightStick ()->ClearAllMappingsForDeviceType (physicalDeviceType );
95
95
96
96
auto gyroMapping = GetGyro ()->GetGyroMapping ();
97
- if (gyroMapping != nullptr && gyroMapping->GetShipDeviceIndex () == shipDeviceIndex ) {
97
+ if (gyroMapping != nullptr && gyroMapping->GetPhysicalDeviceType () == physicalDeviceType ) {
98
98
GetGyro ()->ClearGyroMapping ();
99
99
}
100
100
101
- GetRumble ()->ClearAllMappingsForDevice (shipDeviceIndex );
102
- GetLED ()->ClearAllMappingsForDevice (shipDeviceIndex );
101
+ GetRumble ()->ClearAllMappingsForDeviceType (physicalDeviceType );
102
+ GetLED ()->ClearAllMappingsForDeviceType (physicalDeviceType );
103
103
}
104
104
105
- void Controller::AddDefaultMappings (ShipDeviceIndex shipDeviceIndex ) {
105
+ void Controller::AddDefaultMappings (PhysicalDeviceType physicalDeviceType ) {
106
106
for (auto [bitmask, button] : GetAllButtons ()) {
107
- button->AddDefaultMappings (shipDeviceIndex );
107
+ button->AddDefaultMappings (physicalDeviceType );
108
108
}
109
- GetLeftStick ()->AddDefaultMappings (shipDeviceIndex );
110
- GetRumble ()->AddDefaultMappings (shipDeviceIndex );
109
+ GetLeftStick ()->AddDefaultMappings (physicalDeviceType );
110
+ GetRumble ()->AddDefaultMappings (physicalDeviceType );
111
111
112
112
const std::string hasConfigCvarKey =
113
113
StringHelper::Sprintf (CVAR_PREFIX_CONTROLLERS " .Port%d.HasConfig" , mPortIndex + 1 );
@@ -146,25 +146,25 @@ bool Controller::ProcessMouseButtonEvent(bool isPressed, MouseBtn mouseButton) {
146
146
return result;
147
147
}
148
148
149
- bool Controller::HasMappingsForShipDeviceIndex (ShipDeviceIndex lusIndex ) {
149
+ bool Controller::HasMappingsForPhysicalDeviceType (PhysicalDeviceType physicalDeviceType ) {
150
150
for (auto [bitmask, button] : GetAllButtons ()) {
151
- if (button->HasMappingsForShipDeviceIndex (lusIndex )) {
151
+ if (button->HasMappingsForPhysicalDeviceType (physicalDeviceType )) {
152
152
return true ;
153
153
}
154
154
}
155
- if (GetLeftStick ()->HasMappingsForShipDeviceIndex (lusIndex )) {
155
+ if (GetLeftStick ()->HasMappingsForPhysicalDeviceType (physicalDeviceType )) {
156
156
return true ;
157
157
}
158
- if (GetRightStick ()->HasMappingsForShipDeviceIndex (lusIndex )) {
158
+ if (GetRightStick ()->HasMappingsForPhysicalDeviceType (physicalDeviceType )) {
159
159
return true ;
160
160
}
161
- if (GetGyro ()->HasMappingForShipDeviceIndex (lusIndex )) {
161
+ if (GetGyro ()->HasMappingForPhysicalDeviceType (physicalDeviceType )) {
162
162
return true ;
163
163
}
164
- if (GetRumble ()->HasMappingsForShipDeviceIndex (lusIndex )) {
164
+ if (GetRumble ()->HasMappingsForPhysicalDeviceType (physicalDeviceType )) {
165
165
return true ;
166
166
}
167
- if (GetLED ()->HasMappingsForShipDeviceIndex (lusIndex )) {
167
+ if (GetLED ()->HasMappingsForPhysicalDeviceType (physicalDeviceType )) {
168
168
return true ;
169
169
}
170
170
@@ -175,96 +175,6 @@ std::shared_ptr<ControllerButton> Controller::GetButtonByBitmask(CONTROLLERBUTTO
175
175
return mButtons [bitmask];
176
176
}
177
177
178
- void Controller::MoveMappingsToDifferentController (std::shared_ptr<Controller> newController,
179
- ShipDeviceIndex lusIndex) {
180
- for (auto [bitmask, button] : GetAllButtons ()) {
181
- std::vector<std::string> buttonMappingIdsToRemove;
182
- for (auto [id, mapping] : button->GetAllButtonMappings ()) {
183
- if (mapping->GetShipDeviceIndex () == lusIndex) {
184
- buttonMappingIdsToRemove.push_back (id);
185
-
186
- mapping->SetPortIndex (newController->GetPortIndex ());
187
- mapping->SaveToConfig ();
188
-
189
- newController->GetButtonByBitmask (bitmask)->AddButtonMapping (mapping);
190
- }
191
- }
192
- newController->GetButtonByBitmask (bitmask)->SaveButtonMappingIdsToConfig ();
193
- for (auto id : buttonMappingIdsToRemove) {
194
- button->ClearButtonMappingId (id);
195
- }
196
- }
197
-
198
- for (auto stick : { GetLeftStick (), GetRightStick () }) {
199
- auto newControllerStick =
200
- stick->GetStickIndex () == LEFT_STICK ? newController->GetLeftStick () : newController->GetRightStick ();
201
- for (auto [direction, mappings] : stick->GetAllAxisDirectionMappings ()) {
202
- std::vector<std::string> axisDirectionMappingIdsToRemove;
203
- for (auto [id, mapping] : mappings) {
204
- if (mapping->GetShipDeviceIndex () == lusIndex) {
205
- axisDirectionMappingIdsToRemove.push_back (id);
206
-
207
- mapping->SetPortIndex (newController->GetPortIndex ());
208
- mapping->SaveToConfig ();
209
-
210
- newControllerStick->AddAxisDirectionMapping (direction, mapping);
211
- }
212
- }
213
- newControllerStick->SaveAxisDirectionMappingIdsToConfig ();
214
- for (auto id : axisDirectionMappingIdsToRemove) {
215
- stick->ClearAxisDirectionMappingId (direction, id);
216
- }
217
- }
218
- }
219
-
220
- if (GetGyro ()->GetGyroMapping () != nullptr && GetGyro ()->GetGyroMapping ()->GetShipDeviceIndex () == lusIndex) {
221
- GetGyro ()->GetGyroMapping ()->SetPortIndex (newController->GetPortIndex ());
222
- GetGyro ()->GetGyroMapping ()->SaveToConfig ();
223
-
224
- auto oldGyroMappingFromNewController = newController->GetGyro ()->GetGyroMapping ();
225
- if (oldGyroMappingFromNewController != nullptr ) {
226
- oldGyroMappingFromNewController->SetPortIndex (GetPortIndex ());
227
- oldGyroMappingFromNewController->SaveToConfig ();
228
- }
229
- newController->GetGyro ()->SetGyroMapping (GetGyro ()->GetGyroMapping ());
230
- newController->GetGyro ()->SaveGyroMappingIdToConfig ();
231
- GetGyro ()->SetGyroMapping (oldGyroMappingFromNewController);
232
- GetGyro ()->SaveGyroMappingIdToConfig ();
233
- }
234
-
235
- std::vector<std::string> rumbleMappingIdsToRemove;
236
- for (auto [id, mapping] : GetRumble ()->GetAllRumbleMappings ()) {
237
- if (mapping->GetShipDeviceIndex () == lusIndex) {
238
- rumbleMappingIdsToRemove.push_back (id);
239
-
240
- mapping->SetPortIndex (newController->GetPortIndex ());
241
- mapping->SaveToConfig ();
242
-
243
- newController->GetRumble ()->AddRumbleMapping (mapping);
244
- }
245
- }
246
- newController->GetRumble ()->SaveRumbleMappingIdsToConfig ();
247
- for (auto id : rumbleMappingIdsToRemove) {
248
- GetRumble ()->ClearRumbleMappingId (id);
249
- }
250
-
251
- std::vector<std::string> ledMappingIdsToRemove;
252
- for (auto [id, mapping] : GetLED ()->GetAllLEDMappings ()) {
253
- if (mapping->GetShipDeviceIndex () == lusIndex) {
254
- ledMappingIdsToRemove.push_back (id);
255
-
256
- mapping->SetPortIndex (newController->GetPortIndex ());
257
- mapping->SaveToConfig ();
258
-
259
- newController->GetLED ()->AddLEDMapping (mapping);
260
- }
261
- }
262
- newController->GetLED ()->SaveLEDMappingIdsToConfig ();
263
- for (auto id : ledMappingIdsToRemove) {
264
- GetLED ()->ClearLEDMappingId (id);
265
- }
266
- }
267
-
268
178
std::vector<std::shared_ptr<ControllerMapping>> Controller::GetAllMappings () {
269
179
std::vector<std::shared_ptr<ControllerMapping>> allMappings;
270
180
for (auto [bitmask, button] : GetAllButtons ()) {
0 commit comments