예제 #1
0
int settings_key_handler(unsigned char key)
{
    if (upKeyPressed(key))
    {
	if (settings_offset != 0 && settings_offset == settings_cursor)
	    settings_offset--;
	if (settings_cursor > 0)
	    settings_cursor--;
    }
    else if (downKeyPressed(key))
    {
	if (settings_offset < SETTINGS_MENU_LEN - SETTINGS_DISPLAY_SIZE &&
	    settings_cursor == settings_offset + SETTINGS_DISPLAY_SIZE - 1)
	    settings_offset++;
	if (settings_cursor < SETTINGS_MENU_LEN)
	    settings_cursor++;
    }
    else if (leftKeyPressed(key))
    {
	struct settings_display *disp = &settings_display_list[settings_cursor];
	if (disp->type == FLOAT)
	{
	    *((float *)disp->value) -= 0.5;
	}
	else if (disp->type == UINT8)
	{
	    *((uint8_t *)disp->value) -= 1;
	}
    }
    else if (rightKeyPressed(key))
    {
	struct settings_display *disp = &settings_display_list[settings_cursor];
	if (disp->type == FLOAT)
	{
	    *((float *)disp->value) += 0.5;
	}
	else if (disp->type == UINT8)
	{
	    *((uint8_t *)disp->value) += 1;
	}
    }
    settings_display_menu();
    return 1;
}
예제 #2
0
void cVideoLabel::keyPressEvent(QKeyEvent *ev)
{
  if ((ev->key() == this->moveForwardKey) && !ev->isAutoRepeat())
  {
    emit forwardKeyPressed();
  }
  else if ((ev->key() == this->moveBackwardKey) && !ev->isAutoRepeat())
  {
    emit backwardKeyPressed();
  }
  else if ((ev->key() == this->moveLeftKey) && !ev->isAutoRepeat())
  {
    emit leftKeyPressed();
  }
  else if ((ev->key() == this->moveRightKey) && !ev->isAutoRepeat())
  {
    emit rightKeyPressed();
  }
  else
  {
    QLabel::keyPressEvent(ev);
  }
}