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{
1023 GInput.keyboard.ForgetKeys();
1024
1025 for (int i = 0; i < N_JOYSTICK_AXES; i++)
1026 {
1027 GInput.gamepad.jAxisLastActive[i] = Glob.uiTime - 120;
1028 GInput.gamepad.jAxisBigLastActive[i] = Glob.uiTime - 120;
1029 }
1030
1031 GInput.gamepad.moveLastActive = Glob.uiTime - 1;
1032 GInput.keyboard.moveLastActive = Glob.uiTime + 5;
1033 GInput.mouse.cursorLastActive = Glob.uiTime - 1;
1034 GInput.mouse.turnLastActive = Glob.uiTime - 1;
1035 GInput.keyboard.cursorLastActive = Glob.uiTime;
1036 GInput.keyboard.turnLastActive = Glob.uiTime;
1037 GInput.cursor.aimDeltaX = GInput.cursor.aimDeltaY = GInput.cursor.aimDeltaZ = 0;
1038}
1039void InputSubsystem::LoadKeys()
1040{
1041 // contextControls.cfg owns all action bindings.
1042 ContextControlsConfig contextControls;
1043 const std::string contextControlsPath = ContextControlsCfgPath();
1044 if (!contextControls.Load(contextControlsPath))
1045 {
1046 contextControls.LoadDefaults();
1047 contextControls.Save(contextControlsPath);
1048 }
1049 else if (contextControls.migratedOnLoad)
1050 {
1051 contextControls.Save(contextControlsPath);
1052 }
1053 profiles_ = contextControls.profiles;
1054
1055 // GInput.userKeys is no longer a persistence source. Keep it empty so
1056 // leftover controls.cfg/gamepad.cfg files cannot leak bindings into the
1057 // active context profile path.
1058 for (int i = 0; i < UAN; i++)
1059 {
1060 GInput.userKeys[i].Resize(0);
1061 GInput.userKeysModifiers[i].Resize(0);
1062 }
1063
1064 // gamepad.cfg owns the four tuning scalars only.
1065 GamepadConfig gamepad;
1066 const std::string gamepadPath = GamepadCfgPath();
1067 if (!gamepad.Load(gamepadPath))
1068 {
1069 gamepad.LoadDefaults();
1070 gamepad.Save(gamepadPath);
1071 }
1072 gamepad.Normalize();
1073
1074 // Mouse scalars — mouse.cfg. Same eager-write-on-miss posture.
1075 MouseConfig mouse;
1076 const std::string mousePath = MouseCfgPath();
1077 if (!mouse.Load(mousePath))
1078 {
1079 mouse.LoadDefaults();
1080 mouse.Save(mousePath);
1081 }

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