Hello guys.
I made an arduino code for joystick with mixed codes found in web and it has worked very nice to me, code below:
int pinos [] = {
0,1,2,3};
int lastButtonState[32] = {0,0,0,0};
#include "Joystick.h"
Joystick_ Joystick(
JOYSTICK_DEFAULT_REPORT_ID,
JOYSTICK_TYPE_JOYSTICK,
32, // +2 for the rotary encoder elevator trim
0,
true, // includeXAxis 1
true, // includeYAxis 2
false, // includeZAxis 3
true, // includeRxAxis 4
true, // includeRyAxis 5
false, // includeRzAxis 6
true, // includeRudder 7
true, // includeThrottle 8
false, // includeAccelerator
false, // includeBrake
false); // includeSteering
void setup() {
Joystick.setXAxisRange(0, 1023);
Joystick.setYAxisRange(0, 1023);
Joystick.setRudderRange (0, 1023);
Joystick.setThrottleRange (0, 1023);
Joystick.setRxAxisRange (0, 1023);
Joystick.setRyAxisRange (0, 1023);
for(int i=0; i<4; i++){
pinMode(pinos[i],INPUT_PULLUP);
}
Joystick.begin();
}
void loop() {
Joystick.setXAxis (analogRead(A2));
Joystick.setYAxis (analogRead(A3));
Joystick.setRudder (analogRead(A1));
Joystick.setThrottle (analogRead(A0));
Joystick.setRxAxis (analogRead(A7));
Joystick.setRyAxis (analogRead(A6));
for (int index = 0; index < 4; index++)
{
int currentButtonState = map(digitalRead(index + 0),HIGH,LOW,LOW,HIGH);
if (currentButtonState != lastButtonState[index])
{
Joystick.setButton(index, currentButtonState);
lastButtonState[index] = currentButtonState;
}
}
}
The question is: It would be nice to my gaming experience, to be able to add another analogic control.
If I change the line of Rzaxis to true, it works (potentiometer conected in #8 input of arduino micro), but in panel of gaming controllers of windows the rudder desapear. New controller is working (Rzaxis), and rudder is not more available. I have tryed with all other analogics, and got the same results.
What seems is that, is not possible to have more than 6 analogic inputs.
What could I do for having this 7th analogic controller?
Thanks.
