Thumbnail

Joystick (Xinput)

Joystick control for XInput devices (xbox controllers, etc).

+ How To Add This Control To Your Project (Click to Expand)
  1. Make sure you have the latest version of ARC installed.
  2. Select the Get button in this page to download the archive file.
  3. Double click the downloaded archive file to execute installer.
  4. The installer will add this control to ARC.
  5. Load ARC and press the Project -> Add Control button from the menu.
  6. Choose the Misc category tab.
  7. Press the Joystick (Xinput) icon to add the control to your project.

Manual

Joystick control for XInput devices (xbox controllers, etc). The advantage to this over the Direct Input joystick control is that you have access to vibration hardware, and independent access to analog inputs. Analog inputs, such as the finger triggers can control servos.

*Compatible Joysticks: This control is not compatible with legacy Direct Input joysticks. For direct input joysticks, use the Joystick (DirectInput) found HERE. Some joysticks have a switch for change between Direct Input and XInput. Generally, the switch is labelled D or X. For this control, change the switch to X.

Joystick Position Values
If Use Variables is checked in the Variable Tab of the configuration menu, there will be variables for the analog joystick positions. The analog joystick #1 (left) and #2 (right) will set variable values between -32768 and 32767. The analog finger triggers will set variable values between 0 and 255.
User-inserted image



Buttons
Because the buttons of joysticks can be labelled differently, they are numbered. To see what button corresponds to script positions, simply push the button to see the respective row highlight. In this screenshot, the Y button is pressed.
User-inserted image



Movement Panel Controlling
To control movement panels, by default the D Pad has assigned scripts for calling forward(), left(), right(), etc.. However, the D Pad does not give you variable speed control, so you can enable the left joystick to control Movement Panel with variable speed. This is done with the checkbox in the config menu (see screenshot below). If you use a variable speed on the joystick #1, you may wish to edit the scripts for the DPad in the buttons tab.
User-inserted image



Vibration
The vibration of the joystick's left and right rumble motors can be enabled via ControlCommand(). For example, to demonstrate variable control of the rumble motors with the finger triggers, add this JavaScript code to a script control and run it. Here is a project which includes the script for testing: test joystick.EZB

Code:


map = function (value, in_min, in_max, out_min, out_max) {

return (value - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}

while (true) {

var y1 = map(getVar("$JoystickX3"), 0, 255, 0, 100);

var y2 = map(getVar("$JoystickY3"), 0, 255, 0, 100);

ControlCommand("Joystick (XInput)", "VibrateLeftAndRight", y1, y2);

sleep(100);
}