Skip to content

Commit

Permalink
wiiu: Implement CVAR_PREFIX_CONTROLLERS
Browse files Browse the repository at this point in the history
  • Loading branch information
GaryOderNichts committed May 31, 2024
1 parent df473ec commit 02709ce
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ bool ControllerButton::AddOrEditButtonMappingFromRawPress(CONTROLLERBUTTONS_T bi
AddButtonMapping(mapping);
mapping->SaveToConfig();
SaveButtonMappingIdsToConfig();
const std::string hasConfigCvarKey = StringHelper::Sprintf("gControllers.Port%d.HasConfig", mPortIndex + 1);
const std::string hasConfigCvarKey = StringHelper::Sprintf(CVAR_PREFIX_CONTROLLERS ".Port%d.HasConfig", mPortIndex + 1);
CVarSetInteger(hasConfigCvarKey.c_str(), true);
CVarSave();
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/controller/controldevice/controller/ControllerGyro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ bool ControllerGyro::SetGyroMappingFromRawPress() {
SetGyroMapping(mapping);
mapping->SaveToConfig();
SaveGyroMappingIdToConfig();
const std::string hasConfigCvarKey = StringHelper::Sprintf("gControllers.Port%d.HasConfig", mPortIndex + 1);
const std::string hasConfigCvarKey = StringHelper::Sprintf(CVAR_PREFIX_CONTROLLERS ".Port%d.HasConfig", mPortIndex + 1);
CVarSetInteger(hasConfigCvarKey.c_str(), true);
CVarSave();
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ bool ControllerRumble::AddRumbleMappingFromRawPress() {
AddRumbleMapping(mapping);
mapping->SaveToConfig();
SaveRumbleMappingIdsToConfig();
const std::string hasConfigCvarKey = StringHelper::Sprintf("gControllers.Port%d.HasConfig", mPortIndex + 1);
const std::string hasConfigCvarKey = StringHelper::Sprintf(CVAR_PREFIX_CONTROLLERS ".Port%d.HasConfig", mPortIndex + 1);
CVarSetInteger(hasConfigCvarKey.c_str(), true);
CVarSave();
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ bool ControllerStick::AddOrEditAxisDirectionMappingFromRawPress(Direction direct
AddAxisDirectionMapping(direction, mapping);
mapping->SaveToConfig();
SaveAxisDirectionMappingIdsToConfig();
const std::string hasConfigCvarKey = StringHelper::Sprintf("gControllers.Port%d.HasConfig", mPortIndex + 1);
const std::string hasConfigCvarKey = StringHelper::Sprintf(CVAR_PREFIX_CONTROLLERS ".Port%d.HasConfig", mPortIndex + 1);
CVarSetInteger(hasConfigCvarKey.c_str(), true);
CVarSave();
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ std::string WiiUAxisDirectionToAxisDirectionMapping::GetAxisDirectionMappingId()
}

void WiiUAxisDirectionToAxisDirectionMapping::SaveToConfig() {
const std::string mappingCvarKey = "gControllers.AxisDirectionMappings." + GetAxisDirectionMappingId();
const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".AxisDirectionMappings." + GetAxisDirectionMappingId();
CVarSetString(StringHelper::Sprintf("%s.AxisDirectionMappingClass", mappingCvarKey.c_str()).c_str(),
"WiiUAxisDirectionToAxisDirectionMapping");
CVarSetInteger(StringHelper::Sprintf("%s.Stick", mappingCvarKey.c_str()).c_str(), mStick);
Expand All @@ -134,7 +134,7 @@ void WiiUAxisDirectionToAxisDirectionMapping::SaveToConfig() {
}

void WiiUAxisDirectionToAxisDirectionMapping::EraseFromConfig() {
const std::string mappingCvarKey = "gControllers.AxisDirectionMappings." + GetAxisDirectionMappingId();
const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".AxisDirectionMappings." + GetAxisDirectionMappingId();
CVarClear(StringHelper::Sprintf("%s.Stick", mappingCvarKey.c_str()).c_str());
CVarClear(StringHelper::Sprintf("%s.Direction", mappingCvarKey.c_str()).c_str());
CVarClear(StringHelper::Sprintf("%s.AxisDirectionMappingClass", mappingCvarKey.c_str()).c_str());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ std::string WiiUButtonToAxisDirectionMapping::GetAxisDirectionMappingId() {
}

void WiiUButtonToAxisDirectionMapping::SaveToConfig() {
const std::string mappingCvarKey = "gControllers.AxisDirectionMappings." + GetAxisDirectionMappingId();
const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".AxisDirectionMappings." + GetAxisDirectionMappingId();
CVarSetString(StringHelper::Sprintf("%s.AxisDirectionMappingClass", mappingCvarKey.c_str()).c_str(),
"WiiUButtonToAxisDirectionMapping");
CVarSetInteger(StringHelper::Sprintf("%s.Stick", mappingCvarKey.c_str()).c_str(), mStick);
Expand All @@ -45,7 +45,7 @@ void WiiUButtonToAxisDirectionMapping::SaveToConfig() {
}

void WiiUButtonToAxisDirectionMapping::EraseFromConfig() {
const std::string mappingCvarKey = "gControllers.AxisDirectionMappings." + GetAxisDirectionMappingId();
const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".AxisDirectionMappings." + GetAxisDirectionMappingId();
CVarClear(StringHelper::Sprintf("%s.Stick", mappingCvarKey.c_str()).c_str());
CVarClear(StringHelper::Sprintf("%s.Direction", mappingCvarKey.c_str()).c_str());
CVarClear(StringHelper::Sprintf("%s.AxisDirectionMappingClass", mappingCvarKey.c_str()).c_str());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ std::string WiiUButtonToButtonMapping::GetButtonMappingId() {
}

void WiiUButtonToButtonMapping::SaveToConfig() {
const std::string mappingCvarKey = "gControllers.ButtonMappings." + GetButtonMappingId();
const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".ButtonMappings." + GetButtonMappingId();
CVarSetString(StringHelper::Sprintf("%s.ButtonMappingClass", mappingCvarKey.c_str()).c_str(),
"WiiUButtonToButtonMapping");
CVarSetInteger(StringHelper::Sprintf("%s.Bitmask", mappingCvarKey.c_str()).c_str(), mBitmask);
Expand All @@ -50,7 +50,7 @@ void WiiUButtonToButtonMapping::SaveToConfig() {
}

void WiiUButtonToButtonMapping::EraseFromConfig() {
const std::string mappingCvarKey = "gControllers.ButtonMappings." + GetButtonMappingId();
const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".ButtonMappings." + GetButtonMappingId();

CVarClear(StringHelper::Sprintf("%s.ButtonMappingClass", mappingCvarKey.c_str()).c_str());
CVarClear(StringHelper::Sprintf("%s.Bitmask", mappingCvarKey.c_str()).c_str());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ std::string WiiUGyroMapping::GetGyroMappingId() {
}

void WiiUGyroMapping::SaveToConfig() {
const std::string mappingCvarKey = "gControllers.GyroMappings." + GetGyroMappingId();
const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".GyroMappings." + GetGyroMappingId();

CVarSetString(StringHelper::Sprintf("%s.GyroMappingClass", mappingCvarKey.c_str()).c_str(), "WiiUGyroMapping");
CVarSetInteger(StringHelper::Sprintf("%s.ShipDeviceIndex", mappingCvarKey.c_str()).c_str(),
Expand All @@ -74,7 +74,7 @@ void WiiUGyroMapping::SaveToConfig() {
}

void WiiUGyroMapping::EraseFromConfig() {
const std::string mappingCvarKey = "gControllers.GyroMappings." + GetGyroMappingId();
const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".GyroMappings." + GetGyroMappingId();

CVarClear(StringHelper::Sprintf("%s.GyroMappingClass", mappingCvarKey.c_str()).c_str());
CVarClear(StringHelper::Sprintf("%s.ShipDeviceIndex", mappingCvarKey.c_str()).c_str());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ std::string WiiURumbleMapping::GetRumbleMappingId() {
}

void WiiURumbleMapping::SaveToConfig() {
const std::string mappingCvarKey = "gControllers.RumbleMappings." + GetRumbleMappingId();
const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".RumbleMappings." + GetRumbleMappingId();
CVarSetString(StringHelper::Sprintf("%s.RumbleMappingClass", mappingCvarKey.c_str()).c_str(), "WiiURumbleMapping");
CVarSetInteger(StringHelper::Sprintf("%s.ShipDeviceIndex", mappingCvarKey.c_str()).c_str(),
ControllerRumbleMapping::mShipDeviceIndex);
Expand All @@ -81,7 +81,7 @@ void WiiURumbleMapping::SaveToConfig() {
}

void WiiURumbleMapping::EraseFromConfig() {
const std::string mappingCvarKey = "gControllers.RumbleMappings." + GetRumbleMappingId();
const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".RumbleMappings." + GetRumbleMappingId();

CVarClear(StringHelper::Sprintf("%s.RumbleMappingClass", mappingCvarKey.c_str()).c_str());
CVarClear(StringHelper::Sprintf("%s.ShipDeviceIndex", mappingCvarKey.c_str()).c_str());
Expand Down
6 changes: 3 additions & 3 deletions src/controller/deviceindex/ShipDeviceIndexMappingManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ bool ShipDeviceIndexMappingManager::IsValidWiiUExtensionType(int32_t extensionTy

std::shared_ptr<ShipDeviceIndexToPhysicalDeviceIndexMapping>
ShipDeviceIndexMappingManager::CreateDeviceIndexMappingFromConfig(std::string id) {
const std::string mappingCvarKey = "gControllers.DeviceMappings." + id;
const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".DeviceMappings." + id;
const std::string mappingClass =
CVarGetString(StringHelper::Sprintf("%s.DeviceMappingClass", mappingCvarKey.c_str()).c_str(), "");

Expand Down Expand Up @@ -184,10 +184,10 @@ void ShipDeviceIndexMappingManager::UpdateExtensionTypesFromConfig() {
// for each controller (especially compared to include/exclude locations in rando), and
// the audio editor pattern doesn't work for this because that looks for ids that are either
// hardcoded or provided by an otr file
std::stringstream mappingIdsStringStream(CVarGetString("gControllers.DeviceMappingIds", ""));
std::stringstream mappingIdsStringStream(CVarGetString(CVAR_PREFIX_CONTROLLERS ".DeviceMappingIds", ""));
std::string mappingIdString;
while (getline(mappingIdsStringStream, mappingIdString, ',')) {
const std::string mappingCvarKey = "gControllers.DeviceMappings." + mappingIdString;
const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".DeviceMappings." + mappingIdString;
const std::string mappingClass =
CVarGetString(StringHelper::Sprintf("%s.DeviceMappingClass", mappingCvarKey.c_str()).c_str(), "");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ std::string ShipDeviceIndexToWiiUDeviceIndexMapping::GetWiiUControllerName() {
}

void ShipDeviceIndexToWiiUDeviceIndexMapping::SaveToConfig() {
const std::string mappingCvarKey = "gControllers.DeviceMappings." + GetMappingId();
const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".DeviceMappings." + GetMappingId();
CVarSetString(StringHelper::Sprintf("%s.DeviceMappingClass", mappingCvarKey.c_str()).c_str(),
"ShipDeviceIndexToWiiUDeviceIndexMapping");
CVarSetInteger(StringHelper::Sprintf("%s.ShipDeviceIndex", mappingCvarKey.c_str()).c_str(), mShipDeviceIndex);
Expand All @@ -88,7 +88,7 @@ void ShipDeviceIndexToWiiUDeviceIndexMapping::SaveToConfig() {
}

void ShipDeviceIndexToWiiUDeviceIndexMapping::EraseFromConfig() {
const std::string mappingCvarKey = "gControllers.DeviceMappings." + GetMappingId();
const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".DeviceMappings." + GetMappingId();

CVarClear(StringHelper::Sprintf("%s.DeviceMappingClass", mappingCvarKey.c_str()).c_str());
CVarClear(StringHelper::Sprintf("%s.ShipDeviceIndex", mappingCvarKey.c_str()).c_str());
Expand Down

0 comments on commit 02709ce

Please sign in to comment.