MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / LoadKeys

Method LoadKeys

engine/Poseidon/Input/InputSubsystem.cpp:1024–1082  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1022}
1023void InputSubsystem::LoadKeys()
1024{
1025 // contextControls.cfg owns all action bindings.
1026 ContextControlsConfig contextControls;
1027 const std::string contextControlsPath = ContextControlsCfgPath();
1028 if (!contextControls.Load(contextControlsPath))
1029 {
1030 contextControls.LoadDefaults();
1031 contextControls.Save(contextControlsPath);
1032 }
1033 profiles_ = contextControls.profiles;
1034
1035 // GInput.userKeys is no longer a persistence source. Keep it empty so
1036 // leftover controls.cfg/gamepad.cfg files cannot leak bindings into the
1037 // active context profile path.
1038 for (int i = 0; i < UAN; i++)
1039 {
1040 GInput.userKeys[i].Resize(0);
1041 GInput.userKeysModifiers[i].Resize(0);
1042 }
1043
1044 // gamepad.cfg owns the four tuning scalars only.
1045 GamepadConfig gamepad;
1046 const std::string gamepadPath = GamepadCfgPath();
1047 if (!gamepad.Load(gamepadPath))
1048 {
1049 gamepad.LoadDefaults();
1050 gamepad.Save(gamepadPath);
1051 }
1052 gamepad.Normalize();
1053
1054 // Mouse scalars — mouse.cfg. Same eager-write-on-miss posture.
1055 MouseConfig mouse;
1056 const std::string mousePath = MouseCfgPath();
1057 if (!mouse.Load(mousePath))
1058 {
1059 mouse.LoadDefaults();
1060 mouse.Save(mousePath);
1061 }
1062 mouse.Normalize();
1063 GInput.mouse.reverseY = mouse.reverseY;
1064 GInput.mouse.buttonsReversed = mouse.buttonsReversed;
1065 GInput.mouse.sensitivityX = mouse.sensitivityX;
1066 GInput.mouse.sensitivityY = mouse.sensitivityY;
1067 GInput.mouse.tuning.baseScale = mouse.baseScale;
1068 GInput.mouse.tuning.dpiNormalize = mouse.dpiNormalize;
1069 GInput.mouse.tuning.mouseDpi = mouse.mouseDpi;
1070 GInput.mouse.tuning.referenceDpi = mouse.referenceDpi;
1071 GInput.mouse.tuning.smoothing = mouse.smoothing;
1072 GInput.mouse.tuning.acceleration = mouse.acceleration;
1073 GInput.mouse.tuning.accelExponent = mouse.accelExponent;
1074 GInput.mouse.tuning.menuCursorScale = mouse.menuCursorScale;
1075 GInput.mouse.tuning.extendedRange = mouse.extendedRange;
1076
1077 GInput.gamepad.enabled = gamepad.enabled;
1078 GInput.gamepad.reverseYStick = gamepad.reverseYStick;
1079 GInput.gamepad.deadzoneStick = gamepad.deadzoneStick;
1080 GInput.gamepad.deadzoneTrigger = gamepad.deadzoneTrigger;
1081 GInput.gamepad.lookSensitivity = gamepad.lookSensitivity;

Callers 2

UpdateUserProfileFunction · 0.80
InitMethod · 0.80

Calls 8

ContextControlsCfgPathFunction · 0.85
GamepadCfgPathFunction · 0.85
MouseCfgPathFunction · 0.85
LoadMethod · 0.45
LoadDefaultsMethod · 0.45
SaveMethod · 0.45
ResizeMethod · 0.45
NormalizeMethod · 0.45

Tested by

no test coverage detected