Exemplo n.º 1
0
        private void InternalOnRawKeyReleased(object sender, InputDevice.KeyControlEventArgs e)
        {
            Debug.WriteLine("RELEASE: " + ((Keys)e.Keyboard.key).ToString());

            string lockTo = CollectionHelper.ReadValue<string>(_config, "lock_to", null);
            if (lockTo != null && e.Keyboard.deviceName != lockTo)
                return;

            lock (_buffer)
            {
                Keys myKey = (Keys)e.Keyboard.key;
                if (myKey == Keys.Menu)
                {
                    CheckBuffer();
                    _isAsciiKeyPressed = false;
                }
                else if ((myKey & Keys.Modifiers) == Keys.None && _isAsciiKeyPressed == false)
                {
                    if (OnDataReceived != null)
                    {
                        byte b = ConvertToString(myKey); 
                        if(b != 0)
                            OnDataReceived(new byte[] { b }, 1);
                    }
                    
                }
                else
                    _buffer.Add((Keys)e.Keyboard.key);
            }

        }
Exemplo n.º 2
0
#pragma warning restore 067

        public void SetupCommunication(IDictionary setup)
        {
            _config = setup;

            if (_config == null)
                _config = new Hashtable();

            lock (typeof(HIDComm))
            {
                if (_inputDevice == null)
                {
                    _inputDevice = new InputDevice(this.Handle);
                    _inputDevice.EnumerateDevices();
                }
            }

            _inputDevice.KeyDown += new InputDevice.DeviceEventHandler(InternalOnRawKeyPress);
            _inputDevice.KeyUp += new InputDevice.DeviceEventHandler(InternalOnRawKeyReleased);
        }
Exemplo n.º 3
0
        private void InternalOnRawKeyPress(object sender, InputDevice.KeyControlEventArgs e)
        {
            Debug.WriteLine(string.Format("PRESS[{0}]: {1}", e.Keyboard.deviceName,
			                              ((Keys)e.Keyboard.key).ToString()));

            string lockTo = CollectionHelper.ReadValue<string>(_config, "lock_to", null);
            if (lockTo != null && e.Keyboard.deviceName != lockTo)
                return;

            if ((Keys)e.Keyboard.key == Keys.Menu)
            {

                _isAsciiKeyPressed = true;
                
                lock (_buffer)
                    _buffer.Clear();
            }

        }