Exemple #1
0
/**
 * 	Simple Button Access
 */
bool HotJoystick::Button(kButton btn) {
	switch (btn) {
	case kButtonA:
		return GetRawButton(1);
	case kButtonB:
		return GetRawButton(2);
	case kButtonX:
		return GetRawButton(3);
	case kButtonY:
		return GetRawButton(4);
	case kButtonLB:
		return GetRawButton(5);
	case kButtonRB:
		return GetRawButton(6);
	case kButtonStart:
		return GetRawButton(8);
	case kButtonBack:
		return GetRawButton(7);
	case kButtonLT:
		return GetRawAxis(2) > 0.4;
	case kButtonRT:
		return GetRawAxis(3) > 0.4;
	default:
		return false;
	}
}
Exemple #2
0
bool SmoothJoystick::IsAxisZero(uint32_t axis)
{
    if(GetRawAxis(axis) >= (DEADZONE* -1) || GetRawAxis(axis) <= (DEADZONE))
    {
        return true;
    }
    else
    {
        return false;
    }
}
Exemple #3
0
/**
 * Get the Y value of a stick on the F310.
 *
 * @param stick The stick to read from, either kRightStick or kLeftStick.
 * @return The Y value of the specified stick.
 */
float F310::GetY(StickType stick)
{
	switch(stick)
	{
	case kRightStick:
		return GetRawAxis(kRightYAxisNum);
	case kLeftStick:
		return GetRawAxis(kLeftYAxisNum);
	default:
		return 0.0;
	}
}
bool AdvancedJoystick::GetRawButton (button_t channel) {
    update();

    if (channel < 11)
        return m_gamepad->GetRawButton(channel);
    else
    {
        if (channel == AdvancedJoystick::kTriggerL)
        {
            return GetRawAxis(AdvancedJoystick::kLeftTrigger) > 0.4;
        }
        else if (channel == AdvancedJoystick::kTriggerR)
        {
            return GetRawAxis(AdvancedJoystick::kRightTrigger) > 0.4;
        }
    }
}
Trigger EnhancedJoystick::GetTriggerState() {
    float value=GetRawAxis(TRIGGER_AXIS);
    if(value<TRIGGER_TOLERANCE-1) {
        return TRIG_R;
    } else if(value>1-TRIGGER_TOLERANCE) {
        return TRIG_L;
    }
    return TRIG_NONE;
}
Exemple #6
0
trigStates SmoothJoystick::GetTriggerState()//accepts axis port, returns 1 or -1 if axis value is in the Trigger tolerance range
{
    double a = GetRawAxis(AXIS_TRIGGERS);
    if(a < 0)
    {
        a = (a * -1);
    }
    if(a > TRIGGER_TOLERANCE)
    {
        if(GetRawAxis(AXIS_TRIGGERS) > 0)
        {
            return TRIG_L;
        }
        else
        {
            return TRIG_R;
        }
    }
    else
    {
        return TRIG_NONE;
    }
}
Exemple #7
0
Gamepad::DPadDirection Gamepad::GetDPad()
{
    float x = GetRawAxis(kDPadXAxisNum);
    float y = GetRawAxis(kDPadYAxisNum);

    if (x < -0.5 && y < -0.5)
        return kUpLeft;
    if (x < -0.5 && y > 0.5)
        return kDownLeft;
    if (x > 0.5 && y > 0.5)
        return kDownRight;
    if (x > 0.5 && y < -0.5)
        return kUpRight;
    if (y < -0.5)
        return kUp;
    if (x < -0.5)
        return kLeft;
    if (y > 0.5)
        return kDown;
    if (x > 0.5)
        return kRight;

  return kCenter;
}
// ReadEvent -- Reads from the controller everytime an input button is pressed.
// Also we store 
static void ReadEvent(struct js_event *jse){
  
  int bytes = read(js_fd,jse, sizeof(*jse));
  
  if(bytes > 0){
    jse->type &= ~JS_EVENT_INIT;
    if(jse->type == JS_EVENT_AXIS){
      state.axis[jse->number] = GetRawAxis(jse->value);
    }
    if(jse->type == JS_EVENT_BUTTON){
      state.button[jse->number] = jse->value;
    }

  }
  
}
bool EnhancedJoystick::IsAxisZero(unsigned int i) {
    float value=GetRawAxis(i);
    return std::fabs(value)<=JOYSTICK_ZERO_TOLERANCE;
}
Exemple #10
0
/**
 * Get the Z value of the KinectStick. This axis
 * is unimplemented in the default gestures but can
 * be populated by teams editing the Kinect Server.
 * @param hand Unused
 * @return The Z value of the KinectStick
 */
float KinectStick::GetZ()
{
	return GetRawAxis(Joystick::kDefaultZAxis);
}
Exemple #11
0
/**
 * Get the Twist value of the KinectStick. This axis
 * is unimplemented in the default gestures but can
 * be populated by teams editing the Kinect Server.
 * @return The Twist value of the KinectStick
 */
float KinectStick::GetTwist()
{
	return GetRawAxis(Joystick::kDefaultTwistAxis);
}
Exemple #12
0
/**
 * Get the Y value of the directional pad on the F310.
 *
 * @return The Y value of the directional pad.
 */
