Hello All,
I am working on a F16 Joystick and am getting non stop errors that I can not figure out.
#include <Keypad.h>
#include <Joystick.h>
#define NUMBUTTONS 19
#define NUMROWS 4
#define NUMCOLS 5
#define joyX A0
#define joyY A1
byte buttons[NUMROWS][NUMCOLS] = {
{0,1,2,3,4},
{5,6,7,8,9},
{10,11,12,13,14,},
{15,16,17,18,19},
};
byte rowPins[NUMROWS] = {10,14,15,16};
byte colPins[NUMCOLS] = {5,6,7,8,9};
int xAxis_ = 0;
int yAxis_ = 0;
Keypad buttbx = Keypad( makeKeymap(buttons), rowPins, colPins, NUMROWS, NUMCOLS);
Joystick_ Joystick(0x12, JOYSTICK_TYPE_JOYSTICK, 20, 0,true,true,false,false,false,false,false,false,false,false,false);
void setup() {
Joystick.begin();
}
void loop() {
xAxis_ = analogRead(joyX);
xAxis_ = map(xAxis_,0,1023,0,255);
Joystick.setXAxis(xAxis_);
yAxis_ = analogRead(joyY);
yAxis_ = map(yAxis_,0,1023,0,255);
Joystick.setYAxis(yAxis_);
CheckAllButtons();
delay(0);
}
void CheckAllButtons(void) {
if (buttbx.getKeys())
{
for (int i=0; i<LIST_MAX; i++)
{
if ( buttbx.key[i].stateChanged )
{
switch (buttbx.key[i].kstate) {
case PRESSED:
case HOLD:
Joystick.setButton(buttbx.key[i].kchar, 1);
break;
case RELEASED:
case IDLE:
Joystick.setButton(buttbx.key[i].kchar, 0);
break;
}
}
}
}
}
I am getting the following errors
Arduino: 1.8.19 (Windows 10), Board: "Arduino Leonardo"
code:28:1: error: 'Joystick_' does not name a type; did you mean 'Joystick'?
Joystick_ Joystick(0x12, JOYSTICK_TYPE_JOYSTICK, 20, 0,true,true,false,false,false,false,false,false,false,false,false);
^~~~~~~~~
Joystick
D:\3DPrints\F16Joystick\code\code.ino: In function 'void setup()':
code:32:11: error: expected unqualified-id before '.' token
Joystick.begin();
^
D:\3DPrints\F16Joystick\code\code.ino: In function 'void loop()':
code:40:11: error: expected unqualified-id before '.' token
Joystick.setXAxis(xAxis_);
^
code:44:11: error: expected unqualified-id before '.' token
Joystick.setYAxis(yAxis_);
^
D:\3DPrints\F16Joystick\code\code.ino: In function 'void CheckAllButtons()':
code:61:39: error: expected unqualified-id before '.' token
Joystick.setButton(buttbx.key[i].kchar, 1);
^
code:65:39: error: expected unqualified-id before '.' token
Joystick.setButton(buttbx.key[i].kchar, 0);
^
exit status 1
'Joystick_' does not name a type; did you mean 'Joystick'?
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.