laughingloud
New member
Hello, I am new to Teensy and coding in general. I am replacing a dpad with a analog stick on a gamepad. Just trying to get one Analog stick to work in game. I used the Teensy joystick example and got it working in the windows game controller properties. It also works on a html gamepad test site but the game doesn't recognize it. It shows up as a Keyboard/Mouse/Joystick under game controllers. I would like for it to act as the left analog stick like the xbox controller on Windows. I appreciate any help. I tried searching but every similar project seemed too advanced and not the same problem I was having.
*Edit I wired the analog signals to 8 and 9
*Edit I wired the analog signals to 8 and 9
Code:
/* Basic USB Joystick Example
Teensy becomes a USB joystick
You must select Joystick from the "Tools > USB Type" menu
Pushbuttons should be connected to digital pins 0 and 1.
Wire each button between the digital pin and ground.
Potentiometers should be connected to analog inputs 0 to 1.
This example code is in the public domain.
*/
void setup() {
pinMode(0, INPUT_PULLUP);
pinMode(1, INPUT_PULLUP);
}
void loop() {
// read analog inputs and set X-Y position
Joystick.X(analogRead(8));
Joystick.Y(analogRead(9));
// read the digital inputs and set the buttons
Joystick.button(1, digitalRead(0));
Joystick.button(2, digitalRead(1));
// a brief delay, so this runs 20 times per second
delay(50);
}
Last edited: