Inverting x-axis

When my team and I were testing the usb chicklet with the Logitech Dual action gamepad we experinced some difficulties with the x-axis of the left joystick. When attempting to turn the robot left it turned right, when attempting to turn right it turned left. We have tried re-calibrating it but it continued to give us the same reaction. Although it turns correctly with the KOP joystick we would really like the usb chicklet to work for us. We are not looking for advice on adjusting our program because we want the program to work with either the KOP joystick or the usb chicklet. If anyone knows any solution to this to problem we would greatly appreciate it.

You can flip the ‘direction’ of an analog input by using something like this (from our 2007 code)

DRIVE_LEFT = 254 - p1_y;
DRIVE_RIGHT = 254 - p2_y;

By default you will have to change the mapping of the joysticks when transitioning from two joy drive to a gamepad. Since the gamepad uses one port and joysticks require two. So no matter what you will have to change your code. My suggestion is to use preprocessor defines to make the transition easy.

For example:

// set the condition to 1 for gamepad assignments
#if (1)
#define LEFT_DRIVE 254-p1_y
#define RIGHT_DRIVE 254-p1_x

// change the above condition to 0 to use joystick assignments
#define LEFT_DRIVE p1_y
#define RIGHT_DRIVE p2_y

Or if you like, you could use a switch on the O/I to select from joy to gamepad. Preprocessor define will not work for this. You would use the same logic but during program flow.

#define LEFT_DRIVE pwm01
#define RIGHT_DRIVE pwm02

// if switch is true, use gamepad assignments
LEFT_DRIVE = 254-p1_y;
RIGHT_DRIVE = 254-p1_x;

// if switch is not true, use joystick assignments
LEFT_DRIVE = p1_y;

Please use 255, not 254.
If you use 254, and your joystick goes to max in one direction (255), you would get -1. Since the joystick input is an unsigned char, the value will “wrap around”, making it 255 again.

If you were trying to go left, it would suddenly go full power to the right.


inverted = 255 - normal;

We are using the Logitech Dual-Action gamepad. Our programmer calibrated it in mode 2 for one joystick drive.

We want to be able to use either the gamepad or a joystick without reprogramming.

Currently the USB-Chicklet inverts the output from the x-axis of the left stick on the gamepad. We want the gamepad to emulate the joystick. Changing the code on the robot controller or switching the wires attached to the speed controllers will not fix this.

Changing the code on the USB-Chicklet could fix it. Is there a jumper setting on the chicklet that will do this for us?

I have no experience with the chicklet, sorry.

Check out, calibration might be able to fix this.

Otherwise, you will have to resort to the software solution. You could put a switch on the OI that will let you select joystick or gamepad mode.

Calibration does not seem to fix the problem. Our programmer followed the user’s guide and tried both mode 2 & 3 several times.

I do not understand why the Chicklet was not programmed so it’s joysticks output matches standard/KOP joysticks.

Is this just a problem with the Logitech gamepad? Is there a way to change the code on our Chicklet?

I bet CTRE tried to design it so it matches analog joysticks. However, not all controllers have the same design (inverted x or y axis).

I would contact CTRE ( and ask them whether there is anything you can do. I doubt there is, however.

You can always just have something built into the code that you can quickly change. For example, you can have something like:

#ifdef USB
    pwm1 = p1_Y;
    pwm1 = 255 - p1_Y;

and define as needed.