Skip to content

Commit

Permalink
Add CMake functionality to allow a port to modify what LUS uses for C…
Browse files Browse the repository at this point in the history
…Var names.

Utilize CMake definitions in LUS code.
  • Loading branch information
Malkierian committed Apr 28, 2024
1 parent 54a387a commit c7ea38f
Show file tree
Hide file tree
Showing 37 changed files with 166 additions and 111 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ cmake_minimum_required(VERSION 3.24.0)
option(NON_PORTABLE "Build a non-portable version" OFF)

project(libultraship LANGUAGES C CXX)

include(cmake/cvars.cmake)

if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
enable_language(OBJCXX)
set(CMAKE_OBJC_FLAGS "${CMAKE_OBJC_FLAGS} -fobjc-arc")
Expand Down
50 changes: 50 additions & 0 deletions cmake/cvars.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
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_CONTROL_NAV "gControlNav" CACHE STRING "")
set(CVAR_CONSOLE_ENABLED "gConsoleEnabled" CACHE STRING "")
set(CVAR_CONTROLLER_CONFIGURATION_ENABLED "gControllerConfigurationEnabled" CACHE STRING "")
set(CVAR_CONTROLLER_DISCONNECTED_ENABLED "gControllerDisconnectedWindowEnabled" CACHE STRING "")
set(CVAR_CONTROLLER_REORDERING_ENABLED "gControllerReorderingWindowEnabled" CACHE STRING "")
set(CVAR_GFX_DEBUGGER_ENABLED "gGfxDebuggerEnabled" CACHE STRING "")
set(CVAR_STATS_ENABLED "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_SINK_ENABLED "gSinkEnabled" CACHE STRING "")
set(CVAR_GAME_OVERLAY_FONT "gOverlayFont" CACHE STRING "")
set(CVAR_OPEN_MENU_BAR "gOpenMenuBar" CACHE STRING "")
set(CVAR_BLOCK_CONTROLLERS "gControllers" CACHE STRING "")
set(CVAR_BLOCK_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_CONTROL_NAV="${CVAR_CONTROL_NAV}"
CVAR_CONSOLE_ENABLED="${CVAR_CONSOLE_ENABLED}"
CVAR_CONTROLLER_CONFIGURATION_ENABLED="${CVAR_CONTROLLER_CONFIGURATION_ENABLED}"
CVAR_CONTROLLER_DISCONNECTED_ENABLED="${CVAR_CONTROLLER_DISCONNECTED_ENABLED}"
CVAR_CONTROLLER_REORDERING_ENABLED="${CVAR_CONTROLLER_REORDERING_ENABLED}"
CVAR_GFX_DEBUGGER_ENABLED="${CVAR_GFX_DEBUGGER_ENABLED}"
CVAR_STATS_ENABLED="${CVAR_STATS_ENABLED}"
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_SINK_ENABLED="${CVAR_SINK_ENABLED}"
CVAR_GAME_OVERLAY_FONT="${CVAR_GAME_OVERLAY_FONT}"
CVAR_OPEN_MENU_BAR="${CVAR_OPEN_MENU_BAR}"
CVAR_BLOCK_CONTROLLERS="${CVAR_BLOCK_CONTROLLERS}"
CVAR_BLOCK_ADVANCED_RESOLUTION="${CVAR_BLOCK_ADVANCED_RESOLUTION}"
)
3 changes: 2 additions & 1 deletion src/controller/controldeck/ControlDeck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#endif
#include <imgui.h>
#include "controller/deviceindex/LUSDeviceIndexMappingManager.h"
#include "window/gui/Gui.h"

namespace LUS {

Expand Down Expand Up @@ -69,7 +70,7 @@ 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_OPEN_MENU_BAR, 0) && CVarGetInteger(CVAR_CONTROL_NAV, 0));
}

bool ControlDeck::KeyboardGameInputBlocked() {
Expand Down
6 changes: 3 additions & 3 deletions src/controller/controldevice/controller/Controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ 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_BLOCK_CONTROLLERS ".Port%d.HasConfig", mPortIndex + 1);
return CVarGetInteger(hasConfigCvarKey.c_str(), false);
}

Expand Down Expand Up @@ -108,7 +108,7 @@ void Controller::AddDefaultMappings(LUSDeviceIndex lusDeviceIndex) {
GetLeftStick()->AddDefaultMappings(lusDeviceIndex);
GetRumble()->AddDefaultMappings(lusDeviceIndex);

const std::string hasConfigCvarKey = StringHelper::Sprintf("gControllers.Port%d.HasConfig", mPortIndex + 1);
const std::string hasConfigCvarKey = StringHelper::Sprintf(CVAR_BLOCK_CONTROLLERS ".Port%d.HasConfig", mPortIndex + 1);
CVarSetInteger(hasConfigCvarKey.c_str(), true);
CVarSave();
}
Expand Down Expand Up @@ -142,7 +142,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;

Expand Down
4 changes: 4 additions & 0 deletions src/controller/controldevice/controller/Controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
#include "controller/controldevice/ControlDevice.h"
#include "controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h"

