Joystick_ does not name a type

Getting this when verifying/uploading to Arduino Leonardo. I downloaded this sketch for a button box DIY. Just trying to figure out why I am getting this.

Arduino: 1.8.9 (Windows Store 1.8.21.0) (Windows 10), Board: “Arduino Leonardo”

ARDUINO_BUTTON_BOXV2:95:1: error: ‘Joystick_’ does not name a type

Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID,

^

C:\Users\raycr\Documents\Arduino\32-FUNCTION-BUTTON-BOX-master\ARDUINO_BUTTON_BOXV2\ARDUINO_BUTTON_BOXV2.ino: In function ‘void setup()’:

ARDUINO_BUTTON_BOXV2:101:11: error: expected unqualified-id before ‘.’ token

Joystick.begin();

^

C:\Users\raycr\Documents\Arduino\32-FUNCTION-BUTTON-BOX-master\ARDUINO_BUTTON_BOXV2\ARDUINO_BUTTON_BOXV2.ino: In function ‘void CheckAllButtons()’:

ARDUINO_BUTTON_BOXV2:123:21: error: expected unqualified-id before ‘.’ token

Joystick.setButton(buttbx.key*.kchar, 1);*

  • ^*
    ARDUINO_BUTTON_BOXV2:127:21: error: expected unqualified-id before ‘.’ token
    _ Joystick.setButton(buttbx.key*.kchar, 0);_
    _
    ^_
    C:\Users\raycr\Documents\Arduino\32-FUNCTION-BUTTON-BOX-master\ARDUINO_BUTTON_BOXV2\ARDUINO_BUTTON_BOXV2.ino: In function ‘void CheckAllEncoders()’:
    ARDUINO_BUTTON_BOXV2:158:15: error: expected unqualified-id before ‘.’ token
    Joystick.setButton(rotaries_.ccwchar, 1); delay(50); Joystick.setButton(rotaries.ccwchar, 0);
    ^
    ARDUINO_BUTTON_BOXV2:158:70: error: expected unqualified-id before ‘.’ token
    Joystick.setButton(rotaries.ccwchar, 1); delay(50); Joystick.setButton(rotaries.ccwchar, 0);
    ^
    ARDUINO_BUTTON_BOXV2:161:15: error: expected unqualified-id before ‘.’ token
    Joystick.setButton(rotaries.cwchar, 1); delay(50); Joystick.setButton(rotaries.cwchar, 0);
    ^
    ARDUINO_BUTTON_BOXV2:161:69: error: expected unqualified-id before ‘.’ token
    Joystick.setButton(rotaries.cwchar, 1); delay(50); Joystick.setButton(rotaries.cwchar, 0);
    ^
    Multiple libraries were found for “Joystick.h”
    Used: C:\Users\raycr\Documents\Arduino\libraries\Joystick
    Not used: C:\Users\raycr\Documents\Arduino\libraries\AxisJoystick
    exit status 1_

    ‘Joystick_’ does not name a type*

    This report would have more information with
    “Show verbose output during compilation”
    option enabled in File → Preferences.

As usual, in order to compile this sketch you need the joystick library this sketch was designed to work with. You don't have that library.

You have "some" library that also have a Joystick.h file in it, but it is a wrong one.

And I assume there is no way to find out the correct library without talking to who ever created the sketch?

You can do a search on some distinctive identifiers. For example, a search on JOYSTICK_DEFAULT_REPORT_ID comes up with

https://github.com/MHeironimus/ArduinoJoystickLibrary/blob/master/Joystick/src/Joystick.h

which appears to be what you need.

Note this important information the Arduino IDE is telling you:

raycrews0:

Multiple libraries were found for "Joystick.h"

Used: C:\Users\raycr\Documents\Arduino\libraries\Joystick
Not used: C:\Users\raycr\Documents\Arduino\libraries\AxisJoystick

You have two libraries installed that contain a file named Joystick.h. The Arduino chose C:\Users\raycr\Documents\Arduino\libraries\Joystick because the folder name matches the header file name. If your code was written instead for the library at C:\Users\raycr\Documents\Arduino\libraries\AxisJoystick, then you would need to find a way to force the Arduino IDE to use the correct library. There are a few ways to accomplish that. The most simple is to delete the unwanted library. That's not such a great solution if you have some sketches that use one library and some sketches that use the other. On the other hand, I can't imagine needing two Joystick libraries. I would choose the best one and write all my code for that one.

For all I know, neither of those libraries is the one your sketch was written for and you just grabbed some libraries at random hoping one would work (not a great strategy as you can now see).

Montmorency:
You can do a search on some distinctive identifiers. For example, a search on JOYSTICK_DEFAULT_REPORT_ID comes up with

https://github.com/MHeironimus/ArduinoJoystickLibrary/blob/master/Joystick/src/Joystick.h

GitHub - MHeironimus/ArduinoJoystickLibrary: An Arduino library that adds one or more joysticks to the list of HID devices an Arduino Leonardo or Arduino Micro can support.

which appears to be what you need.

So this worked. THANK YOU!

This is my first go around with Arduino, and you guys are awesome.

My next question is, I wired up a 5x5 matrix of buttons (for sim racing button box). I have 4 individual buttons all registering as 1 in properties. Any ideas?

My next question is, I wired up a 5x5 matrix of buttons (for sim racing button box). I have 4 individual buttons all registering as 1 in properties. Any ideas?

I have an idea. You should post your code.
I have another idea. You should post a schematic.
I have another idea. You should pretend we know nothing about your system, and tell us which buttons you sewd on that all register (whatever that means) as 1. You should also explain what "in properties" means.