void ShortcutsPlugin::releaseKeys() { releaseKeys(MenuMain); releaseKeys(MenuGroup); releaseKeys(MenuContact); releaseKeys(MenuStatus); oldKeys.clear(); oldGlobals.clear(); if (globalKeys){ list<GlobalKey*>::iterator it; for (it = globalKeys->begin(); it != globalKeys->end(); ++it){ delete *it; } delete globalKeys; globalKeys = NULL; } mouseCmds.clear(); qApp->removeEventFilter(this); }
void GnomeMediaKeys::serviceOwnerChanged(const QString &name, const QString &, const QString &) { if (name==constService) { releaseKeys(); disconnectDaemon(); if (daemonIsRunning()) { grabKeys(); } } }
Cgreven::Cgreven() { height=600; width=800; end=false; fullScreen=false; mouseX=0; mouseY=0; releaseKeys(); camera=NULL; lastTime=0; this->NoO = 0; this->gameObjects = NULL; };
ShortcutsPlugin::~ShortcutsPlugin() { #ifdef WIN32 QWidget *main = getMainWindow(); if (main && oldProc){ if (IsWindowUnicode(main->winId())){ SetWindowLongW(main->winId(), GWL_WNDPROC, (LONG)oldProc); }else{ SetWindowLongA(main->winId(), GWL_WNDPROC, (LONG)oldProc); } } #endif releaseKeys(); free_data(shortcutsData, &data); }
void GnomeMediaKeys::setEnabled(bool en) { if (en && !mk) { if (daemonIsRunning()) { grabKeys(); } } else if (!en && mk) { releaseKeys(); disconnectDaemon(); if (watcher) { watcher->deleteLater(); watcher=0; } } }
ShortcutsPlugin::~ShortcutsPlugin() { #ifdef WIN32 QWidget *main = getMainWindow(); if (main && oldProc) { if (IsWindowUnicode(main->winId())) { SetWindowLongW(main->winId(), GWL_WNDPROC, (LONG)oldProc); } else { SetWindowLongA(main->winId(), GWL_WNDPROC, (LONG)oldProc); } } #else #ifndef USE_KDE qt_set_x11_event_filter(oldFilter); #endif #endif releaseKeys(); free_data(shortcutsData, &data); }
void Player::updateInput(ActionTree &action_tree) { bool direction_pressed = false; bool attack_pressed = false; if (keyboard_works == true) { releaseKeys(); for (auto &itr : key_to_action) { if (keys_pressed.find(sf::Keyboard::X) != keys_pressed.end()) { attack_pressed = true; } if (keys_pressed.find(sf::Keyboard::Left) != keys_pressed.end() || keys_pressed.find(sf::Keyboard::Right) != keys_pressed.end() || keys_pressed.find(sf::Keyboard::Up) != keys_pressed.end() || keys_pressed.find(sf::Keyboard::Down) != keys_pressed.end()) { direction_pressed = true; } //If the key is pressed add to the set. If not then delete from the set. //If it's a new key then refresh the last_key_pressed and current_action if (sf::Keyboard::isKeyPressed(itr.first)) { auto key = keys_pressed.find(itr.first); if (key == keys_pressed.end() ) //&& (direction_pressed || attack_pressed) { last_key_pressed = itr.first; keys_pressed.insert(last_key_pressed); } } else { auto key = keys_pressed.find(itr.first); if (key != keys_pressed.end()) { keys_pressed.erase(itr.first); } } } //Only one direction if (attack_pressed) { if (hero != nullptr) if (hero->isAttack() == false ) { //std::cout << "Attack" << std::endl; is_attacking = true; current_action = key_to_action[last_key_pressed]; hero->pushAction(action_to_command[current_action]); } } else if (direction_pressed && last_key_pressed != sf::Keyboard::X) { //if (last_key_pressed == sf::Keyboard::X) std::cout << "Error" << std::endl; current_action = key_to_action[last_key_pressed]; hero->pushAction(action_to_command[current_action]); } } }
void printUpdate(void) { char ascii = 0; if(strBuf[actString].info != EMPTY) { if(strBuf[actString].info == RAM) { ascii = *(strBuf[actString].strPtr); //READ CHAR } else if(strBuf[actString].info == FLASH) { ascii = pgm_read_byte(strBuf[actString].strPtr);//READ CHAR } } switch(kbd_status) { case INIT: //Initial debouncing if(debounceCount < INIT_DEBOUNCE) { releaseKeys(); debounceCount++; } else { kbd_status=RELEASED; debounceCount = 0; } break; case PRESSED: //We release releaseKeys(); kbd_status = RELEASED; if(strBuf[actString].len > 0) strBuf[actString].len--; break; case RELEASED: //We can PROCESS CHAR if( (strBuf[actString].callback == 0) && (ascii == 0) )//EOS { EOS=1; strBuf[actString].info = EMPTY; actString = (actString+1)%5; } else if( (strBuf[actString].callback != 0) && (strBuf[actString].len == 0) ) { strBuf[actString].info = EMPTY; crd_apply(); if(strBuf[actString].info == EMPTY) { EOS=1; } } else { strBuf[actString].strPtr++; //Increment pointer //Do we have to enter IDLE state? if(ascii == SYNCHRONOUS_IDLE_KEY) { kbd_status = IDLE; } else { pressKeyByChar(ascii); if(EOS==0) { //not first char cCount++;//new char to delete } else { //first char of string EOS=0; cCount = 1; } kbd_status = PRESSED; } } break; case IDLE: if(debounceCount < IDLE_TIMEOUT) { releaseKeys(); debounceCount++; } else { kbd_status=RELEASED; debounceCount = 0; } break; case DELETE: if(cCount > 0) { //DELETING pressKeyByChar(0x08); cCount--; kbd_status=DELETE_PRESSED; } else { //DONE ERASING releaseKeys(); //strBuf[actString].info = EMPTY; kbd_status=RELEASED; if(EOS==0) //if half word printing { EOS=1; //INVALIDATE CURRENT TYPING strBuf[actString].info = EMPTY; actString = (actString+1)%5; } } break; case DELETE_PRESSED: releaseKeys(); kbd_status=DELETE; break; } }