#ifndef CVAR_SIMULATED_INPUT_LAG
#define CVAR_SIMULATED_INPUT_LAG "gSimulatedInputLag"
#endif

namespace LUS {

class Controller : public ControlDevice {
Expand Down
8 changes: 4 additions & 4 deletions src/controller/controldevice/controller/ControllerButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void ControllerButton::SaveButtonMappingIdsToConfig() {
}

const std::string buttonMappingIdsCvarKey = StringHelper::Sprintf(
"gControllers.Port%d.Buttons.%sButtonMappingIds", mPortIndex + 1, GetConfigNameFromBitmask(mBitmask).c_str());
CVAR_BLOCK_CONTROLLERS ".Port%d.Buttons.%sButtonMappingIds", mPortIndex + 1, GetConfigNameFromBitmask(mBitmask).c_str());
if (buttonMappingIdListString == "") {
CVarClear(buttonMappingIdsCvarKey.c_str());
} else {
Expand All @@ -125,7 +125,7 @@ void ControllerButton::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 buttonMappingIdsCvarKey = StringHelper::Sprintf(
"gControllers.Port%d.Buttons.%sButtonMappingIds", mPortIndex + 1, GetConfigNameFromBitmask(mBitmask).c_str());
CVAR_BLOCK_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, ',')) {
Expand Down Expand Up @@ -186,7 +186,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_BLOCK_CONTROLLERS ".Port%d.HasConfig", mPortIndex + 1);
CVarSetInteger(hasConfigCvarKey.c_str(), true);
CVarSave();
return true;
Expand Down Expand Up @@ -229,7 +229,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_BLOCK_CONTROLLERS ".Port%d.HasConfig", mPortIndex + 1);
CVarSetInteger(hasConfigCvarKey.c_str(), true);
CVarSave();
return true;
Expand Down
8 changes: 4 additions & 4 deletions 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_BLOCK_CONTROLLERS ".Port%d.HasConfig", mPortIndex + 1);
CVarSetInteger(hasConfigCvarKey.c_str(), true);
CVarSave();
return true;
Expand All @@ -50,7 +50,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_BLOCK_CONTROLLERS ".Port%d.HasConfig", mPortIndex + 1);
CVarSetInteger(hasConfigCvarKey.c_str(), true);
CVarSave();
return true;
Expand All @@ -67,7 +67,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_BLOCK_CONTROLLERS ".Port%d.Gyro.GyroMappingId", mPortIndex + 1);

