void Egraph::getNextAckAxioms( vector< Enode * > & axioms ) { // // Outer loop, for each function symbol // for ( map< Enode *, vector< Enode * > >::iterator it = uf_to_appl.begin( ) ; it != uf_to_appl.end( ) ; it ++ ) { Enode * f_symb = it->first; vector< Enode * > & appl = it->second; const size_t max_index = appl.size( ); // Retrieve current counters size_t i = uf_to_appl_count[ f_symb ].first; size_t j = uf_to_appl_count[ f_symb ].second; assert( i < j ); assert( i < max_index ); assert( j <= max_index ); // All axioms already returned for this symbol if ( i + 1 == max_index ) { assert( j == max_index ); continue; } assert( i + 1 < max_index ); assert( j + 1 <= max_index ); // Generate axiom Enode * appl_i = appl[ i ]; Enode * appl_j = appl[ j ]; Enode * appl_i_list = appl_i->getCdr( ); Enode * appl_j_list = appl_j->getCdr( ); // // Construct (ai_1 = aj_1 /\ ai_2 = aj_2 /\ ... /\ ai_n = aj_n) --> f( ... ) = f( ... ) // equiv to (ai_1 != aj_1 \/ ai_2 != aj_2 \/ ... \/ ai_n != aj_n \/ f( ... ) = f( ... )) // // equiv to (ai_1 < aj_1 \/ ai_1 > aj_1 \/ ... \/ f( ... ) <= f( ... ) ) // equiv to (ai_1 < aj_1 \/ ai_1 > aj_1 \/ ... \/ f( ... ) => f( ... ) ) // list< Enode * > clause; while ( !appl_i_list->isEnil( ) ) { appl_i_list = appl_i_list->getCdr( ); appl_j_list = appl_j_list->getCdr( ); Enode * arg_i = appl_i_list->getCar( ); Enode * arg_j = appl_j_list->getCar( ); Enode * lt = mkLt( arg_i, arg_j ); LAExpression lalt( lt ); clause.push_back( lalt.toEnode( *this ) ); Enode * gt = mkGt( arg_i, arg_j ); LAExpression lagt( gt ); clause.push_back( lagt.toEnode( *this ) ); } clause.push_back( mkLeq( appl_i, appl_j ) ); // Push first axiom axioms.push_back( mkOr( cons( clause ) ) ); clause.pop_back( ); clause.push_back( mkGeq( appl_i, appl_j ) ); // Push second axiom axioms.push_back( mkOr( cons( clause ) ) ); // Update counters j ++; if ( j == max_index ) { i ++; j = i + 1; } // Store for next call uf_to_appl_count[ f_symb ].first = i; uf_to_appl_count[ f_symb ].second = j; } }
void KeyMap::PCtoX(BYTE virtKey, DWORD keyData, ClientConnection* clientCon) { bool down = ((keyData & 0x80000000) == 0); bool extended = ((keyData & 0x1000000) != 0); bool repeated = ((keyData & 0xc0000000) == 0x40000000); UINT extVkey = virtKey + (extended ? 256 : 0); // exclude winkey when not scroll-lock if (virtKey==91 || virtKey==92) return; vnclog.Print(8, _T("\nPCtoX: %svirtKey 0x%02x%s%s, keyData 0x%08x\n"), (extended ? _T("extended ") : _T("")), virtKey, (repeated ? _T(" repeated") : _T("")), (down ? _T(" down") : _T(" up")), keyData); // If this is a key release then just send the associated sent KeySym when // this key was pressed if (!down) { vnclog.Print(8, _T("Release the associated KeySym when this VirtKey was pressed\n")); if (downUnicode[extVkey]) { vnclog.Print(8, _T(" 0x%04x (%c): "), downUnicode[extVkey], downUnicode[extVkey]); downUnicode[extVkey] = NULL; } else { vnclog.Print(8, _T(" Control character: ")); } releaseKey(clientCon, extVkey); vnclog.Print(8, _T("\n")); GetKeyboardState(KBKeysState); if (!((KBKeysState[VK_MENU] & 0x80) && (KBKeysState[VK_CONTROL] & 0x80))) { if (storedDeadChar && reset) { reset=false; keybd_event(VK_SPACE, 0, 0, 0); keybd_event(VK_SPACE, 0, KEYEVENTF_KEYUP, 0); } } return; } // We try to look it up in our key table // Look up the desired code in the keyMap table try to find the exact match according to // the extended flag, then try the opposite of the extended flag CARD32 foundXCode = XK_VoidSymbol; bool exactMatched = false; vnclog.Print(8, _T("Looking in key table ")); for (UINT i = 0; i < (sizeof(keyMap) / sizeof(vncKeyMapping_t)); i++) { if (keyMap[i].WinCode == virtKey) { foundXCode = keyMap[i].XCode; if (extended == keyMap[i].extVK) { exactMatched = true; break; } } } if (foundXCode != XK_VoidSymbol) { vnclog.Print(8, _T("-> keyMap gives (from %s extended flag) KeySym %u (0x%08x)\n"), (exactMatched ? _T("matched") : _T("opposite")), foundXCode, foundXCode); pressKey(clientCon, extVkey, foundXCode); vnclog.Print(8, _T("\n")); return; } else { vnclog.Print(8, _T("-> not in special keyMap\n")); } // Under CE, we're not so concerned about this bit because we handle a WM_CHAR message later #ifndef UNDER_CE GetKeyboardState(KBKeysState); ModifierKeyReleaser lctrl(clientCon, VK_CONTROL, 0); ModifierKeyReleaser lalt(clientCon, VK_MENU, 0); ModifierKeyReleaser ralt(clientCon, VK_MENU, 1); if ((KBKeysState[VK_MENU] & 0x80) && (KBKeysState[VK_CONTROL] & 0x80)) { // This is a Ctrl-Alt (AltGr) key on international keyboards (= LCtrl-RAlt) // Ex. Ctrl-Alt-Q gives '@' on German keyboards vnclog.Print(8, _T("Ctrl-Alt pressed:\n")); // We must release Control and Alt (AltGr) if they were both pressed, so the character // is seen without them by the VNC server // We don't release the Right Control; this allows German users // to use it for doing Ctrl-AltGr-x, e.g. Ctl-@, etc lctrl.release(downKeysym); lalt.release(downKeysym); ralt.release(downKeysym); } else { // This is not a Ctrl-Alt (AltGr) key vnclog.Print(8, _T("Ctrl-Alt not pressed, fake release any Ctrl key\n")); // There are no KeySym corresponding to control characters, e.g. Ctrl-F // The server has already known whether the Ctrl key is pressed from the previouse key event // So we are interested in the key that would be there if the Ctrl key were not pressed KBKeysState[VK_CONTROL] = KBKeysState[VK_LCONTROL] = KBKeysState[VK_RCONTROL] = 0; } int ret; if (storedDeadChar) { SHORT virtDeadKey; BYTE prevModifierState = 0; vnclog.Print(8, _T("[Storing base character modifier(s)]\n")); StoreModifier(&prevModifierState, KBKeysState); virtDeadKey = VkKeyScanW(storedDeadChar); vnclog.Print(8, _T("[A dead key was stored, restoring the dead key state:") _T(" 0x%02x (%c) using virtDeadKey 0x%02x] "), storedDeadChar, storedDeadChar, virtDeadKey); SetModifier(HIBYTE(virtDeadKey), KBKeysState); vnclog.Print(8, _T("\n")); ToUnicode((virtDeadKey & 0xff), 0, KBKeysState, ucsChar, (sizeof(ucsChar) / sizeof(WCHAR)), 0); vnclog.Print(8, _T("[Restoring base character modifier(s)] ")); SetModifier(prevModifierState, KBKeysState); vnclog.Print(8, _T("\n")); storedDeadChar = 0; ret = ToUnicode(virtKey, 0, KBKeysState, ucsChar, (sizeof(ucsChar) / sizeof(WCHAR)), 0); } else ret = ToUnicode(virtKey, 0, KBKeysState, ucsChar, (sizeof(ucsChar) / sizeof(WCHAR)), 0); if (ucsChar[0]==8364) { //euro // return; } if (ret < 0 || ret==2) { // It is a dead key vnclog.Print(8, _T("ToUnicode returns dead key: 0x%02x (%c) "), *ucsChar, *ucsChar); if (sendDeadKey) { // We try to look it up in our dead key table // Look up the desired code in the deadKeyMap table foundXCode = XK_VoidSymbol; for (UINT i = 0; i < (sizeof(deadKeyMap) / sizeof(vncDeadKeyMapping_t)); i++) { if (deadKeyMap[i].deadKeyChar == *ucsChar) { foundXCode = deadKeyMap[i].XCode; break; } } if (foundXCode != XK_VoidSymbol) { vnclog.Print(8, _T("-> deadKeyMap gives KeySym %u (0x%08x)\n"), foundXCode, foundXCode); pressKey(clientCon, extVkey, foundXCode); } else { vnclog.Print(8, _T("-> not in deadKeyMap\n")); } } else { storedDeadChar = *ucsChar; reset=true; vnclog.Print(8, _T("-> Store the dead key state, wait for next key-stroke\n")); } FlushDeadKey(KBKeysState); } else if (ret > 0) { vnclog.Print(8, _T("ToUnicode returns %d character(s):\n"), ret); for (int i = 0; i < ret; i++) { CARD32 xChar = UCS2X(*(ucsChar+i)); if (xChar != XK_VoidSymbol) { downUnicode[extVkey] = *(ucsChar+i); pressKey(clientCon, extVkey, xChar); } } } else { vnclog.Print(8, _T("No character is generated by this key event\n")); } #endif vnclog.Print(8, _T("\n")); };