-
Notifications
You must be signed in to change notification settings - Fork 0
Control Handler
The Control Handler works alongside the profile handler to parse joystick input into the controls mapped by the pilot.
The format for parsed control JSON is just an object containing values for mapped controls. Only mapped controls will appear in the parsed JSON object. The name is the control and the value is the joystick value.
{"surge":0.652, "heave": 0.421, "heave": 0, "pitchUp": 1}
To use the Control Handler, you have to initialize it as a variable.
var controlHandler = new ControlHandler();
In order to parse controls, the Control Handler instance must be given a profile. The profile can be set from a profile JSON object (See Here) :
//profileToSet is a profile JSON object
controlHandler.profile = profileToSet
The Control Handler instance can then be used to receive parsed controls. The method controlHandler.parseControls()
will get new gamepad input, parse it, and return it as Control JSON as seen above.
Control Handler also contains a method isValidProfile(profile)
. This method will return either true or false depending on if the required amount of gamepads are connected as determined by the profile.
© Memorial University Eastern Edge Robotics - www.easternedgerobotics.com