コード例 #1
0
        public void Press(KeyScanCode scanCode)
        {
            var key = PS2ScanCodeTranslator.Instance.GetCode(scanCode);

            data.Enqueue((byte)(key & 0x7f));
            NotifyParent();
        }
コード例 #2
0
        public void Press(KeyScanCode scanCode)
        {
            this.Log(LogLevel.Error, "Pressed key {0}", scanCode);
            var key = PS2ScanCodeTranslator.Instance.GetCode(scanCode);

            data.Enqueue((byte)(key & 0x7f));
            NotifyParent();
        }
コード例 #3
0
        private void ReleaseInner(KeyScanCode scanCode)
        {
            var key = PS2ScanCodeTranslator.Instance.GetCode(scanCode);

            data.Enqueue((byte)Command.Release);
            data.Enqueue((byte)(key & 0x7f));
            NotifyParent();
        }
コード例 #4
0
 public void Release(KeyScanCode scanCode)
 {
     if (!UpdateModifiers(scanCode, false))
     {
         pressedKey = 0;
     }
     SendPacket();
 }
コード例 #5
0
 public void Press(KeyScanCode scanCode)
 {
     if (!UpdateModifiers(scanCode, true))
     {
         pressedKey = (byte)((int)scanCode & 0x7f);
     }
     SendPacket();
 }
コード例 #6
0
ファイル: PS2ScanCodeTranslator.cs プロジェクト: rte-se/emul8
 public int GetCode(KeyScanCode scanCode)
 {
     int result;
     if(!mapping.TryGetValue(scanCode, out result))
     {
         result = 0;
     }
     return result;
 }
コード例 #7
0
 private bool UpdateModifiers(KeyScanCode scanCode, bool set)
 {
     if (scanCode >= KeyScanCode.CtrlL && scanCode <= KeyScanCode.WinR)
     {
         BitHelper.SetBit(ref modifiers, (byte)((int)scanCode & 0x7), set);
         return(true);
     }
     return(false);
 }
コード例 #8
0
 public void Release(KeyScanCode scanCode)
 {
     this.Log(LogLevel.Noisy, "Releasing {0}", scanCode);
     if (!UpdateModifiers(scanCode, false))
     {
         pressedKey = 0;
     }
     SendPacket();
 }
コード例 #9
0
 public void Press(KeyScanCode scanCode)
 {
     this.Log(LogLevel.Noisy, "Pressing {0}", scanCode);
     if (!UpdateModifiers(scanCode, true))
     {
         pressedKey = (byte)((int)scanCode & 0x7f);
     }
     SendPacket();
 }
コード例 #10
0
        public void Release(KeyScanCode scanCode)
        {
            this.Log(LogLevel.Noisy, "Released key {0}", scanCode);
            var key = PS2ScanCodeTranslator.Instance.GetCode(scanCode);

            data.Enqueue((byte)Command.Release);
            data.Enqueue((byte)(key & 0x7f));
            NotifyParent();
        }
コード例 #11
0
        public static void click(KeyScanCode scanCode, KeyId id)
        {
            //press down id
            keybd_event((byte)id, (byte)scanCode, KEYEVENT_KEYDOWN, (IntPtr)0);

            Thread.Sleep(PERSON_CLICK_DELAY);

            //press up id
            keybd_event((byte)id, (byte)scanCode, KEYEVENT_KEYUP, (IntPtr)0);
        }
コード例 #12
0
        public int GetCode(KeyScanCode scanCode)
        {
            int result;

            if (!mapping.TryGetValue(scanCode, out result))
            {
                result = 0;
            }
            return(result);
        }
コード例 #13
0
        public void KeyReleased(KeyScanCode key)
        {
            lalt   &= (key != KeyScanCode.AltL);
            lctrl  &= (key != KeyScanCode.CtrlL);
            lshift &= (key != KeyScanCode.ShiftL);

            var kh = keyboardHandler;

            if (kh != null)
            {
                kh.Release(key);
            }
        }
コード例 #14
0
ファイル: USBKeyboard.cs プロジェクト: AntonKrug/emul8-modded
 private void PressInner(KeyScanCode scanCode)
 {
     lock (thisLock)
     {
         pkey = (int)scanCode & 0x7f;
         if (((int)scanCode) >= 0xe0 && ((int)scanCode) <= 0xe7)
         {
             modifiers |= 1 << (((int)scanCode) & 0x7);
             pkey       = 0;
         }
         queue.Enqueue((byte)pkey);
     }
     Refresh();
 }
コード例 #15
0
ファイル: Keypad.cs プロジェクト: drdnar/Tiedye
        /// <summary>
        /// Signals that the given key is being held down.
        /// </summary>
        /// <param name="key"></param>
        public void SetKey(KeyScanCode key)
        {
            if (key == KeyScanCode.None)
            {
                return;
            }
            if (key == KeyScanCode.On)
            {
                OnKey = true;
                return;
            }
            int n = (int)key - 1;

            SetKey(n >> 3, n & 0x7);
        }
