Thumbnail

Joystick (Direct Input)

+ How To Add This Control To Your Project (Click to Expand)
  1. Load the most recent release of ARC.
  2. Press the Project tab from the top menu bar in ARC.
  3. Press Add Control from the button ribbon bar in ARC.
  4. Choose the Misc category tab.
  5. Press the Joystick (Direct Input) icon to add the control to your project.
A joystick can be connected and used with ARC to control movement, servo positions, and assign scripts to buttons. For XInput joysticks (such as Xbox), use the Joystick (Xinput) skill.

By default, the Analog/Digital joystick #1 is configured to control a movement panel. This can be changed by using the Config button and assigning servos to the joystick instead. Each button can execute a script by either press down or release up.

*Note: If your joystick is connected after the project has been loaded, press the Refresh button to detect and load the joystick.

Main Window




1. Device Drop-down
This drop down shows the DirectInput devices that are available to be used by the Joystick DirectInput Skill

2. Refresh Button
This button refreshes the devices listed in the Device drop-down. Whenever a new device is inserted into the computer you will have to press refresh to have it show up.

3. Status Field
This displays the status of the skill's connection to the Joystick DirectInput controller.

Settings - Joystick #1 Tab




1. Joystick #1 Controls Movement Panel Checkbox
This checkbox enables the left joystick #1 to control a movement panel. By default the D-Pad has assigned scripts for calling forward(), reverse(), left(), right(), and stop() movement panel commands. However, the D-Pad does not give you variable speed control, so you can enable the joystick to control movements with variable speed. If you use a variable speed on the joystick, you may wish to edit the scripts for the D-Pad in the buttons tab.

2. Servo Control
By default, the left joystick#1 will control servos. This option is only available when the Joystick #1 Controls Movement Panel Checkbox is unchecked. This section allows you to set up servo movement parameters such as servo port, board index, servo configuration, max/min degree limitations, multiple servo control, and inverted direction.

3. Use Variable Movement speed Checkbox
This option is only available when the Joystick #1 Controls Movement Panel Checkbox is enabled. Instead of fully on/off this checkbox can enable the analog functionality of the left joystick to variably adjust the speed of a movement panel (if the movement panel supports it).

4. Movement Sensitivity Drop-down
This option is only available when the Joystick #1 Controls Movement Panel Checkbox is enabled. This value controls the sensitivity of the joystick. The joystick values move in a range between -1 and 1. The default value is 0.25, this means that the joystick must move more than 0.25 to register as a movement.

Settings - Joystick #2 Tab




1. Joystick #2 Controls Drone Up/Down/Roll Checkbox
This checkbox enables the right joystick #2 to control a Up/Down/Roll of the A.R. Drone movement panel. If unchecked the joystick will control the configured servos.

2. Servo Control
By default the right joystick#2 will control servos. This option is only available when the joystick Controls Drone Checkbox is unchecked. This section allows you to setup servo movement parameters such as servo port, board index, servo configuration, max/min degree limitations, multiple servo control and inverted direction.

Settings - Joystick #3 Tab




1. Servo Control
By default the left and right triggers will control servos. This section allows you to set up servo movement parameters such as servo port, board index, servo configuration, max/min degree limitations, multiple servo control, and inverted direction. If servo control is not desired, don't configure them, and you can use the triggers for other tasks such as activating the vibration motors. See the code sample below.

Settings - Buttons Tab


1. Button Number Field
The buttons of joysticks can internally be labelled differently from one device to another, so we generically numbered them for you. To see what button corresponds to the script positions, simply push the button to see the respective row highlight in blue.

2. Button Down Command Field
When a button is pressed down the script in the corresponding position will activate.

3. Button Up Command Field
When a button is released the script in the corresponding position will activate.

Settings - Variables Tab




1. Set EZ-Script Variables Checkbox
If this checkbox is enabled there will be variables assigned to the analog joystick positions. The analog joystick #1 (left) and #2 (right) will set variable values between -32768 and 32767. The analog triggers will set variable values between 0 and 255.

2. Variable Section
This section assigns the joystick and trigger values to customizable variable names.

How to Use Joystick (Direct Input)


1) Add the Joystick (Direct Input) skill to your ARC project (Project -> Add Skill -> Misc -> Joystick (Direct Input)).

2) Plug your wireless/wired joystick into one of your PC's USB ports (or connect via Bluetooth).

3) Find your Joystick in the Device drop-down and select it.

4) If you don't see your joystick listed, click the refresh button and try step 3 again.

5) Once the Status field reports that you are connected you can then enter the Settings and configure your Joystick.

Code Sample


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 skill and run it.

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 (Direct Input)", "VibrateLeftAndRight", y1, y2);

  sleep(100);

}

Requirements

We recommend the Logitech F710 Wireless Joystick. If you use the Logitech joystick, ensure the switch is selected to the D position and not X. The D position means DirectInput, and X means XInput. This particular ARC joystick skill operates in DirectInput mode.

Different joysticks support a variety of drivers. The ARC software uses the DirectInput Native Windows Driver for this skill.

Resources


Xbox Controller Mapping
When using an Xbox controller, there is a button/stick mapping posted on Microsoft's website. The D-pad is not functional using Xbox and DirectInput. Another difference is the trigger buttons are both connected together.




Video