/// <summary> /// Clears all relative states /// </summary> public void Clear() { KeyEvents.Clear(); MouseEvents.Clear(); KeyCharPresses.Clear(); WheelDelta = 0.0f; Events.Clear(); KeysDownThisFrame.Clear(); MouseButtonsDownThisFrame.Clear(); }
public void CopyTo(InputSnapshot other) { other.KeyEvents = KeyEvents.ToList(); other.MouseEvents = MouseEvents.ToList(); other.KeyCharPresses = KeyCharPresses.ToList(); other.MousePosition = MousePosition; other.WheelDelta = WheelDelta; other.Events = Events.ToList(); //Don't copy the dictionary every time, just update the states //This avoids allocating a lot of memory every frame foreach (var entry in Keys.Keys) { other.Keys[entry] = Keys[entry]; } foreach (var entry in MouseButtons.Keys) { other.MouseButtons[entry] = MouseButtons[entry]; } other.KeysDownThisFrame.Clear(); other.MouseButtonsDownThisFrame.Clear(); foreach (var entry in KeysDownThisFrame) { other.KeysDownThisFrame.Add(entry); } foreach (var entry in MouseButtonsDownThisFrame) { other.MouseButtonsDownThisFrame.Add(entry); } }