Esempio n. 1
0
//************************************
// 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;
}
Esempio n. 2
0
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;
}
Esempio n. 3
0
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;
    }
Esempio n. 6
0
bool CButton::isInShort()
{
   return wasPressed(shortPushMilli);
}
Esempio n. 7
0
bool CButton::isInLong()
{
   return wasPressed(longPushMilli);
}