if (mGyroMapping == nullptr) {
CVarClear(gyroMappingIdCvarKey.c_str());
Expand All @@ -90,7 +90,7 @@ void ControllerGyro::ClearGyroMapping() {

void ControllerGyro::ReloadGyroMappingFromConfig() {
const std::string gyroMappingIdCvarKey =
StringHelper::Sprintf("gControllers.Port%d.Gyro.GyroMappingId", mPortIndex + 1);
StringHelper::Sprintf(CVAR_BLOCK_CONTROLLERS ".Port%d.Gyro.GyroMappingId", mPortIndex + 1);

std::string id = CVarGetString(gyroMappingIdCvarKey.c_str(), "");
if (id == "") {
Expand Down
6 changes: 3 additions & 3 deletions src/controller/controldevice/controller/ControllerLED.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void ControllerLED::SaveLEDMappingIdsToConfig() {
ledMappingIdListString += ",";
}

const std::string ledMappingIdsCvarKey = StringHelper::Sprintf("gControllers.Port%d.LEDMappingIds", mPortIndex + 1);
const std::string ledMappingIdsCvarKey = StringHelper::Sprintf(CVAR_BLOCK_CONTROLLERS ".Port%d.LEDMappingIds", mPortIndex + 1);
if (ledMappingIdsCvarKey == "") {
CVarClear(ledMappingIdsCvarKey.c_str());
} else {
Expand Down Expand Up @@ -97,7 +97,7 @@ 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_BLOCK_CONTROLLERS ".Port%d.LEDMappingIds", mPortIndex + 1);
std::stringstream ledMappingIdsStringStream(CVarGetString(ledMappingIdsCvarKey.c_str(), ""));
std::string ledMappingIdString;
while (getline(ledMappingIdsStringStream, ledMappingIdString, ',')) {
Expand Down Expand Up @@ -138,7 +138,7 @@ 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_BLOCK_CONTROLLERS ".Port%d.HasConfig", mPortIndex + 1);
CVarSetInteger(hasConfigCvarKey.c_str(), true);
CVarSave();
return true;
Expand Down
8 changes: 4 additions & 4 deletions src/controller/controldevice/controller/ControllerRumble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void ControllerRumble::SaveRumbleMappingIdsToConfig() {
}

const std::string rumbleMappingIdsCvarKey =
StringHelper::Sprintf("gControllers.Port%d.RumbleMappingIds", mPortIndex + 1);
StringHelper::Sprintf(CVAR_BLOCK_CONTROLLERS ".Port%d.RumbleMappingIds", mPortIndex + 1);
if (rumbleMappingIdListString == "") {
CVarClear(rumbleMappingIdsCvarKey.c_str());
} else {
Expand Down Expand Up @@ -128,7 +128,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_BLOCK_CONTROLLERS ".Port%d.RumbleMappingIds", mPortIndex + 1);
std::stringstream rumbleMappingIdsStringStream(CVarGetString(rumbleMappingIdsCvarKey.c_str(), ""));
std::string rumbleMappingIdString;
while (getline(rumbleMappingIdsStringStream, rumbleMappingIdString, ',')) {
Expand All @@ -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_BLOCK_CONTROLLERS ".Port%d.HasConfig", mPortIndex + 1);
CVarSetInteger(hasConfigCvarKey.c_str(), true);
CVarSave();
return true;
Expand All @@ -171,7 +171,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_BLOCK_CONTROLLERS ".Port%d.HasConfig", mPortIndex + 1);
CVarSetInteger(hasConfigCvarKey.c_str(), true);
CVarSave();
return true;
Expand Down
20 changes: 10 additions & 10 deletions src/controller/controldevice/controller/ControllerStick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void ControllerStick::SaveAxisDirectionMappingIdsToConfig() {
}

const std::string axisDirectionMappingIdsCvarKey = StringHelper::Sprintf(
"gControllers.Port%d.%s.%sAxisDirectionMappingIds", mPortIndex + 1, stickToConfigStickName[mStick].c_str(),
CVAR_BLOCK_CONTROLLERS ".Port%d.%s.%sAxisDirectionMappingIds", mPortIndex + 1, stickToConfigStickName[mStick].c_str(),
directionToConfigDirectionName[direction].c_str());
if (axisDirectionMappingIdListString == "") {
CVarClear(axisDirectionMappingIdsCvarKey.c_str());
Expand Down Expand Up @@ -177,7 +177,7 @@ 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(),
CVAR_BLOCK_CONTROLLERS ".Port%d.%s.%sAxisDirectionMappingIds", mPortIndex + 1, stickToConfigStickName[mStick].c_str(),
directionToConfigDirectionName[direction].c_str());

std::stringstream axisDirectionMappingIdsStringStream(
Expand All @@ -188,17 +188,17 @@ void ControllerStick::ReloadAllMappingsFromConfig() {
}
}

SetSensitivity(CVarGetInteger(StringHelper::Sprintf("gControllers.Port%d.%s.SensitivityPercentage", mPortIndex + 1,
SetSensitivity(CVarGetInteger(StringHelper::Sprintf(CVAR_BLOCK_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,
SetDeadzone(CVarGetInteger(StringHelper::Sprintf(CVAR_BLOCK_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,
SetNotchSnapAngle(CVarGetInteger(StringHelper::Sprintf(CVAR_BLOCK_CONTROLLERS ".Port%d.%s.NotchSnapAngle", mPortIndex + 1,
stickToConfigStickName[mStick].c_str())
.c_str(),
0));
Expand Down 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_BLOCK_CONTROLLERS ".Port%d.HasConfig", mPortIndex + 1);
CVarSetInteger(hasConfigCvarKey.c_str(), true);
CVarSave();
return true;
Expand Down Expand Up @@ -326,7 +326,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_BLOCK_CONTROLLERS ".Port%d.HasConfig", mPortIndex + 1);
CVarSetInteger(hasConfigCvarKey.c_str(), true);
CVarSave();
return true;
Expand Down Expand Up @@ -377,7 +377,7 @@ bool ControllerStick::ProcessKeyboardEvent(LUS::KbEventType eventType, LUS::KbSc
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_BLOCK_CONTROLLERS ".Port%d.%s.SensitivityPercentage", mPortIndex + 1,
stickToConfigStickName[mStick].c_str())
.c_str(),
mSensitivityPercentage);
Expand All @@ -399,7 +399,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_BLOCK_CONTROLLERS ".Port%d.%s.DeadzonePercentage", mPortIndex + 1,
stickToConfigStickName[mStick].c_str())
.c_str(),
mDeadzonePercentage);
Expand All @@ -420,7 +420,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_BLOCK_CONTROLLERS ".Port%d.%s.NotchSnapAngle", mPortIndex + 1,
stickToConfigStickName[mStick].c_str())
.c_str(),
mNotchSnapAngle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
namespace LUS {
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_BLOCK_CONTROLLERS ".AxisDirectionMappings." + id;
const std::string mappingClass =
CVarGetString(StringHelper::Sprintf("%s.AxisDirectionMappingClass", mappingCvarKey.c_str()).c_str(), "");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
namespace LUS {
std::shared_ptr<ControllerButtonMapping> ButtonMappingFactory::CreateButtonMappingFromConfig(uint8_t portIndex,
std::string id) {
const std::string mappingCvarKey = "gControllers.ButtonMappings." + id;
const std::string mappingCvarKey = CVAR_BLOCK_CONTROLLERS ".ButtonMappings." + id;
const std::string mappingClass =
CVarGetString(StringHelper::Sprintf("%s.ButtonMappingClass", mappingCvarKey.c_str()).c_str(), "");
CONTROLLERBUTTONS_T bitmask =
Expand Down
Loading

0 comments on commit c7ea38f

Please sign in to comment.