void LineEditWithHistory::keyPressEvent(QKeyEvent *event) { if(event->key() == Qt::Key_Up) { GetPrevious(); emit UpPressed(); return; } if(event->key() == Qt::Key_Down) { GetNext(); emit DownPressed(); return; } if(event->key() == Qt::Key_Escape) { setText(m_sEditBuffer.c_str()); m_nCurrentCommand = m_history.size(); return; } QLineEdit::keyPressEvent(event); m_sEditBuffer = text().toStdString(); }
bool NoDirectionPressed (void) { if ( (axis_is_active && (input_axis.x || input_axis.y)) || DownPressed () || UpPressed() || LeftPressed() || RightPressed() ) return ( FALSE ); else return ( TRUE ); } // int NoDirectionPressed(void)
void PongController::specialKeyPressed(std::string key) { if(key.find("up") == 0) { UpPressed(2); } if(key.find("down") == 0) { DownPressed(2); } }
LibraryViewContainer::LibraryViewContainer(QWidget* parent) : QWidget(parent), ui_(new Ui_LibraryViewContainer) { ui_->setupUi(this); view()->SetFilter(filter()); connect(filter(), SIGNAL(UpPressed()), view(), SLOT(UpAndFocus())); connect(filter(), SIGNAL(DownPressed()), view(), SLOT(DownAndFocus())); connect(filter(), SIGNAL(ReturnPressed()), view(), SLOT(FilterReturnPressed())); connect(view(), SIGNAL(FocusOnFilterSignal(QKeyEvent*)), filter(), SLOT(FocusOnFilter(QKeyEvent*))); ReloadSettings(); }
void LibraryFilterWidget::keyReleaseEvent(QKeyEvent* e) { switch (e->key()) { case Qt::Key_Up: emit UpPressed(); e->accept(); break; case Qt::Key_Down: emit DownPressed(); e->accept(); break; case Qt::Key_Escape: ui_->filter->clear(); e->accept(); break; } QWidget::keyReleaseEvent(e); }
/*----------------------------------------------------------------- * @Desc: the acutal Takeover game-playing is done here * * *-----------------------------------------------------------------*/ void PlayGame (void) { int countdown = 100; /* lenght of Game in 1/10 seconds */ char count_text[80]; int FinishTakeover = FALSE; int row; Uint32 prev_count_tick, count_tick_len; /* tick vars for count-down */ Uint32 prev_move_tick, move_tick_len; /* tick vars for motion */ Uint32 last_movekey_time, wait_move_ticks = 110; /* number of ticks to wait before "key-repeat" */ int up, down, set; int up_counter, down_counter; int wheel_up, wheel_down; count_tick_len = 100; /* countdown in 1/10 second steps */ move_tick_len = 60; /* allow motion at this tick-speed in ms */ up = down = set = FALSE; up_counter = down_counter = 0; wheel_up = wheel_down = 0; prev_count_tick = prev_move_tick = SDL_GetTicks (); /* start tick clock */ ResetMouseWheel (); // forget about previous wheel events CountdownSound(); while (!FinishTakeover) { cur_time = SDL_GetTicks (); /* * here we register if there have been key-press events in the * "waiting period" between move-ticks : */ if ( !up && UpPressed () ) { up = TRUE; last_movekey_time = SDL_GetTicks(); } if (!down && DownPressed() ) { down = TRUE; last_movekey_time = SDL_GetTicks(); } set = set || (SpacePressed() || MouseLeftPressed()); if (WheelUpPressed()) wheel_up ++; if (WheelDownPressed()) wheel_down ++; /* allow for a WIN-key that give immedate victory */ if ( KeyIsPressedR ('w') && CtrlPressed() && AltPressed() ) { LeaderColor = YourColor; /* simple as that */ return; /* leave now, to avoid changing of LeaderColor! */ } if ( cur_time > prev_count_tick + count_tick_len ) /* time to count 1 down */ { prev_count_tick += count_tick_len; /* set for next countdown tick */ countdown--; sprintf (count_text, "Finish-%d", countdown); DisplayBanner (count_text, NULL , 0 ); if (countdown && (countdown%10 == 0) ) CountdownSound(); if (countdown == 0) { EndCountdownSound(); FinishTakeover = TRUE; } AnimateCurrents (); /* do some animation on the active cables */ } /* if (countdown_tick has occurred) */ /* time for movement */ if ( cur_time > prev_move_tick + move_tick_len ) { prev_move_tick += move_tick_len; /* set for next motion tick */ EnemyMovements (); if (wheel_up || (up && (SDL_GetTicks() - last_movekey_time > wait_move_ticks))) { CapsuleCurRow[YourColor]--; if (CapsuleCurRow[YourColor] < 1) CapsuleCurRow[YourColor] = NUM_LINES; if (!UpPressed()) up = FALSE; if (wheel_up) wheel_up --; } if (wheel_down || (down && (SDL_GetTicks() - last_movekey_time > wait_move_ticks))) { CapsuleCurRow[YourColor]++; if (CapsuleCurRow[YourColor] > NUM_LINES) CapsuleCurRow[YourColor] = 1; if (!DownPressed()) down = FALSE; if (wheel_down) wheel_down --; } if ( set && (NumCapsules[YOU] > 0)) { set = FALSE; row = CapsuleCurRow[YourColor] - 1; if ((row >= 0) && (ToPlayground[YourColor][0][row] != KABELENDE) && (ActivationMap[YourColor][0][row] == INACTIVE)) { NumCapsules[YOU]--; CapsuleCurRow[YourColor] = 0; ToPlayground[YourColor][0][row] = VERSTAERKER; ActivationMap[YourColor][0][row] = ACTIVE1; CapsuleCountdown[YourColor][0][row] = CAPSULE_COUNTDOWN * 2; Takeover_Set_Capsule_Sound (); } /* if (row > 0 && ... ) */ } /* if ( set ) */ ProcessCapsules (); /* count down the lifetime of the capsules */ ProcessPlayground (); ProcessPlayground (); ProcessPlayground (); ProcessPlayground (); /* this has to be done several times to be sure */ ProcessDisplayColumn (); } /* if (motion_tick has occurred) */ ShowPlayground (); } /* while !FinishTakeover */ /* Schluss- Countdown */ countdown = CAPSULE_COUNTDOWN; while (countdown--) { while ( SDL_GetTicks() < prev_count_tick + count_tick_len ) ; prev_count_tick += count_tick_len; ProcessCapsules (); /* count down the lifetime of the capsules */ ProcessCapsules (); /* do it twice this time to be faster */ AnimateCurrents (); ProcessPlayground (); ProcessPlayground (); ProcessPlayground (); ProcessPlayground (); /* this has to be done several times to be sure */ ProcessDisplayColumn (); ShowPlayground (); } /* while (countdown) */ return; } /* PlayGame() */