Exemple #1
0
 public void KeyUp(AltoKey key)
 {
     _script.AppendAction(
         new KeyAction(
             GetRelativeTimestamp(),
             key,
             false));
 }
Exemple #2
0
 public void KeyDown(AltoKey key)
 {
     _script.AppendAction(
         new KeyAction(
             GetRelativeTimestamp(),
             key,
             true));
 }
Exemple #3
0
        //
        // Keyboard and Mouse handling
        //

        /// <summary>
        /// Handle modifier keys here mostly because Windows Forms doesn't
        /// normally distinguish between left and right shift; the Alto keyboard does.
        /// CTRL is also handled here just because.
        /// </summary>
        /// <param name="m"></param>
        /// <returns></returns>
        protected override bool ProcessKeyEventArgs(ref Message m)
        {
            // Grab the scancode from the message
            int  scanCode = (int)((m.LParam.ToInt64() >> 16) & 0x1ff);
            bool down     = false;

            const int WM_KEYDOWN = 0x100;
            const int WM_KEYUP   = 0x101;

            if (m.Msg == WM_KEYDOWN)
            {
                down = true;
            }
            else if (m.Msg == WM_KEYUP)
            {
                down = false;
            }
            else
            {
                // Something else?
                return(base.ProcessKeyEventArgs(ref m));
            }

            AltoKey modifierKey = AltoKey.None;

            switch (scanCode)
            {
            case 0x2a:     // LShift
                modifierKey = AltoKey.LShift;
                break;

            case 0x36:
                modifierKey = AltoKey.RShift;
                break;

            case 0x1d:
            case 0x11d:
                modifierKey = AltoKey.CTRL;
                break;
            }

            if (modifierKey != AltoKey.None)
            {
                if (down)
                {
                    _system.Keyboard.KeyDown(modifierKey);
                }
                else
                {
                    _system.Keyboard.KeyUp(modifierKey);
                }

                return(true); // handled
            }


            return(base.ProcessKeyEventArgs(ref m));
        }
Exemple #4
0
        public void KeyUp(AltoKey key)
        {
            AltoKeyBit bits = _keyMap[key];

            _keyWords[bits.Word] &= (ushort)~bits.Bitmask;

            if (ScriptManager.IsRecording)
            {
                ScriptManager.Recorder.KeyUp(key);
            }
        }
Exemple #5
0
        public static KeyAction Parse(ulong timestamp, bool keyDown, string[] tokens)
        {
            if (tokens.Length != 3)
            {
                throw new InvalidOperationException("Invalid KeyAction syntax.");
            }

            AltoKey key = (AltoKey)Enum.Parse(typeof(AltoKey), tokens[2]);

            return(new KeyAction(timestamp, key, keyDown));
        }
        public void KeyDown(AltoKey key)
        {
            //
            // If we had been holding boot keys, release them now that a real user is pressing a key.
            if (_bootKeysPressed)
            {
                Reset();
            }

            AltoKeyBit bits = _keyMap[key];

            _keyWords[bits.Word] |= bits.Bitmask;
        }
Exemple #7
0
        public static KeyStrokeAction Parse(ulong timestamp, string[] tokens)
        {
            if (tokens.Length < 3)
            {
                throw new InvalidOperationException("Invalid KeyStroke syntax.");
            }

            AltoKey[] keys = new AltoKey[tokens.Length - 2];

            for (int i = 2; i < tokens.Length; i++)
            {
                keys[i - 2] = (AltoKey)Enum.Parse(typeof(AltoKey), tokens[i]);
            }

            return(new KeyStrokeAction(timestamp, keys));
        }
        public void KeyUp(AltoKey key)
        {
            AltoKeyBit bits = _keyMap[key];

            _keyWords[bits.Word] &= (ushort)~bits.Bitmask;
        }
Exemple #9
0
 public Keystroke(StrokeType type, AltoKey key)
 {
     Type = type;
     Key  = key;
 }
Exemple #10
0
 public KeyAction(ulong timestamp, AltoKey key, bool keyDown) : base(timestamp)
 {
     _key     = key;
     _keyDown = keyDown;
 }