| 1022 | } |
| 1023 | void 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; |
no test coverage detected