Sometimes during the competition, it would be nice if the sensitivity of the joystick could be lowered temporarily to allow you to maneuver more precisely. The code snippet below does exactly that. If you press button #7 on your gamepad (this is the right trigger on my gamepad), it halves the sensitivity of the joystick. That way, you can drop the sensitivity mid-match by simply holding down the right button.
Replace the joystick and motor code in Telop.vi with the snippet below.
The code is quite simple: the Joystick Get Values function outputs both an array of joystick data and an array of boolean button data. The index array function is used to get the boolean value of the specified button, in this case, button #7. That value is fed into a case structure. If the button is pressed, the case structure gives a value of 2. If it is not pressed, it gives a value of 1. The value of the joystick position is then divided by the output. This way, when button #7 is pressed, every joystick value is divided by two, dropping the sensitivity. If button #7 is not pressed, the joystick sensitivity is unchanged and the robot moves at full speed.