Add CMake functionality to allow a port to modify what LUS uses for CVar names (#527)

This commit is contained in:
Malkierian
2024-04-29 23:47:24 -04:00
committed by GitHub
parent 6c375a8b5e
commit 2b7ecfaf7c
36 changed files with 175 additions and 112 deletions
+1
View File
@@ -9,6 +9,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
endif()
project(libultraship LANGUAGES C CXX)
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR CMAKE_SYSTEM_NAME STREQUAL "iOS")
enable_language(OBJCXX)
set(CMAKE_OBJC_FLAGS "${CMAKE_OBJC_FLAGS} -fobjc-arc")
+48
View File
@@ -0,0 +1,48 @@
set(CVAR_VSYNC_ENABLED "gVsyncEnabled" CACHE STRING "")
set(CVAR_Z_FIGHTING_MODE "gZFightingMode" CACHE STRING "")
set(CVAR_NEW_FILE_DROPPED "gNewFileDropped" CACHE STRING "")
set(CVAR_DROPPED_FILE "gDroppedFile" CACHE STRING "")
set(CVAR_INTERNAL_RESOLUTION "gInternalResolution" CACHE STRING "")
set(CVAR_MSAA_VALUE "gMSAAValue" CACHE STRING "")
set(CVAR_SDL_WINDOWED_FULLSCREEN "gSdlWindowedFullscreen" CACHE STRING "")
set(CVAR_TEXTURE_FILTER "gTextureFilter" CACHE STRING "")
set(CVAR_IMGUI_CONTROLLER_NAV "gControlNav" CACHE STRING "")
set(CVAR_CONSOLE_WINDOW_OPEN "gConsoleEnabled" CACHE STRING "")
set(CVAR_CONTROLLER_CONFIGURATION_WINDOW_OPEN "gControllerConfigurationEnabled" CACHE STRING "")
set(CVAR_CONTROLLER_DISCONNECTED_WINDOW_OPEN "gControllerDisconnectedWindowEnabled" CACHE STRING "")
set(CVAR_CONTROLLER_REORDERING_WINDOW_OPEN "gControllerReorderingWindowEnabled" CACHE STRING "")
set(CVAR_GFX_DEBUGGER_WINDOW_OPEN "gGfxDebuggerEnabled" CACHE STRING "")
set(CVAR_STATS_WINDOW_OPEN "gStatsEnabled" CACHE STRING "")
set(CVAR_ENABLE_MULTI_VIEWPORTS "gEnableMultiViewports" CACHE STRING "")
set(CVAR_LOW_RES_MODE "gLowResMode" CACHE STRING "")
set(CVAR_SIMULATED_INPUT_LAG "gSimulatedInputLag" CACHE STRING "")
set(CVAR_ALT_ASSETS "gAltAssets" CACHE STRING "")
set(CVAR_GAME_OVERLAY_FONT "gOverlayFont" CACHE STRING "")
set(CVAR_MENU_BAR_OPEN "gOpenMenuBar" CACHE STRING "")
set(CVAR_PREFIX_CONTROLLERS "gControllers" CACHE STRING "")
set(CVAR_PREFIX_ADVANCED_RESOLUTION "gAdvancedResolution" CACHE STRING "")
add_compile_definitions(
CVAR_VSYNC_ENABLED="${CVAR_VSYNC_ENABLED}"
CVAR_Z_FIGHTING_MODE="${CVAR_Z_FIGHTING_MODE}"
CVAR_NEW_FILE_DROPPED="${CVAR_NEW_FILE_DROPPED}"
CVAR_DROPPED_FILE="${CVAR_DROPPED_FILE}"
CVAR_INTERNAL_RESOLUTION="${CVAR_INTERNAL_RESOLUTION}"
CVAR_MSAA_VALUE="${CVAR_MSAA_VALUE}"
CVAR_SDL_WINDOWED_FULLSCREEN="${CVAR_SDL_WINDOWED_FULLSCREEN}"
CVAR_TEXTURE_FILTER="${CVAR_TEXTURE_FILTER}"
CVAR_IMGUI_CONTROLLER_NAV="${CVAR_IMGUI_CONTROLLER_NAV}"
CVAR_CONSOLE_WINDOW_OPEN="${CVAR_CONSOLE_WINDOW_OPEN}"
CVAR_CONTROLLER_CONFIGURATION_WINDOW_OPEN="${CVAR_CONTROLLER_CONFIGURATION_WINDOW_OPEN}"
CVAR_CONTROLLER_DISCONNECTED_WINDOW_OPEN="${CVAR_CONTROLLER_DISCONNECTED_WINDOW_OPEN}"
CVAR_CONTROLLER_REORDERING_WINDOW_OPEN="${CVAR_CONTROLLER_REORDERING_WINDOW_OPEN}"
CVAR_GFX_DEBUGGER_WINDOW_OPEN="${CVAR_GFX_DEBUGGER_WINDOW_OPEN}"
CVAR_STATS_WINDOW_OPEN="${CVAR_STATS_WINDOW_OPEN}"
CVAR_ENABLE_MULTI_VIEWPORTS="${CVAR_ENABLE_MULTI_VIEWPORTS}"
CVAR_LOW_RES_MODE="${CVAR_LOW_RES_MODE}"
CVAR_SIMULATED_INPUT_LAG="${CVAR_SIMULATED_INPUT_LAG}"
CVAR_ALT_ASSETS="${CVAR_ALT_ASSETS}"
CVAR_GAME_OVERLAY_FONT="${CVAR_GAME_OVERLAY_FONT}"
CVAR_MENU_BAR_OPEN="${CVAR_MENU_BAR_OPEN}"
CVAR_PREFIX_CONTROLLERS="${CVAR_PREFIX_CONTROLLERS}"
CVAR_PREFIX_ADVANCED_RESOLUTION="${CVAR_PREFIX_ADVANCED_RESOLUTION}"
)
+2
View File
@@ -1,3 +1,5 @@
include(../cmake/cvars.cmake)
add_library(libultraship STATIC)
set_target_properties(libultraship PROPERTIES PREFIX "")
set_property(TARGET libultraship PROPERTY CXX_STANDARD 20)
+2 -1
View File
@@ -65,7 +65,8 @@ bool ControlDeck::AllGameInputBlocked() {
bool ControlDeck::GamepadGameInputBlocked() {
// block controller input when using the controller to navigate imgui menus
return AllGameInputBlocked() || (CVarGetInteger("gOpenMenuBar", 0) && CVarGetInteger("gControlNav", 0));
return AllGameInputBlocked() ||
(CVarGetInteger(CVAR_MENU_BAR_OPEN, 0) && CVarGetInteger(CVAR_IMGUI_CONTROLLER_NAV, 0));
}
bool ControlDeck::KeyboardGameInputBlocked() {
@@ -70,7 +70,8 @@ uint8_t Controller::GetPortIndex() {
}
bool Controller::HasConfig() {
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);
return CVarGetInteger(hasConfigCvarKey.c_str(), false);
}
@@ -108,7 +109,8 @@ void Controller::AddDefaultMappings(ShipDeviceIndex shipDeviceIndex) {
GetLeftStick()->AddDefaultMappings(shipDeviceIndex);
GetRumble()->AddDefaultMappings(shipDeviceIndex);
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();
}
@@ -142,7 +144,7 @@ void Controller::ReadToPad(OSContPad* pad) {
mPadBuffer.push_front(padToBuffer);
if (pad != nullptr) {
auto& padFromBuffer =
mPadBuffer[std::min(mPadBuffer.size() - 1, (size_t)CVarGetInteger("gSimulatedInputLag", 0))];
mPadBuffer[std::min(mPadBuffer.size() - 1, (size_t)CVarGetInteger(CVAR_SIMULATED_INPUT_LAG, 0))];
pad->button |= padFromBuffer.button;
@@ -105,8 +105,9 @@ void ControllerButton::SaveButtonMappingIdsToConfig() {
buttonMappingIdListString += ",";
}
const std::string buttonMappingIdsCvarKey = StringHelper::Sprintf(
"gControllers.Port%d.Buttons.%sButtonMappingIds", mPortIndex + 1, GetConfigNameFromBitmask(mBitmask).c_str());
const std::string buttonMappingIdsCvarKey =
StringHelper::Sprintf(CVAR_PREFIX_CONTROLLERS ".Port%d.Buttons.%sButtonMappingIds", mPortIndex + 1,
GetConfigNameFromBitmask(mBitmask).c_str());
if (buttonMappingIdListString == "") {
CVarClear(buttonMappingIdsCvarKey.c_str());
} else {
@@ -124,8 +125,9 @@ void ControllerButton::ReloadAllMappingsFromConfig() {
// 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
const std::string buttonMappingIdsCvarKey = StringHelper::Sprintf(
"gControllers.Port%d.Buttons.%sButtonMappingIds", mPortIndex + 1, GetConfigNameFromBitmask(mBitmask).c_str());
const std::string buttonMappingIdsCvarKey =
StringHelper::Sprintf(CVAR_PREFIX_CONTROLLERS ".Port%d.Buttons.%sButtonMappingIds", mPortIndex + 1,
GetConfigNameFromBitmask(mBitmask).c_str());
std::stringstream buttonMappingIdsStringStream(CVarGetString(buttonMappingIdsCvarKey.c_str(), ""));
std::string buttonMappingIdString;
while (getline(buttonMappingIdsStringStream, buttonMappingIdString, ',')) {
@@ -196,7 +198,8 @@ 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;
@@ -31,7 +31,8 @@ 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;
@@ -47,7 +48,7 @@ void ControllerGyro::UpdatePad(float& x, float& y) {
void ControllerGyro::SaveGyroMappingIdToConfig() {
const std::string gyroMappingIdCvarKey =
StringHelper::Sprintf("gControllers.Port%d.Gyro.GyroMappingId", mPortIndex + 1);
StringHelper::Sprintf(CVAR_PREFIX_CONTROLLERS ".Port%d.Gyro.GyroMappingId", mPortIndex + 1);
if (mGyroMapping == nullptr) {
CVarClear(gyroMappingIdCvarKey.c_str());
@@ -70,7 +71,7 @@ void ControllerGyro::ClearGyroMapping() {
void ControllerGyro::ReloadGyroMappingFromConfig() {
const std::string gyroMappingIdCvarKey =
StringHelper::Sprintf("gControllers.Port%d.Gyro.GyroMappingId", mPortIndex + 1);
StringHelper::Sprintf(CVAR_PREFIX_CONTROLLERS ".Port%d.Gyro.GyroMappingId", mPortIndex + 1);
std::string id = CVarGetString(gyroMappingIdCvarKey.c_str(), "");
if (id == "") {
@@ -28,7 +28,8 @@ void ControllerLED::SaveLEDMappingIdsToConfig() {
ledMappingIdListString += ",";
}
const std::string ledMappingIdsCvarKey = StringHelper::Sprintf("gControllers.Port%d.LEDMappingIds", mPortIndex + 1);
const std::string ledMappingIdsCvarKey =
StringHelper::Sprintf(CVAR_PREFIX_CONTROLLERS ".Port%d.LEDMappingIds", mPortIndex + 1);
if (ledMappingIdsCvarKey == "") {
CVarClear(ledMappingIdsCvarKey.c_str());
} else {
@@ -97,7 +98,8 @@ void ControllerLED::ReloadAllMappingsFromConfig() {
// 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
const std::string ledMappingIdsCvarKey = StringHelper::Sprintf("gControllers.Port%d.LEDMappingIds", mPortIndex + 1);
const std::string ledMappingIdsCvarKey =
StringHelper::Sprintf(CVAR_PREFIX_CONTROLLERS ".Port%d.LEDMappingIds", mPortIndex + 1);
std::stringstream ledMappingIdsStringStream(CVarGetString(ledMappingIdsCvarKey.c_str(), ""));
std::string ledMappingIdString;
while (getline(ledMappingIdsStringStream, ledMappingIdString, ',')) {
@@ -121,7 +123,8 @@ bool ControllerLED::AddLEDMappingFromRawPress() {
AddLEDMapping(mapping);
mapping->SaveToConfig();
SaveLEDMappingIdsToConfig();
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;
@@ -34,7 +34,7 @@ void ControllerRumble::SaveRumbleMappingIdsToConfig() {
}
const std::string rumbleMappingIdsCvarKey =
StringHelper::Sprintf("gControllers.Port%d.RumbleMappingIds", mPortIndex + 1);
StringHelper::Sprintf(CVAR_PREFIX_CONTROLLERS ".Port%d.RumbleMappingIds", mPortIndex + 1);
if (rumbleMappingIdListString == "") {
CVarClear(rumbleMappingIdsCvarKey.c_str());
} else {
@@ -115,7 +115,7 @@ void ControllerRumble::ReloadAllMappingsFromConfig() {
// the audio editor pattern doesn't work for this because that looks for ids that are either
// hardcoded or provided by an otr file
const std::string rumbleMappingIdsCvarKey =
StringHelper::Sprintf("gControllers.Port%d.RumbleMappingIds", mPortIndex + 1);
StringHelper::Sprintf(CVAR_PREFIX_CONTROLLERS ".Port%d.RumbleMappingIds", mPortIndex + 1);
std::stringstream rumbleMappingIdsStringStream(CVarGetString(rumbleMappingIdsCvarKey.c_str(), ""));
std::string rumbleMappingIdString;
while (getline(rumbleMappingIdsStringStream, rumbleMappingIdString, ',')) {
@@ -139,7 +139,8 @@ 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;
@@ -88,8 +88,8 @@ void ControllerStick::SaveAxisDirectionMappingIdsToConfig() {
}
const std::string axisDirectionMappingIdsCvarKey = StringHelper::Sprintf(
"gControllers.Port%d.%s.%sAxisDirectionMappingIds", mPortIndex + 1, stickToConfigStickName[mStick].c_str(),
directionToConfigDirectionName[direction].c_str());
CVAR_PREFIX_CONTROLLERS ".Port%d.%s.%sAxisDirectionMappingIds", mPortIndex + 1,
stickToConfigStickName[mStick].c_str(), directionToConfigDirectionName[direction].c_str());
if (axisDirectionMappingIdListString == "") {
CVarClear(axisDirectionMappingIdsCvarKey.c_str());
} else {
@@ -162,8 +162,8 @@ void ControllerStick::ReloadAllMappingsFromConfig() {
// hardcoded or provided by an otr file
for (auto direction : { LEFT, RIGHT, UP, DOWN }) {
const std::string axisDirectionMappingIdsCvarKey = StringHelper::Sprintf(
"gControllers.Port%d.%s.%sAxisDirectionMappingIds", mPortIndex + 1, stickToConfigStickName[mStick].c_str(),
directionToConfigDirectionName[direction].c_str());
CVAR_PREFIX_CONTROLLERS ".Port%d.%s.%sAxisDirectionMappingIds", mPortIndex + 1,
stickToConfigStickName[mStick].c_str(), directionToConfigDirectionName[direction].c_str());
std::stringstream axisDirectionMappingIdsStringStream(
CVarGetString(axisDirectionMappingIdsCvarKey.c_str(), ""));
@@ -173,18 +173,18 @@ void ControllerStick::ReloadAllMappingsFromConfig() {
}
}
SetSensitivity(CVarGetInteger(StringHelper::Sprintf("gControllers.Port%d.%s.SensitivityPercentage", mPortIndex + 1,
stickToConfigStickName[mStick].c_str())
SetSensitivity(CVarGetInteger(StringHelper::Sprintf(CVAR_PREFIX_CONTROLLERS ".Port%d.%s.SensitivityPercentage",
mPortIndex + 1, stickToConfigStickName[mStick].c_str())
.c_str(),
DEFAULT_STICK_SENSITIVITY_PERCENTAGE));
SetDeadzone(CVarGetInteger(StringHelper::Sprintf("gControllers.Port%d.%s.DeadzonePercentage", mPortIndex + 1,
stickToConfigStickName[mStick].c_str())
SetDeadzone(CVarGetInteger(StringHelper::Sprintf(CVAR_PREFIX_CONTROLLERS ".Port%d.%s.DeadzonePercentage",
mPortIndex + 1, stickToConfigStickName[mStick].c_str())
.c_str(),
DEFAULT_STICK_DEADZONE_PERCENTAGE));
SetNotchSnapAngle(CVarGetInteger(StringHelper::Sprintf("gControllers.Port%d.%s.NotchSnapAngle", mPortIndex + 1,
stickToConfigStickName[mStick].c_str())
SetNotchSnapAngle(CVarGetInteger(StringHelper::Sprintf(CVAR_PREFIX_CONTROLLERS ".Port%d.%s.NotchSnapAngle",
mPortIndex + 1, stickToConfigStickName[mStick].c_str())
.c_str(),
0));
}
@@ -289,7 +289,8 @@ 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;
@@ -337,7 +338,7 @@ bool ControllerStick::ProcessKeyboardEvent(Ship::KbEventType eventType, Ship::Kb
void ControllerStick::SetSensitivity(uint8_t sensitivityPercentage) {
mSensitivityPercentage = sensitivityPercentage;
mSensitivity = sensitivityPercentage / 100.0f;
CVarSetInteger(StringHelper::Sprintf("gControllers.Port%d.%s.SensitivityPercentage", mPortIndex + 1,
CVarSetInteger(StringHelper::Sprintf(CVAR_PREFIX_CONTROLLERS ".Port%d.%s.SensitivityPercentage", mPortIndex + 1,
stickToConfigStickName[mStick].c_str())
.c_str(),
mSensitivityPercentage);
@@ -359,7 +360,7 @@ bool ControllerStick::SensitivityIsDefault() {
void ControllerStick::SetDeadzone(uint8_t deadzonePercentage) {
mDeadzonePercentage = deadzonePercentage;
mDeadzone = MAX_AXIS_RANGE * (deadzonePercentage / 100.0f);
CVarSetInteger(StringHelper::Sprintf("gControllers.Port%d.%s.DeadzonePercentage", mPortIndex + 1,
CVarSetInteger(StringHelper::Sprintf(CVAR_PREFIX_CONTROLLERS ".Port%d.%s.DeadzonePercentage", mPortIndex + 1,
stickToConfigStickName[mStick].c_str())
.c_str(),
mDeadzonePercentage);
@@ -380,7 +381,7 @@ bool ControllerStick::DeadzoneIsDefault() {
void ControllerStick::SetNotchSnapAngle(uint8_t notchSnapAngle) {
mNotchSnapAngle = notchSnapAngle;
CVarSetInteger(StringHelper::Sprintf("gControllers.Port%d.%s.NotchSnapAngle", mPortIndex + 1,
CVarSetInteger(StringHelper::Sprintf(CVAR_PREFIX_CONTROLLERS ".Port%d.%s.NotchSnapAngle", mPortIndex + 1,
stickToConfigStickName[mStick].c_str())
.c_str(),
mNotchSnapAngle);
@@ -12,7 +12,7 @@
namespace Ship {
std::shared_ptr<ControllerAxisDirectionMapping>
AxisDirectionMappingFactory::CreateAxisDirectionMappingFromConfig(uint8_t portIndex, Stick stick, std::string id) {
const std::string mappingCvarKey = "gControllers.AxisDirectionMappings." + id;
const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".AxisDirectionMappings." + id;
const std::string mappingClass =
CVarGetString(StringHelper::Sprintf("%s.AxisDirectionMappingClass", mappingCvarKey.c_str()).c_str(), "");
@@ -11,7 +11,7 @@
namespace Ship {
std::shared_ptr<ControllerButtonMapping> ButtonMappingFactory::CreateButtonMappingFromConfig(uint8_t portIndex,
std::string id) {
const std::string mappingCvarKey = "gControllers.ButtonMappings." + id;
const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".ButtonMappings." + id;
const std::string mappingClass =
CVarGetString(StringHelper::Sprintf("%s.ButtonMappingClass", mappingCvarKey.c_str()).c_str(), "");
CONTROLLERBUTTONS_T bitmask =
@@ -9,7 +9,7 @@
namespace Ship {
std::shared_ptr<ControllerGyroMapping> GyroMappingFactory::CreateGyroMappingFromConfig(uint8_t portIndex,
std::string id) {
const std::string mappingCvarKey = "gControllers.GyroMappings." + id;
const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".GyroMappings." + id;
const std::string mappingClass =
CVarGetString(StringHelper::Sprintf("%s.GyroMappingClass", mappingCvarKey.c_str()).c_str(), "");
@@ -8,7 +8,7 @@
namespace Ship {
std::shared_ptr<ControllerLEDMapping> LEDMappingFactory::CreateLEDMappingFromConfig(uint8_t portIndex, std::string id) {
const std::string mappingCvarKey = "gControllers.LEDMappings." + id;
const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".LEDMappings." + id;
const std::string mappingClass =
CVarGetString(StringHelper::Sprintf("%s.LEDMappingClass", mappingCvarKey.c_str()).c_str(), "");
@@ -9,7 +9,7 @@
namespace Ship {
std::shared_ptr<ControllerRumbleMapping> RumbleMappingFactory::CreateRumbleMappingFromConfig(uint8_t portIndex,
std::string id) {
const std::string mappingCvarKey = "gControllers.RumbleMappings." + id;
const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".RumbleMappings." + id;
const std::string mappingClass =
CVarGetString(StringHelper::Sprintf("%s.RumbleMappingClass", mappingCvarKey.c_str()).c_str(), "");
@@ -26,7 +26,7 @@ std::string KeyboardKeyToAxisDirectionMapping::GetAxisDirectionMappingId() {
}
void KeyboardKeyToAxisDirectionMapping::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(),
"KeyboardKeyToAxisDirectionMapping");
CVarSetInteger(StringHelper::Sprintf("%s.Stick", mappingCvarKey.c_str()).c_str(), mStick);
@@ -36,7 +36,7 @@ void KeyboardKeyToAxisDirectionMapping::SaveToConfig() {
}
void KeyboardKeyToAxisDirectionMapping::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());
@@ -32,7 +32,7 @@ std::string KeyboardKeyToButtonMapping::GetButtonMappingId() {
}
void KeyboardKeyToButtonMapping::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(),
"KeyboardKeyToButtonMapping");
CVarSetInteger(StringHelper::Sprintf("%s.Bitmask", mappingCvarKey.c_str()).c_str(), mBitmask);
@@ -41,7 +41,7 @@ void KeyboardKeyToButtonMapping::SaveToConfig() {
}
void KeyboardKeyToButtonMapping::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());
@@ -45,7 +45,7 @@ std::string SDLAxisDirectionToAxisDirectionMapping::GetAxisDirectionMappingId()
}
void SDLAxisDirectionToAxisDirectionMapping::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(),
"SDLAxisDirectionToAxisDirectionMapping");
CVarSetInteger(StringHelper::Sprintf("%s.Stick", mappingCvarKey.c_str()).c_str(), mStick);
@@ -58,7 +58,7 @@ void SDLAxisDirectionToAxisDirectionMapping::SaveToConfig() {
}
void SDLAxisDirectionToAxisDirectionMapping::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());
@@ -56,7 +56,7 @@ std::string SDLAxisDirectionToButtonMapping::GetButtonMappingId() {
}
void SDLAxisDirectionToButtonMapping::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(),
"SDLAxisDirectionToButtonMapping");
CVarSetInteger(StringHelper::Sprintf("%s.Bitmask", mappingCvarKey.c_str()).c_str(), mBitmask);
@@ -68,7 +68,7 @@ void SDLAxisDirectionToButtonMapping::SaveToConfig() {
}
void SDLAxisDirectionToButtonMapping::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());
CVarClear(StringHelper::Sprintf("%s.ShipDeviceIndex", mappingCvarKey.c_str()).c_str());
@@ -31,7 +31,7 @@ std::string SDLButtonToAxisDirectionMapping::GetAxisDirectionMappingId() {
}
void SDLButtonToAxisDirectionMapping::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(),
"SDLButtonToAxisDirectionMapping");
CVarSetInteger(StringHelper::Sprintf("%s.Stick", mappingCvarKey.c_str()).c_str(), mStick);
@@ -43,7 +43,7 @@ void SDLButtonToAxisDirectionMapping::SaveToConfig() {
}
void SDLButtonToAxisDirectionMapping::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());

Some files were not shown because too many files have changed in this diff Show More