Skip to content

Control Handler

Andrew Troake edited this page Dec 2, 2018 · 1 revision

The Control Handler works alongside the profile handler to parse joystick input into the controls mapped by the pilot.

Parsed Control JSON Format

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.


Example of Parsed Control JSON

{"surge":0.652, "heave": 0.421, "heave": 0, "pitchUp": 1}

How To Use

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.