Teensy 4.0 registering multiple devices on RPI5
-
I have a raspberry pi 5 with pi OS installed and I use a Teensy 4.0 to convert my buttons to a USB gamepad that can be detected, I use emulation station as a frontend and when i configure my controls all digital buttons work expect for joystick. The joysticks are really unresponsive and don't work on the raspberry pi. However, on my computer running Windows 11 it works perfectly.
Below is my Arduino code it used. Also the USB type I selected for the Teensy was Keyboard + Mouse + Joystickvoid setup() { // pinmode(Actual button on Teensy pin, INPUT_PULLUP)
Serial.begin(9600);
pinMode(0, INPUT_PULLUP); // A
pinMode(1, INPUT_PULLUP); // B
pinMode(2, INPUT_PULLUP); // X
pinMode(3, INPUT_PULLUP); // Y
pinMode(4, INPUT_PULLUP); // D-up
pinMode(5, INPUT_PULLUP); // D-down
pinMode(6, INPUT_PULLUP); // D-Left
pinMode(7, INPUT_PULLUP); // D-right
pinMode(8, INPUT_PULLUP); // Select
pinMode(9, INPUT_PULLUP); // Start
pinMode(10, INPUT_PULLUP); // L
pinMode(11, INPUT_PULLUP);// R
pinMode(12, INPUT_PULLUP);// L3
pinMode(13, INPUT_PULLUP);// R3
pinMode(14, INPUT_PULLUP);// R3
pinMode(18, INPUT_PULLUP);// R2
pinMode(19, INPUT_PULLUP);// L2
}void loop() {
// read analog inputs and set X-Y position | Joystick.X(analogRead(analog pins 0 - 9))
Joystick.X(analogRead(2));
Joystick.Y(analogRead(3));
Joystick.Z(analogRead(0));
Joystick.Zrotate(analogRead(1));// if (!digitalRead(0) == 1) {
// digitalWrite(13,1);
// } else {
// digitalWrite(13,0);
// }// read the digital inputs and set the buttons
Joystick.button(1, !digitalRead(0)); // Joystick.button(the button number(its just what you want the button's number to be), !DigitalRead(Button Pin)
Joystick.button(2, !digitalRead(1));
Joystick.button(3, !digitalRead(2));
Joystick.button(4, !digitalRead(3));
Joystick.button(5, !digitalRead(4));
Joystick.button(6, !digitalRead(5));
Joystick.button(7, !digitalRead(6));
Joystick.button(8, !digitalRead(7));
Joystick.button(9, !digitalRead(8));
Joystick.button(10, !digitalRead(9));
Joystick.button(11, !digitalRead(10));
Joystick.button(12, !digitalRead(11));
Joystick.button(13, !digitalRead(12));
Joystick.button(14, !digitalRead(13));
Joystick.button(15, !digitalRead(18));
Joystick.button(16, !digitalRead(19));
// a brief delay, so this runs 20 times per second
delay(50);
} -
If the inputs are not registering correctly when testing the input with
evtest
orjstest
, they won't be delivered correctly also to EmulationStation - this is not related to any RetroPie configuration, but it's an OS (Linux) or Arduino issue. -
@mitu i used some of the jstest-gtk commands and i was wondering how can I edit the joystick's deadzone?
-
You can use
jscal
to modify the deadzone(s) of an analog joystick, thenjscal-store
to save the values so they can be applied automatically on boot.
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.