I am using the joystick library included in Teensy, since the one from Arduino does not work on the Teensy.
Although I can't find API usage and documentation, and I am stuck now.
When I connect the Teensy 3.1; Windows 10 see it as a 32 buttons joystick with HAT , Zaxis, Zrotation and 2 sliders.
How do I change the number of buttons and the axis? I just need 2 axis, but I need 40 buttons.
Also I get this behavior where any button pressed does throw off the axis (I did not connect the pots to the teensy); I did attach 2 images to show what happen after I press a button.
This is how I use the joystick class; but since arduino IDE does not do autocompletion, I can't even try to parse all the properties and methods and figure things out on my own.
Although I can't find API usage and documentation, and I am stuck now.
When I connect the Teensy 3.1; Windows 10 see it as a 32 buttons joystick with HAT , Zaxis, Zrotation and 2 sliders.
How do I change the number of buttons and the axis? I just need 2 axis, but I need 40 buttons.
Also I get this behavior where any button pressed does throw off the axis (I did not connect the pots to the teensy); I did attach 2 images to show what happen after I press a button.
This is how I use the joystick class; but since arduino IDE does not do autocompletion, I can't even try to parse all the properties and methods and figure things out on my own.
Code:
int button1 = 2;
int button2 = 7;
void setup() {
Joystick.useManualSend(true);
pinMode(button1, INPUT_PULLUP);
pinMode(button2, INPUT_PULLUP);
}
void loop() {
// the 2 axis for the pots
Joystick.sliderLeft(analogRead(7));
Joystick.sliderRight(analogRead(8));
if (digitalRead(button1 == HIGH) {
Joystick.button(1,1);
Joystick.send_now();
delay(10);
} else {
Joystick.button(1,0);
Joystick.send_now();
delay(10);
}
if (digitalRead(button2 == HIGH) {
Joystick.button(2,1);
Joystick.send_now();
delay(10);
} else {
Joystick.button(2,0);
Joystick.send_now();
delay(10);
}