Esempio n. 1
0
/**
 * \brief Returns whether this keyboard, joypad or mouse event
 * corresponds to pressing something.
 *
 * The thing pressed may be a key, a button or a direction.
 * If this is not a keyboard, joypad or mouse event, false is returned.
 *
 * \return true if something was pressed
 */
bool InputEvent::is_pressed() const {

  return is_keyboard_key_pressed()
    || is_direction_pressed()
    || is_joypad_button_pressed()
    || is_mouse_button_pressed();
}
Esempio n. 2
0
/**
 * @brief Returns whether this event is a keyboard event
 * corresponding to pressing one of the specified keys.
 * @param keys an array of the keys to test, terminated by KEY_NONE
 * @return true if this event corresponds to pressing one of those keys
 */
bool InputEvent::is_keyboard_key_pressed(const KeyboardKey *keys) {

  while (*keys != KEY_NONE) {

    if (is_keyboard_key_pressed(*keys)) {
      return true;
    }
    keys++;
  }

  return false;
}
Esempio n. 3
0
/**
 * @brief Returns whether this event is a keyboard event
 * corresponding to pressing a key other than the four directional keys.
 * @return true if this event corresponds to pressing a key other than the four directional keys
 */
bool InputEvent::is_keyboard_non_direction_key_pressed() {

  return is_keyboard_key_pressed()
    && !is_keyboard_direction_key_pressed();
}
Esempio n. 4
0
/**
 * @brief Returns whether this event is a keyboard event
 * corresponding to pressing one of the four directional keys.
 * @return true if this event corresponds to pressing one of the four directional keys
 */
bool InputEvent::is_keyboard_direction_key_pressed() {

  return is_keyboard_key_pressed(directional_keys);
}
Esempio n. 5
0
/**
 * @brief Returns whether this event is a keyboard event
 * corresponding to pressing a specific key.
 * @param key the key to test
 * @return true if this event corresponds to pressing that key
 */
bool InputEvent::is_keyboard_key_pressed(KeyboardKey key) {

  return is_keyboard_key_pressed()
    && get_keyboard_key() == key;
}