Ejemplo n.º 1
0
        void GameControl_KeyDown(object sender, KeyEventArgs e)
        {
            XKeys xkey = KeyboardUtil.ToXna(e.KeyCode);

            if (!_keys.Contains(xkey))
            {
                _keys.Add(xkey);
            }
        }
Ejemplo n.º 2
0
        void GameControl_KeyUp(object sender, KeyEventArgs e)
        {
            XKeys xkey = KeyboardUtil.ToXna(e.KeyCode);

            if (_keys.Contains(xkey))
            {
                _keys.Remove(xkey);
            }
        }
Ejemplo n.º 3
0
        // We would like to just override ProcessKeyMessage, but our control would only intercept it
        // if it had explicit focus.  Focus is a messy issue, so instead we're going to let the parent
        // form override ProcessKeyMessage instead, and pass it along to this method.

        internal new void ProcessKeyMessage(ref Message m)
        {
            if (m.Msg == WM_KEYDOWN)
            {
                XKeys xkey = KeyboardUtil.ToXna((Keys)m.WParam);
                if (!_keys.Contains(xkey))
                {
                    _keys.Add(xkey);
                }
            }
            else if (m.Msg == WM_KEYUP)
            {
                Microsoft.Xna.Framework.Input.Keys xnaKey = KeyboardUtil.ToXna((Keys)m.WParam);
                if (_keys.Contains(xnaKey))
                {
                    _keys.Remove(xnaKey);
                }
            }

            Console.WriteLine(_keys.Count);
        }