예제 #1
0
파일: LowLevel.cs 프로젝트: 10der/tvision
 public static bool SysTVGetKeyEvent(ref SysKeyEvent Event)
 {
     W32Kbd.KbdUpdateEventQueues();
     if (W32Kbd.SysKeyCount == 0)
     {
         return(false);
     }
     else
     {
         W32Kbd.SysKeyCount--;
         Event = W32Kbd.SysKeyQue[0];
         for (int i = W32Kbd.SysKeyCount; i > 0; i--)
         {
             W32Kbd.SysKeyQue[i] = W32Kbd.SysKeyQue[i - 1];
         }
         return(true);
     }
 }
예제 #2
0
파일: LowLevel.cs 프로젝트: 10der/tvision
        public static Event GetKeyEvent()
        {
            KeyTransEntry[] KeyTranslateTable =
            {
                new KeyTransEntry(scSpace,   0x08, KeyboardKeys.AltSpace),
                new KeyTransEntry(scIns,     0x04, KeyboardKeys.CtrlIns),
                new KeyTransEntry(scCtrlIns, 0x04, KeyboardKeys.CtrlIns),
                new KeyTransEntry(scIns,     0x01, KeyboardKeys.ShiftIns),
                new KeyTransEntry(scIns,     0x02, KeyboardKeys.ShiftIns),
                new KeyTransEntry(scIns,     0x03, KeyboardKeys.ShiftIns),
                new KeyTransEntry(scDel,     0x04, KeyboardKeys.CtrlDel),
                new KeyTransEntry(scCtrlDel, 0x04, KeyboardKeys.CtrlDel),
                new KeyTransEntry(scDel,     0x01, KeyboardKeys.ShiftDel),
                new KeyTransEntry(scDel,     0x02, KeyboardKeys.ShiftDel),
                new KeyTransEntry(scDel,     0x03, KeyboardKeys.ShiftDel),
                new KeyTransEntry(scBack,    0x09, KeyboardKeys.AltShiftBack),
                new KeyTransEntry(scBack,    0x0A, KeyboardKeys.AltShiftBack),
                new KeyTransEntry(scBack,    0x0B, KeyboardKeys.AltShiftBack),
                new KeyTransEntry(scBack,    0x08, KeyboardKeys.AltBack)
            };

            SysKeyEvent SysKeyEvent = new SysKeyEvent();
            Event       Event       = new Event();

            if (!SysTVGetKeyEvent(ref SysKeyEvent))
            {
                Event.What = Event.Nothing;
            }
            else
            {
                Event.What     = KeyDownMask;
                Event.KeyCode  = (KeyboardKeys)SysKeyEvent.skeKeyCode;
                Event.KeyEvent = SysKeyEvent.wKeyEvent;
                for (int i = KeyTranslateTable.GetLowerBound(0); i <= KeyTranslateTable.GetUpperBound(0); i++)
                {
                    if ((KeyTranslateTable[i].Scan == Event.ScanCode) &&
                        (KeyTranslateTable[i].Shift & SysKeyEvent.skeShiftState) == KeyTranslateTable[i].Shift)
                    {
                        Event.KeyCode = KeyTranslateTable[i].Code;
                        break;
                    }
                }
                if (Event.CharCode == 0xE0)
                {
                    switch (Event.ScanCode)
                    {
                    case scUp:
                    case scDown:
                    case scLeft:
                    case scRight:
                    case scIns:
                    case scDel:
                    case scHome:
                    case scEnd:
                    case scPgUp:
                    case scPgDn:
                    case ((int)KeyboardKeys.CtrlHome >> 8) & 0xFF:
                    case ((int)KeyboardKeys.CtrlEnd >> 8) & 0xFF:
                    case ((int)KeyboardKeys.CtrlPageUp >> 8) & 0xFF:
                    case ((int)KeyboardKeys.CtrlPageDown >> 8) & 0xFF:
                    case ((int)KeyboardKeys.CtrlLeft >> 8) & 0xFF:
                    case ((int)KeyboardKeys.CtrlRight >> 8)& 0xFF:
                    case scCtrlUp:
                    case scCtrlDown:
                        Event.CharCode = 0;
                        break;
                    }
                }
                if (Event.KeyCode == (KeyboardKeys)0xE00D)
                {
                    Event.KeyCode = KeyboardKeys.Enter;
                }
                Event.InfoPtr = null;
            }
            return(Event);
        }