MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / Deserialize

Method Deserialize

Source/Engine/Input/Input.cpp:99–164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97}
98
99void InputSettings::Deserialize(DeserializeStream& stream, ISerializeModifier* modifier)
100{
101 PROFILE_MEM(Input);
102 const auto actionMappings = stream.FindMember("ActionMappings");
103 if (actionMappings != stream.MemberEnd())
104 {
105 auto& actionMappingsArray = actionMappings->value;
106 if (actionMappingsArray.IsArray())
107 {
108 ActionMappings.Resize(actionMappingsArray.Size(), false);
109 for (uint32 i = 0; i < actionMappingsArray.Size(); i++)
110 {
111 auto& v = actionMappingsArray[i];
112 if (!v.IsObject())
113 continue;
114
115 ActionConfig& config = ActionMappings[i];
116 config.Name = JsonTools::GetString(v, "Name");
117 config.Mode = JsonTools::GetEnum(v, "Mode", InputActionMode::Pressing);
118 config.Key = JsonTools::GetEnum(v, "Key", KeyboardKeys::None);
119 config.MouseButton = JsonTools::GetEnum(v, "MouseButton", MouseButton::None);
120 config.GamepadButton = JsonTools::GetEnum(v, "GamepadButton", GamepadButton::None);
121 config.Gamepad = JsonTools::GetEnum(v, "Gamepad", InputGamepadIndex::All);
122 config.DeadZone = JsonTools::GetFloat(v, "DeadZone", 0.5f);
123 }
124 }
125 else
126 {
127 ActionMappings.Resize(0, false);
128 }
129 }
130
131 const auto axisMappings = stream.FindMember("AxisMappings");
132 if (axisMappings != stream.MemberEnd())
133 {
134 auto& axisMappingsArray = axisMappings->value;
135 if (axisMappingsArray.IsArray())
136 {
137 AxisMappings.Resize(axisMappingsArray.Size(), false);
138 for (uint32 i = 0; i < axisMappingsArray.Size(); i++)
139 {
140 auto& v = axisMappingsArray[i];
141 if (!v.IsObject())
142 continue;
143
144 AxisConfig& config = AxisMappings[i];
145 config.Name = JsonTools::GetString(v, "Name");
146 config.Axis = JsonTools::GetEnum(v, "Axis", InputAxisType::MouseX);
147 config.Gamepad = JsonTools::GetEnum(v, "Gamepad", InputGamepadIndex::All);
148 config.PositiveButton = JsonTools::GetEnum(v, "PositiveButton", KeyboardKeys::None);
149 config.NegativeButton = JsonTools::GetEnum(v, "NegativeButton", KeyboardKeys::None);
150 config.GamepadPositiveButton = JsonTools::GetEnum(v, "GamepadPositiveButton", GamepadButton::None);
151 config.GamepadNegativeButton = JsonTools::GetEnum(v, "GamepadNegativeButton", GamepadButton::None);
152 config.DeadZone = JsonTools::GetFloat(v, "DeadZone", 0.1f);
153 config.Sensitivity = JsonTools::GetFloat(v, "Sensitivity", 0.4f);
154 config.Gravity = JsonTools::GetFloat(v, "Gravity", 1.0f);
155 config.Scale = JsonTools::GetFloat(v, "Scale", 1.0f);
156 config.Snap = JsonTools::GetBool(v, "Snap", false);

Callers

nothing calls this directly

Calls 8

GetEnumFunction · 0.85
FindMemberMethod · 0.80
MemberEndMethod · 0.80
GetStringFunction · 0.50
GetFloatFunction · 0.50
GetBoolFunction · 0.50
ResizeMethod · 0.45
SizeMethod · 0.45

Tested by

no test coverage detected