bool XboxController::IsButtonPressed(XboxButtons buttonType, WORD buttonState) { if (buttonType == LeftTrigger || buttonType == RightTrigger || buttonType == LeftThumbLeft || buttonType == LeftThumbRight || buttonType == RightThumbLeft || buttonType == RightThumbRight || buttonType == LeftThumbUp || buttonType == LeftThumbDown || buttonType == RightThumbUp || buttonType == RightThumbDown) { return (GetAnalogValue(buttonType, buttonState) > TriggerValue); } return (buttonState & XboxButtonMasks[buttonType]) != 0; }
int Pin::GetAnalog(void) { float vcc = 5.0; // assume a fixed Vcc with 5.0V! return (int)(((double)GetAnalogValue(vcc) * INT_MAX) / (double)vcc); }