float F310::GetDPadY(void)
{
	return GetRawAxis(kDPadYAxisNum);
}
Exemple #13
0
/**
 * Get the Throttle value of the KinectStick. This axis
 * is unimplemented in the default gestures but can
 * be populated by teams editing the Kinect Server.
 * @return The Throttle value of the KinectStick
 */
float KinectStick::GetThrottle()
{
	return GetRawAxis(Joystick::kDefaultThrottleAxis);
}
float jankyXboxJoystick::GetRightYAxis ()
{
	float y = (GetRawAxis(RIGHT_Y_AXIS_CHANNEL));
	return y;
}
Exemple #15
0
/**
 * Get the left joystick Y-value.
 *
 * @return The left joystick Y-value of the gamepad.
 */
float Gamepad::GetLeftY(void)
{
	return -GetRawAxis(m_axes[kLeftYAxis]);
}
/**
 * Get the throttle value of the current joystick.
 * This depends on the mapping of the joystick connected to the current port.
 */
float Joystick::GetThrottle()
{
	return GetRawAxis(m_axes[kThrottleAxis]);
}
/**
 * Get the Z value of the current joystick.
 * This depends on the mapping of the joystick connected to the current port.
 */
float Joystick::GetZ()
{
	return GetRawAxis(m_axes[kZAxis]);
}
Exemple #18
0
/**
 * Get the dpad Y-value.
 *
 * @return The dpad Y-value of the gamepad.
 */
float Gamepad::GetDpadY(void)
{
	return GetRawAxis(m_axes[kDpadYAxis]);
}
Exemple #19
0
/**
 * Get the right joystick Y-value.
 *
 * @return The right joystick Y-value of the gamepad.
 */
float Gamepad::GetRightY(void)
{
	return -GetRawAxis(m_axes[kRightYAxis]);
}
Exemple #20
0
/**
 * Get the right joystick X-value.
 *
 * @return The right joystick X-value of the gamepad.
 */
float Gamepad::GetRightX(void)
{
	return GetRawAxis(m_axes[kRightXAxis]);
}
Exemple #21
0
/**
 * Get the Y value of the KinectStick. This axis
 * represents arm angle in the default gestures
 * @param hand Unused
 * @return The Y value of the KinectStick
 */
float KinectStick::GetY(JoystickHand hand)
{
	return GetRawAxis(Joystick::kDefaultYAxis);
}
Exemple #22
0
/**
 * Get the Y value of the right analog stick.
 */
float Gamepad::GetRightY()
{
    return GetRawAxis(kRightYAxisNum);
}
Exemple #23
0
/**
 * 	Simple Axis Access
 */
float HotJoystick::Axis(kAxis axis) {
	switch(axis) {
	case kAxisLX:
		return fabs(GetRawAxis(0)) > db_LX ? GetRawAxis(0) : 0.0;
		break;
	case kAxisLY:
		return fabs(GetRawAxis(1)) > db_LY ? GetRawAxis(1) : 0.0;
		break;
	case kAxisLT:
		return fabs(GetRawAxis(2)) > db_LX ? GetRawAxis(2) : 0.0;
		break;
	case kAxisRT:
		return fabs(GetRawAxis(3)) > db_LX ? GetRawAxis(3) : 0.0;
		break;
	case kAxisRX:
		return fabs(GetRawAxis(4)) > db_LX ? GetRawAxis(4) : 0.0;
		break;
	case kAxisRY:
		return fabs(GetRawAxis(5)) > db_LX ? GetRawAxis(5) : 0.0;
		break;
	default:
		return 0.0;
	}
}
Exemple #24
0
/**
 * Get the left joystick X-value.
 *
 * @return The left joystick X-value of the gamepad.
 */
float Gamepad::GetLeftX(void)
{
	return GetRawAxis(m_axes[kLeftXAxis]);
}
Exemple #25
0
/**
 * Get the Y value of the joystick.
 * This depends on the mapping of the joystick connected to the current port.
 */
float Joystick::GetY(JoystickHand hand) const
{
    return GetRawAxis(m_axes[kYAxis]);
}
/**
 * Get the state of the left thumbstick axis. Returns a float value.
 */
float jankyXboxJoystick::GetLeftXAxis ()
{
	float x = GetRawAxis(LEFT_X_AXIS_CHANNEL);
	return x;
}
/**
 * Get the twist value of the current joystick.
 * This depends on the mapping of the joystick connected to the current port.
 */
float Joystick::GetTwist()
{
	return GetRawAxis(m_axes[kTwistAxis]);
}
/**
 * Get the state of the right thumbstick axis. Returns a float value.
 */
float jankyXboxJoystick::GetLeftYAxis()
{
	float y = (GetRawAxis(LEFT_Y_AXIS_CHANNEL));
	return y;
}
/**
 * Get the X value of the joystick.
 * This depends on the mapping of the joystick connected to the current port.
 */
float Joystick::GetX(JoystickHand hand)
{
	return GetRawAxis(m_axes[kXAxis]);
}
float jankyXboxJoystick::GetRightXAxis ()
{
	float x = GetRawAxis(RIGHT_X_AXIS_CHANNEL);
	return x;
}