Exemplo n.º 1
0
        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);
            }
        }