|
| 1 | +#include "GlobalSDLDeviceSettings.h" |
| 2 | + |
| 3 | +#include <string> |
| 4 | +#include "utils/StringHelper.h" |
| 5 | +#include "public/bridge/consolevariablebridge.h" |
| 6 | + |
| 7 | +namespace Ship { |
| 8 | +GlobalSDLDeviceSettings::GlobalSDLDeviceSettings() { |
| 9 | + const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".GlobalSDLDeviceSettings"; |
| 10 | + const int32_t defaultAxisThresholdPercentage = 25; |
| 11 | + mStickAxisThresholdPercentage = CVarGetInteger(StringHelper::Sprintf("%s.StickAxisThresholdPercentage", mappingCvarKey.c_str()).c_str(), defaultAxisThresholdPercentage); |
| 12 | + mTriggerAxisThresholdPercentage = CVarGetInteger(StringHelper::Sprintf("%s.TriggerAxisThresholdPercentage", mappingCvarKey.c_str()).c_str(), defaultAxisThresholdPercentage); |
| 13 | +} |
| 14 | + |
| 15 | +GlobalSDLDeviceSettings::~GlobalSDLDeviceSettings() { |
| 16 | +} |
| 17 | + |
| 18 | +int32_t GlobalSDLDeviceSettings::GetStickAxisThresholdPercentage() { |
| 19 | + return mStickAxisThresholdPercentage; |
| 20 | +} |
| 21 | + |
| 22 | +void GlobalSDLDeviceSettings::SetStickAxisThresholdPercentage(int32_t stickAxisThresholdPercentage) { |
| 23 | + mStickAxisThresholdPercentage = stickAxisThresholdPercentage; |
| 24 | +} |
| 25 | + |
| 26 | +int32_t GlobalSDLDeviceSettings::GetTriggerAxisThresholdPercentage() { |
| 27 | + return mTriggerAxisThresholdPercentage; |
| 28 | +} |
| 29 | + |
| 30 | +void GlobalSDLDeviceSettings::SetTriggerAxisThresholdPercentage(int32_t triggerAxisThresholdPercentage) { |
| 31 | + mTriggerAxisThresholdPercentage = triggerAxisThresholdPercentage; |
| 32 | +} |
| 33 | + |
| 34 | +void GlobalSDLDeviceSettings::SaveToConfig() { |
| 35 | + const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".GlobalSDLDeviceSettings"; |
| 36 | + CVarSetInteger(StringHelper::Sprintf("%s.StickAxisThresholdPercentage", mappingCvarKey.c_str()).c_str(), |
| 37 | + mStickAxisThresholdPercentage); |
| 38 | + CVarSetInteger(StringHelper::Sprintf("%s.TriggerAxisThresholdPercentage", mappingCvarKey.c_str()).c_str(), |
| 39 | + mTriggerAxisThresholdPercentage); |
| 40 | + CVarSave(); |
| 41 | +} |
| 42 | + |
| 43 | +void GlobalSDLDeviceSettings::EraseFromConfig() { |
| 44 | + const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".GlobalSDLDeviceSettings"; |
| 45 | + CVarClear(StringHelper::Sprintf("%s.StickAxisThresholdPercentage", mappingCvarKey.c_str()).c_str()); |
| 46 | + CVarClear(StringHelper::Sprintf("%s.TriggerAxisThresholdPercentage", mappingCvarKey.c_str()).c_str()); |
| 47 | + |
| 48 | + CVarSave(); |
| 49 | +} |
| 50 | +} // namespace Ship |
0 commit comments