Teensy 4.0 - Joystick mode stopped working 2 weeks ago

Unreadyashell

New member
Hi There, I've got 2no Teensy 4.0's connected to two separate HOTAS systems, they had both been running and working fine for +12 months - then ~2 weeks ago, I went to play a flying SIM game and my HOTAS wasn't recognised, so I went to the "Setup USB Game Controllers" - the device was recognised and showing up as "serial/keyboard/mouse/joystick" as it always had been, however, when clicking on 'Properties' the axis/buttons weren't showing up as they used to, and the 'Apply' button on the Test and Settings tabs, was greyed out/unable to press.

So, my next step was to try the other HOTAS system, and it was doing exactly the same - if it was just one of the boards/systems with this problem I'd think it was a hardware issue, however, for both of them to go from working to not, it would be unfortunate if both boards had a hardware issue at the same time.

Has anyone else has this issue recently or have any advice?

The code I had been (successfully) using is as below:

/* Complete USB Joystick Example
Teensy becomes a USB joystick with 16 or 32 buttons and 6 axis input

You must select Joystick from the "Tools > USB Type" menu

Pushbuttons should be connected between the digital pins and ground.
Potentiometers should be connected to analog inputs 0 to 5.

This example code is in the public domain.
*/

// Configure the number of buttons. Be careful not
// to use a pin for both a digital button and analog
// axis. The pullup resistor will interfere with
// the analog voltage.
const int numButtons = 2; // 16 for Teensy, 32 for Teensy++

void setup() {
// you can print to the serial monitor while the joystick is active!
Serial.begin(9600);
// configure the joystick to manual send mode. This gives precise
// control over when the computer receives updates, but it does
// require you to manually call Joystick.send_now().
Joystick.useManualSend(true);
for (int i=0; i<numButtons; i++) {
pinMode(i, INPUT_PULLUP);
}
Serial.println("Begin Complete Joystick Test");
}

byte allButtons[numButtons];
byte prevButtons[numButtons];
int angle=0;

void loop() {
// read 6 analog inputs and use them for the joystick axis
Joystick.X(analogRead(0));
Joystick.Y(analogRead(1));
Joystick.Z(analogRead(2));
Joystick.Zrotate(analogRead(3));
Joystick.sliderLeft(analogRead(4));

// read digital pins and use them for the buttons
for (int i=0; i<numButtons; i++) {
if (digitalRead(i)) {
// when a pin reads high, the button is not pressed
// the pullup resistor creates the "on" signal
allButtons = 1;
} else {
// when a pin reads low, the button is connecting to ground.
allButtons = 0;
}
Joystick.button(i + 1, allButtons);
}
// Because setup configured the Joystick manual send,
// the computer does not see any of the changes yet.
// This send_now() transmits everything all at once.
Joystick.send_now();

// check to see if any button changed since last time
boolean anyChange = false;
for (int i=0; i<numButtons; i++) {
if (allButtons != prevButtons) anyChange = true;
prevButtons = allButtons;
}
}

Many thanks in advance.
 
Back
Top