View Single Post
  #2   Spotlight this post!  
Unread 28-04-2016, 21:22
414cnewq 414cnewq is offline
Registered User
FRC #3844 (Kentucky Wildbots)
Team Role: Alumni
 
Join Date: Jul 2014
Rookie Year: 2014
Location: KY
Posts: 86
414cnewq has much to be proud of414cnewq has much to be proud of414cnewq has much to be proud of414cnewq has much to be proud of414cnewq has much to be proud of414cnewq has much to be proud of414cnewq has much to be proud of414cnewq has much to be proud of414cnewq has much to be proud of414cnewq has much to be proud of
Re: How simple should commands be? And how should they be structured?

When I needed to activate something via the Xbox 360 controller, I used the wpilib triggers functionality.
My GetTrigger.h (C++)
Code:
#ifndef GetTrigger_H
#define GetTrigger_H

#include "WPILib.h"

class GetTrigger: public Trigger
{
private:
	int m_axis;
	Joystick* joy;
public:
	GetTrigger(int, Joystick*);
	bool Get();
};

#endif
And GetTrigger.CPP
Code:
#include "GetTrigger.h"

GetTrigger::GetTrigger(int axis, Joystick* Joy)
{
	joy=Joy;
	m_axis=axis;
}

bool GetTrigger::Get()
{
	return joy->GetRawAxis(m_axis)>0;
}
You just declare an object of Type, in this case, GetTrigger in your OI as defined in your constructor and Initialize it like a JoystickButton. If I'm too vaugue, just look in the WPIlub documentation on Triggers here.

Last edited by 414cnewq : 28-04-2016 at 21:26. Reason: Aa
Reply With Quote