📄 keyboard.c
字号:
return 1; if (temp == 0xFE) break; } } while ((resends-- > 0) && (timeout > 0)); return 0;}/****************************************************************************PARAMETERS:modifiers - Keyboard modifier flagsREMARKS:This function re-programs the LED's on the keyboard to the values storedin the passed in modifier flags. If the 'allowLEDS' flag is false, thisfunction does nothing.****************************************************************************/static void setLEDS( uint modifiers){ if (EVT.allowLEDS) { if (!kbSendData(0xED) || !kbSendData((modifiers>>9) & 7)) { kbSendData(0xF4); } }}/****************************************************************************REMARKS:Function to process raw scan codes read from the keyboard controller.NOTE: Interrupts are OFF when this routine is called by the keyboard ISR, and we leave them OFF the entire time.{secret}****************************************************************************/void processRawScanCode( int scan){ static int pauseLoop = 0; static int extended = 0; int what; if (pauseLoop) { /* Skip scan codes until the pause key sequence has been read */ pauseLoop--; } else if (scan == 0xE0) { /* This signals the start of an extended scan code sequence */ extended = 1; } else if (scan == 0xE1) { /* The Pause key sends a strange scan code sequence, which is: * * E1 1D 52 E1 9D D2 * * However there is never any release code nor any auto-repeat for * this key. For this reason we simply ignore the key and skip the * next 5 scan codes read from the keyboard. */ pauseLoop = 5; } else { /* Process the scan code normally (it may be an extended code * however!). Bit 7 means key was released, and bits 0-6 are the * scan code. */ what = (scan & 0x80) ? EVT_KEYUP : EVT_KEYDOWN; scan &= 0x7F; if (extended) { extended = 0; if (scan == 0x2A || scan == 0x36) { /* Ignore these extended scan code sequences. These are * used by the keyboard controller to wrap around certain * key sequences for the keypad (and when NUMLOCK is down * internally). */ return; } /* Convert extended codes for key sequences that we map to * virtual scan codes so the user can detect them in their * code. */ switch (scan) { case KB_leftCtrl: scan = KB_rightCtrl; break; case KB_leftAlt: scan = KB_rightAlt; break; case KB_divide: scan = KB_padDivide; break; case KB_enter: scan = KB_padEnter; break; case KB_padTimes: scan = KB_sysReq; break; } } else { /* Convert regular scan codes for key sequences that we map to * virtual scan codes so the user can detect them in their * code. */ switch (scan) { case KB_left: scan = KB_padLeft; break; case KB_right: scan = KB_padRight; break; case KB_up: scan = KB_padUp; break; case KB_down: scan = KB_padDown; break; case KB_insert: scan = KB_padInsert; break; case KB_delete: scan = KB_padDelete; break; case KB_home: scan = KB_padHome; break; case KB_end: scan = KB_padEnd; break; case KB_pageUp: scan = KB_padPageUp; break; case KB_pageDown: scan = KB_padPageDown; break; } } /* Determine if the key is an UP, DOWN or REPEAT and maintain the * up/down status of all keys in our global key array. */ if (what == EVT_KEYDOWN) { if (EVT.keyTable[scan]) what = EVT_KEYREPEAT; else EVT.keyTable[scan] = scan; } else { EVT.keyTable[scan] = 0; } /* Handle shift key modifiers */ if (what != EVT_KEYREPEAT) { switch (scan) { case KB_capsLock: if (what == EVT_KEYDOWN) EVT.keyModifiers ^= EVT_CAPSLOCK; setLEDS(EVT.keyModifiers); break; case KB_numLock: if (what == EVT_KEYDOWN) EVT.keyModifiers ^= EVT_NUMLOCK; setLEDS(EVT.keyModifiers); break; case KB_scrollLock: if (what == EVT_KEYDOWN) EVT.keyModifiers ^= EVT_SCROLLLOCK; setLEDS(EVT.keyModifiers); break; case KB_leftShift: if (what == EVT_KEYUP) EVT.keyModifiers &= ~EVT_LEFTSHIFT; else EVT.keyModifiers |= EVT_LEFTSHIFT; break; case KB_rightShift: if (what == EVT_KEYUP) EVT.keyModifiers &= ~EVT_RIGHTSHIFT; else EVT.keyModifiers |= EVT_RIGHTSHIFT; break; case KB_leftCtrl: if (what == EVT_KEYUP) EVT.keyModifiers &= ~EVT_LEFTCTRL; else EVT.keyModifiers |= EVT_LEFTCTRL; break; case KB_rightCtrl: if (what == EVT_KEYUP) EVT.keyModifiers &= ~EVT_RIGHTCTRL; else EVT.keyModifiers |= EVT_RIGHTCTRL; break; case KB_leftAlt: if (what == EVT_KEYUP) EVT.keyModifiers &= ~EVT_LEFTALT; else EVT.keyModifiers |= EVT_LEFTALT; break; case KB_rightAlt: if (what == EVT_KEYUP) EVT.keyModifiers &= ~EVT_RIGHTALT; else EVT.keyModifiers |= EVT_RIGHTALT; break;#ifdef SUPPORT_CTRL_ALT_DEL case KB_delete: if ((EVT.keyModifiers & EVT_CTRLSTATE) && (EVT.keyModifiers & EVT_ALTSTATE)) Reboot(); break;#endif } } /* Add the untranslated key code to the event queue. All * translation to ASCII from the key codes occurs when the key * is extracted from the queue, saving time in the low level * interrupt handler. */ addKeyEvent(what,scan << 8); }}/****************************************************************************DESCRIPTION:Enables/disables the update of the keyboard LED status indicators.HEADER:event.hPARAMETERS:enable - True to enable, false to disableREMARKS:Enables the update of the keyboard LED status indicators. Sometimes it maybe convenient in the application to turn off the updating of the LEDstatus indicators (such as if a game is using the CAPSLOCK key for somefunction). Passing in a value of FALSE to this function will turn off allthe LEDS, and stop updating them when the internal status changes (notehowever that internally we still keep track of the toggle key status!).****************************************************************************/void EVTAPI EVT_allowLEDS( ibool enable){ EVT.allowLEDS = true; if (enable) setLEDS(EVT.keyModifiers); else setLEDS(0); EVT.allowLEDS = enable;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -