int mymain(void) { unsigned int code=0; unsigned char head=0, tail=0; unsigned char scanCode=0, asciiCode=0; disableKey(); if(firstTime==1) { initHeadTail(); initTab(); firstTime=0; } scanCode=getScanCode(); asciiCode=lookupAscii(scanCode); if(asciiCode==0) { /* not printable */ if(scanCode==0x1D) { /* check if ctrl is pressed or not */ isCtrlDown=1; } else if(scanCode==0x9d) { isCtrlDown=0; } } if(scanCode>=0x3b && scanCode<=0x3e && isCtrlDown==1) { setActiveShell((scanCode-0x3b)+1); } code= scanCode; code<<=8; code|=asciiCode; head=getHead(); tail=getTail(); if(!((tail+2)==head || (head==0x1e && tail==0x3c)) ) { /* not full */ setKeyCode(code); if(tail==0x3C) { setTail(0x1e); } else { setTail(tail+2); } } enableKey(); eoi(ss,sp); }
void keyboard::__winnt__readKeyboard(RAWINPUT* rawDevice) { // Local variable(s): keyboardActionType actionType; auto key = (keyboardKey)rawDevice->data.keyboard.VKey; bool isDown = keyEnabled(key); if ((rawDevice->data.keyboard.Flags & RI_KEY_BREAK) > 0) { // If the key is currently up, release/disable it. if (isDown) disableKey(key); actionType = ACTION_TYPE_HIT; } else // if ((rawDevice->data.keyboard.Flags & RI_KEY_MAKE) > 0) { // Check if this event is worth logging: if (isDown) return; actionType = ACTION_TYPE_DOWN; // Enable/hold this key, so we don't // log it again until it's been released. enableKey(key); } actionQueue.push_back(keyboardAction(key, actionType)); #ifdef KEYBOARD_DEBUG deviceInfo << "Detected key: " << rawDevice->data.keyboard.VKey << ", actionType: " << actionType << endl; #endif return; }