//************************************ // Method: getButtonState // FullName: Button::getButtonState // Access: public // Returns: ButtonState // Qualifier: //************************************ ButtonState Button::getButtonState() { if (heldFor(holdThreshold)) { buttonState = LONG_PRESSURE; stateStartTime = millis(); } // Has been release and wasn't hold else if (wasPressed() && !wasHeld()) { buttonState = SHORT_PRESSURE; stateStartTime = millis(); } // Released else { } if (stateStartTime != -1) { if (millis() - stateStartTime > stateRemainsThreshold) { buttonState = RELEASED; stateStartTime = -1; } } return buttonState; }
uint8_t wasPressedMask(ButtonGroup group) { if (!buttonGroupValid(group)) return 0; uint8_t mask = 0; for (int i = 0; i < group->count && i < 8; i++) { if (wasPressed(group->buttons[i])) mask |= _BV(i); } return mask; }
bool InputHandler::isPressed(InputHandler::t_buttonNum button, t_joyNum joyNum) { if (!wasPressed(button, joyNum) && isHeld(button, joyNum)) { return true; } else return false; }
bool PlayerInputHeroActionController::shouldShootWeapon() const { if(!input.expired()) { auto in = input.lock(); if(in) { return in->wasPressed(Input::BUTTON_SHOOT); } } return false; }
bool PlayerInputHeroActionController::shouldSlide() const { if(!input.expired()) { auto in = input.lock(); if(in) { return in->isDown(Input::BUTTON_DOWN) && in->wasPressed(Input::BUTTON_JUMP); } } return false; }
bool CButton::isInShort() { return wasPressed(shortPushMilli); }
bool CButton::isInLong() { return wasPressed(longPushMilli); }