Joystick (Xinput)

by Synthiam

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

How to add the Joystick (Xinput) robot skill

  1. Load the most recent release of ARC (Get ARC).
  2. Press the Project tab from the top menu bar in ARC.
  3. Press Add Robot Skill from the button ribbon bar in ARC.
  4. Choose the Remote Control category tab.
  5. Press the Joystick (Xinput) icon to add the robot skill to your project.

Don't have a robot yet?

Follow the Getting Started Guide to build a robot and use the Joystick (Xinput) robot skill.

How to use the Joystick (Xinput) robot skill

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

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

Main Window

User-inserted image

1. Device Drop-down
This drop-down shows the Xinput devices that are available to be used by the Joystick Xinput 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 Xinput controller.

Settings - Left Stick Tab

User-inserted image

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. Movement Control Deadband Value Field
This option is only available when the left joystick #1 Controls Movement Panel Checkbox is enabled. This value controls the sensitivity of the joystick. The joystick values move in a range between -32768 and 32767. If the value is 800, the joystick must move to a value greater than +/- 800 from the center for the joystick to respond. The lower the number, the more sensitive the joystick will be.

Settings - Right Stick Tab

User-inserted image

1. Joystick #2 Controls Drone Up/Down/Roll Checkbox
This checkbox enables the right joystick #2 to control the 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 the servos. This option is only available when the joystick Controls Drone 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.

Settings - Triggers Tab

User-inserted image

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

User-inserted image

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

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

3. Button Up Command Field
The script in the corresponding position will activate when a button has been released.

Movement Control

The joystick controls the current Movement Panel that has been added to the project. When a Movement Panel is being used that supports variable speeds, you will have the ability to move forward or reverse with a slight right or left turn. The analog stick can be moved to the right or left to rotate the robot or spin it on the spot.

The dead band can be configured, which determines how much the joystick must move before registering as a movement. It is also used to determine how large the spin-on-spot (right/left) band is. 

User-inserted image

Settings - Variables Tab

User-inserted image

1. Set EZ-Script Variables Checkbox
Variables will be assigned to the analog joystick positions if this checkbox is enabled. 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 (XInput)

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

2) Plug your wireless/wired joystick into 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 enter the Settings and configure your Joystick. 

Code Sample

The vibration of the joystick's left and suitable 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 (XInput)", "VibrateLeftAndRight", y1, y2);



This skill 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 labeled D or X. For this skill, change the switch to X.


Here is a project which includes the script for testing the joystick xinput functions: test joystick.EZB


Upgrade to ARC Pro

Harnessing the power of ARC Pro, your robot can be more than just a simple automated machine.

I have a copy cat PS3 game pad bought from EB Games, works as direct replacement bluetooth to PS3 or on windows steam games through USB c Cable....would something like this work if I wanted to take control of a Roomba?
Hey thanks Jer, will try that out now!
Oh Jer ,forgot to mention you outdid yourself on the Tiny That pulsing L.E.D. reminds me of the bright heart beat on the EZv3 and the cute munchkin voice when it starts,ha ha right on Jer!
#5   — Edited
Does anyone know if shoulder buttons, the direction pad and buttons x, y,a, b can be read?
@TMesserschmidt I'm not sure about the D-pad but the rest for sure!
Yes. The d pad is used. By default they’re set for movement. See screenshot in the manual above. They are mapped button inputs 2-5
@DJ Looking into it further it seems that the D-pad doesn't work with Xinput. The manual above does mention: "The D-pad is not functional using Xbox and XInput."
Really? Hmmm mine maps to those buttons. Wonder if there’s different modes. Sure your testing joystick is set for xinput rather than direct input?
Here is a short screencap of demonstrating the D-Pad buttons being detected in the config menu of this robot skill. If your joystick has a switch to manually change between D (direct input) and X (XInput), ensure the switch is on X.

@DJ I was just going by what the manual says above. I believe the info was a copy/paste of the original info that was there when the skill was updated. Have you tried with an Xbox controller?
#12   — Edited
According to the X Input mappings from Microsoft in the above manual, the xbox controller does not work with dpad. If it does work, then microsoft's documentation is outdated. I have no way of knowing if xBox controllers dpad works because I don't have one. You'd have to plug it in and test. Thomas did not ask about xBox controller - this question is about X Input devices. My video demonstrated that the dpad works with Xinput joysticks.
Just to clarify, Xbox controllers are considered Xinput controllers as well. 

No worries though, I'm an Xbox guy so when I get home from Vernon I'll test out Xbox 360 and Xbox one controllers with this skill and let you know:D
According to Microsoft’s documentation, they’re only kinda not really xinput. Remember, it’s not our code that decides what the controller buttons do. The API is created by Microsoft and it’s their api that returns the buttons. If their api doesn’t work fully with Xbox controllers, it is out of our hands. 

I do have a hard time imagining them not working - because my controller is an Xbox compatible one. And it works great. So guess we will see when Jeremie tests his:)
Hey guys,

Sorry it took me so long to get back to you all, I've had a very interesting and busy summer. 

Good news! The D-pad on Xbox controllers does work with the Xinput skill in ARC. The documentation can be updated above to mention that they are supported.

I verified with an Xbox One S Controller (which can connect to Windows via Bluetooth) and a Xbox 360 controller (which can connect to windows with a special USB dongle) that the D-pads work. 

Awesome jer! Thanks for checking with an official Xbox controller
Updated v10 to include an option for Max Speed
v11 fix for right analog joystick
Updated to include a max turn spin speed to compliment the max forward/reverse speed

User-inserted image