I'm using a teensy LC as a controller input with a raspberry Pi4 and retropie. I have two analog sticks and a slew of regular buttons. Right now I'm just picking usb type: keyboard+mouse+joystick, however the Pi sees it as several devices and in turn retropie thinks there are two gamepads. All my buttons work, but the analog sticks do not. When plugged into a windows 10 machine everything works fine, analog sticks respond along with buttons.
I can't find a solution, I have looked. I'm curious if there is a way to set the USB mode to joystick only instead of the multiple devices? Or if that is even related.
teensyduino 1.53 installed, if that matters.
The code is just standard bounce code for buttons and joystick commands. The loop is running Joystick.X(analogRead(6)); 4 times on the 4 axis, and then there are rising and falling edge commands to deal with sending buttons. Full code at the end.
If I run cat /proc/bus/input/devices I get the following output
Quite lost at this point, any help making this show up as a single device would be great.
Full code on the teensy. You can ignore the power stuff, I'm also using the teensy to watch a GPIO pin on the pi to know when it shut down and then the other pin is controlling my power circuit to let it kill power to the whole device once the pi is shutdown.
I can't find a solution, I have looked. I'm curious if there is a way to set the USB mode to joystick only instead of the multiple devices? Or if that is even related.
teensyduino 1.53 installed, if that matters.
The code is just standard bounce code for buttons and joystick commands. The loop is running Joystick.X(analogRead(6)); 4 times on the 4 axis, and then there are rising and falling edge commands to deal with sending buttons. Full code at the end.
If I run cat /proc/bus/input/devices I get the following output
Code:
pi@retropie:~ $ cat /proc/bus/input/devices
I: Bus=0003 Vendor=16c0 Product=0482 Version=0111
N: Name="Teensyduino Keyboard/Mouse/Joystick"
P: Phys=usb-0000:01:00.0-1.4/input0
S: Sysfs=/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.4/1-1.4:1.0/0003:16C0:0482.0001/input/input0
U: Uniq=8855790
H: Handlers=sysrq kbd leds event0
B: PROP=0
B: EV=120013
B: KEY=7 ff800000 7ff e0b2ffdf 1cfffff ffffffff fffffffe
B: MSC=10
B: LED=1f
I: Bus=0003 Vendor=16c0 Product=0482 Version=0111
N: Name="Teensyduino Keyboard/Mouse/Joystick Mouse"
P: Phys=usb-0000:01:00.0-1.4/input1
S: Sysfs=/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.4/1-1.4:1.1/0003:16C0:0482.0002/input/input1
U: Uniq=8855790
H: Handlers=mouse0 event1 js0
B: PROP=0
B: EV=1f
B: KEY=ff0000 0 0 0 0 0 0 0 0
B: REL=1943
B: ABS=3
B: MSC=10
I: Bus=0003 Vendor=16c0 Product=0482 Version=0111
N: Name="Teensyduino Keyboard/Mouse/Joystick"
P: Phys=usb-0000:01:00.0-1.4/input3
S: Sysfs=/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.4/1-1.4:1.3/0003:16C0:0482.0004/input/input2
U: Uniq=8855790
H: Handlers=event2 js1
B: PROP=0
B: EV=1b
B: KEY=ffff 0 0 0 0 0 0 0 0 0 0 0 0 ffff 0 0 0 0 0 0 0 0 0
B: ABS=30067
B: MSC=10
I: Bus=0003 Vendor=16c0 Product=0482 Version=0111
N: Name="Teensyduino Keyboard/Mouse/Joystick"
P: Phys=usb-0000:01:00.0-1.4/input4
S: Sysfs=/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.4/1-1.4:1.4/0003:16C0:0482.0005/input/input3
U: Uniq=8855790
H: Handlers=kbd event3 js2
B: PROP=0
B: EV=1f
B: KEY=300ff 0 0 0 0 4c3ffff 17aff32d bfd44456 0 c000000 1 130ffb 8b17c000 677bfa d951dfed 9ed680 4400 0 10000002
B: REL=1040
B: ABS=101 101ff
B: MSC=10
Quite lost at this point, any help making this show up as a single device would be great.
Full code on the teensy. You can ignore the power stuff, I'm also using the teensy to watch a GPIO pin on the pi to know when it shut down and then the other pin is controlling my power circuit to let it kill power to the whole device once the pi is shutdown.
Code:
#include <Bounce.h>
const int pwrcheck = 24;
const int pwroff = 25;
int boot = 0;
const int waittime = 60000;
int timenow = 0;
int pwrread = 1;
const int checktime = 5000;
int checknow = 0;
// Create Bounce objects for each button. The Bounce object
// automatically deals with contact chatter or "bounce", and
// it makes detecting changes very simple.
Bounce button2 = Bounce(2, 10); // which is appropriate for
Bounce button3 = Bounce(3, 10); // most mechanical pushbuttons
Bounce button4 = Bounce(4, 10);
Bounce button5 = Bounce(5, 10);
Bounce button6 = Bounce(6, 10);
Bounce button7 = Bounce(7, 10);
Bounce button8 = Bounce(8, 10);
Bounce button9 = Bounce(9, 10);
Bounce button10 = Bounce(10, 10);
Bounce button11 = Bounce(11, 10); // 10 = 10 ms debounce time
Bounce button12 = Bounce(12, 10); // which is appropriate for
Bounce button13 = Bounce(13, 10); // most mechanical pushbuttons
Bounce button14 = Bounce(14, 10);
Bounce button15 = Bounce(15, 10);
Bounce button16 = Bounce(16, 10);
Bounce button17 = Bounce(17, 10);
Bounce button18 = Bounce(18, 10);
Bounce button19 = Bounce(19, 10);
void setup() {
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
pinMode(5, INPUT_PULLUP);
pinMode(6, INPUT_PULLUP);
pinMode(7, INPUT_PULLUP);
pinMode(8, INPUT_PULLUP);
pinMode(9, INPUT_PULLUP);
pinMode(10, INPUT_PULLUP);
pinMode(11, INPUT_PULLUP);
pinMode(12, INPUT_PULLUP);
pinMode(13, INPUT_PULLUP);
pinMode(14, INPUT_PULLUP);
pinMode(15, INPUT_PULLUP);
pinMode(16, INPUT_PULLUP);
pinMode(17, INPUT_PULLUP);
pinMode(18, INPUT_PULLUP);
pinMode(19, INPUT_PULLUP);
pinMode(pwrcheck, INPUT);
pinMode(pwroff, OUTPUT);
digitalWrite(pwroff, LOW);
timenow = millis();
}
void loop() {
// read analog inputs and set X-Y position
Joystick.X(analogRead(6));
Joystick.Y(analogRead(7));
Joystick.Z(analogRead(8));
Joystick.Zrotate(analogRead(9));
// Update all the buttons. There should not be any long
// delays in loop(), so this runs repetitively at a rate
// faster than the buttons could be pressed and released.
button2.update();
button3.update();
button4.update();
button5.update();
button6.update();
button7.update();
button8.update();
button9.update();
button10.update();
button11.update();
button12.update();
button13.update();
button14.update();
button15.update();
button16.update();
button17.update();
button18.update();
button19.update();
// Check each button for "falling" edge.
// Update the Joystick buttons only upon changes.
// falling = high (not pressed - voltage from pullup resistor)
// to low (pressed - button connects pin to ground)
if (button2.fallingEdge()) {
Joystick.button(3, 1);
}
if (button3.fallingEdge()) {
Joystick.button(4, 1);
}
if (button4.fallingEdge()) {
Joystick.button(5, 1);
}
if (button5.fallingEdge()) {
Joystick.button(6, 1);
}
if (button6.fallingEdge()) {
Joystick.button(7, 1);
}
if (button7.fallingEdge()) {
Joystick.button(8, 1);
}
if (button8.fallingEdge()) {
Joystick.button(9, 1);
}
if (button9.fallingEdge()) {
Joystick.button(10, 1);
}
if (button10.fallingEdge()) {
Joystick.button(11, 1);
}
if (button11.fallingEdge()) {
Joystick.button(12, 1);
}
if (button12.fallingEdge()) {
Joystick.button(13, 1);
}
if (button13.fallingEdge()) {
Joystick.button(14, 1);
}
if (button14.fallingEdge()) {
Joystick.button(15, 1);
}
if (button15.fallingEdge()) {
Joystick.button(16, 1);
}
if (button16.fallingEdge()) {
Joystick.button(17, 1);
}
if (button17.fallingEdge()) {
Joystick.button(18, 1);
}
if (button18.fallingEdge()) {
Joystick.button(19, 1);
}
if (button19.fallingEdge()) {
Joystick.button(20, 1);
}
// Check each button for "rising" edge
// Update the Joystick buttons only upon changes.
// rising = low (pressed - button connects pin to ground)
// to high (not pressed - voltage from pullup resistor)
if (button2.risingEdge()) {
Joystick.button(3, 0);
}
if (button3.risingEdge()) {
Joystick.button(4, 0);
}
if (button4.risingEdge()) {
Joystick.button(5, 0);
}
if (button5.risingEdge()) {
Joystick.button(6, 0);
}
if (button6.risingEdge()) {
Joystick.button(7, 0);
}
if (button7.risingEdge()) {
Joystick.button(8, 0);
}
if (button8.risingEdge()) {
Joystick.button(9, 0);
}
if (button9.risingEdge()) {
Joystick.button(10, 0);
}
if (button10.risingEdge()) {
Joystick.button(11, 0);
}
if (button11.risingEdge()) {
Joystick.button(12, 0);
}
if (button12.risingEdge()) {
Joystick.button(13, 0);
}
if (button13.risingEdge()) {
Joystick.button(14, 0);
}
if (button14.risingEdge()) {
Joystick.button(15, 0);
}
if (button15.risingEdge()) {
Joystick.button(16, 0);
}
if (button16.risingEdge()) {
Joystick.button(17, 0);
}
if (button17.risingEdge()) {
Joystick.button(18, 0);
}
if (button18.risingEdge()) {
Joystick.button(19, 0);
}
if (button19.risingEdge()) {
Joystick.button(20, 0);
}
if (millis()- timenow > waittime && boot == 0){
boot = 1;
checknow = millis();
}
if (boot == 1 && millis() - checknow > checktime){
pwrread = digitalRead(pwrcheck);
if (pwrread == 0){
digitalWrite(pwroff, HIGH);
}
checknow = millis();
}
}