コード例 #16
0
ファイル: Keypad.cs プロジェクト: drdnar/Tiedye
        /// <summary>
        /// Signals that the given key is not being held down.
        /// </summary>
        /// <param name="key"></param>
        public void ResetKey(KeyScanCode key)
        {
            if (key == KeyScanCode.None)
            {
                return;
            }
            if (key == KeyScanCode.On)
            {
                OnKey = false;
                return;
            }
            int n = (int)key - 1;

            ResetKey(n >> 3, n & 0x7);
        }
コード例 #17
0
ファイル: USBKeyboard.cs プロジェクト: AntonKrug/emul8-modded
 private void ReleaseInner(KeyScanCode scanCode)
 {
     lock (thisLock)
     {
         pkey = (int)0;
         if (((int)scanCode) >= 0xe0 && ((int)scanCode) <= 0xe7)
         {
             modifiers &= ~(1 << (((int)scanCode) & 0x7));
         }
         for (int i = 0; i < 6; i++)
         {
             queue.Enqueue((byte)pkey);
         }
     }
     Refresh();
 }
コード例 #18
0
ファイル: Keypad.cs プロジェクト: drdnar/Tiedye
        /// <summary>
        /// Returns true if the specified key is being held down.
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public bool TestKey(KeyScanCode key)
        {
            if (key == KeyScanCode.None)
            {
                return(false);
            }
            if (key == KeyScanCode.On)
            {
                return(onKey);
            }
            int n     = (int)key - 1;
            int group = n >> 3;
            int bit   = n & 0x7;

            return((KeyStateTable[group] & (1 << bit)) != 0);
        }
コード例 #19
0
ファイル: Keypad.cs プロジェクト: drdnar/Tiedye
 /// <summary>
 /// This provides a simple way to control which keys are being pressed.
 /// </summary>
 /// <param name="key"></param>
 /// <returns></returns>
 public bool this[KeyScanCode key]
 {
     get
     {
         return(TestKey(key));
     }
     set
     {
         if (value)
         {
             SetKey(key);
         }
         else
         {
             ResetKey(key);
         }
     }
 }
コード例 #20
0
ファイル: IOHandler.cs プロジェクト: rte-se/emul8
        public void KeyPressed(KeyScanCode key)
        {
            var kh = keyboardHandler;

            lalt |= (key == KeyScanCode.AltL);
            lctrl |= (key == KeyScanCode.CtrlL);
            lshift |= (key == KeyScanCode.ShiftL);

            if(lctrl && lalt && lshift)
            {
                lalt = false;
                lctrl = false;
                lshift = false;

                if(status == Status.Grabbed)
                {
                    // ask if we should grab
                    source.DetachHandler();
                    source = new XWTEventSource(widget);
                    source.AttachHandler(this);
                    status = Status.NotGrabbed;
                }

                if(kh != null)
                {
                    kh.Release(KeyScanCode.AltL);
                    kh.Release(KeyScanCode.CtrlL);
                    kh.Release(KeyScanCode.ShiftL);
                }
                return;
            }

            if(kh != null)
            {
                kh.Press(key);
            }
        }
コード例 #21
0
        public void KeyPressed(KeyScanCode key)
        {
            var kh = keyboardHandler;

            lalt   |= (key == KeyScanCode.AltL);
            lctrl  |= (key == KeyScanCode.CtrlL);
            lshift |= (key == KeyScanCode.ShiftL);

            if (lctrl && lalt && lshift)
            {
                lalt   = false;
                lctrl  = false;
                lshift = false;

                if (status == Status.Grabbed)
                {
                    // ask if we should grab
                    source.DetachHandler();
                    source = new XWTEventSource(widget);
                    source.AttachHandler(this);
                    status = Status.NotGrabbed;
                }

                if (kh != null)
                {
                    kh.Release(KeyScanCode.AltL);
                    kh.Release(KeyScanCode.CtrlL);
                    kh.Release(KeyScanCode.ShiftL);
                }
                return;
            }

            if (kh != null)
            {
                kh.Press(key);
            }
        }
コード例 #22
0
ファイル: IOHandler.cs プロジェクト: rte-se/emul8
        public void KeyReleased(KeyScanCode key)
        {
            lalt &= (key != KeyScanCode.AltL);
            lctrl &= (key != KeyScanCode.CtrlL);
            lshift &= (key != KeyScanCode.ShiftL);

            var kh = keyboardHandler;
            if(kh != null)
            {
                kh.Release(key);
            }
        }
コード例 #23
0
        private void UpdateKeyList(KeyScanCode scanCode, bool isPress)
        {
            // Ignore duplicate events which happen due to key repeat.
            if ((isPress && this.PressedKeys.ContainsKey(scanCode)) ||
                (!isPress && !this.PressedKeys.ContainsKey(scanCode)))
            {
                return;
            }

            // If we can't handle this key, don't process it.
            if (!MatrixMapping.ContainsKey(scanCode))
            {
                this.Log(LogLevel.Debug, "No key mapping found for {0}", scanCode);
                return;
            }

            // Add or remove this key from the list of currently-active keys
            this.Log(LogLevel.Debug, "Got new key -- press? {0} : {1}", isPress, scanCode);
            if (isPress)
            {
                this.PressedKeys.Add(scanCode, true);
            }
            else
            {
                this.PressedKeys.Remove(scanCode);
            }

            // Reconstruct the keyboard matrix press state
            for (var i = 0; i < this.rows.Length; i++)
            {
                this.rows[i] = 0;
            }

            // Simulate the keyboard matrix by ORing all pressed keys.
            foreach (var key in this.PressedKeys)
            {
                KeyMap result;
                MatrixMapping.TryGetValue(key.Key, out result);
                for (var i = 0; i < this.rows.Length; i++)
                {
                    this.rows[i] |= result.rows[i];
                }
            }
            // for (var i = 0; i <= 8; i++)
            // {
            //     this.Log(LogLevel.Debug, "    rows[{0}] = {1}", i, rows[i]);
            // }

            // Update the `rowChange` field if no interrupt is pending.
            if (!this.irqInjectPending.Value)
            {
                for (var i = 0; i <= 8; i++)
                {
                    if (this.rows[i] != 0)
                    {
                        this.rowChange |= (1u << i);
                    }
                }
            }
            this.irqKeyPressedStatus = true;
            this.UpdateInterrupts();
            this.irqKeyPressedStatus = false;
            return;
        }
コード例 #24
0
 public void Release(KeyScanCode scanCode)
 {
     this.UpdateKeyList(scanCode, false);
 }
コード例 #25
0
ファイル: USBKeyboard.cs プロジェクト: AntonKrug/emul8-modded
 public void Press(KeyScanCode scanCode)
 {
     machine.ReportForeignEvent(scanCode, PressInner);
 }
コード例 #26
0
ファイル: USBKeyboard.cs プロジェクト: AntonKrug/emul8-modded
 public void Release(KeyScanCode scanCode)
 {
     machine.ReportForeignEvent(scanCode, ReleaseInner);
 }
コード例 #27
0
ファイル: USBKeyboard.cs プロジェクト: rte-se/emul8
 public void Press(KeyScanCode scanCode)
 {
     machine.ReportForeignEvent(scanCode, PressInner);
 }
コード例 #28
0
 public static void release(KeyScanCode scanCode, KeyId id)
 {
     //press up id
     keybd_event((byte)id, (byte)scanCode, KEYEVENT_KEYUP, (IntPtr)0);
 }
コード例 #29
0
 public static void press(KeyScanCode scanCode, KeyId id)
 {
     //press down id
     keybd_event((byte)id, (byte)scanCode, KEYEVENT_KEYDOWN, (IntPtr)0);
 }
コード例 #30
0
ファイル: USBKeyboard.cs プロジェクト: rte-se/emul8
 public void Release(KeyScanCode scanCode)
 {
     machine.ReportForeignEvent(scanCode, ReleaseInner);
 }
コード例 #31
0
ファイル: USBKeyboard.cs プロジェクト: rte-se/emul8
 private void ReleaseInner(KeyScanCode scanCode)
 {
     lock(thisLock)
     {
         pkey = (int)0;
         if(((int)scanCode) >= 0xe0 && ((int)scanCode) <= 0xe7)
         {
             modifiers &= ~(1 << (((int)scanCode) & 0x7));
         }
         for(int i = 0; i < 6; i++)
             queue.Enqueue((byte)pkey);
     }
     Refresh();
 }
コード例 #32
0
ファイル: USBKeyboard.cs プロジェクト: rte-se/emul8
 private void PressInner(KeyScanCode scanCode)
 {
     lock(thisLock)
     {
         pkey = (int)scanCode & 0x7f;
         if(((int)scanCode) >= 0xe0 && ((int)scanCode) <= 0xe7)
         {
             modifiers |= 1 << (((int)scanCode) & 0x7);
             pkey = 0;
         }
         queue.Enqueue((byte)pkey);
     }
     Refresh();
 }
コード例 #33
0
 public void Press(KeyScanCode scanCode)
 {
     this.UpdateKeyList(scanCode, true);
 }
コード例 #34
0
ファイル: PS2Keyboard.cs プロジェクト: rte-se/emul8
        private void ReleaseInner(KeyScanCode scanCode)
        {
            var key = PS2ScanCodeTranslator.Instance.GetCode(scanCode);
            data.Enqueue((byte)Command.Release);
            data.Enqueue((byte)(key & 0x7f));
            NotifyParent();

        }