'Joystick_' does not name a type

Arduino: 1.8.5 (Windows 10), Board: "Arduino/Genuino Uno"

shifter:15: error: 'Joystick_' does not name a type

Joystick_ Joystick;

^

C:\Users\User\Documents\Arduino\shifter\shifter.ino: In function 'void setup()':

shifter:86: error: expected unqualified-id before '.' token

Joystick.begin();

^

C:\Users\User\Documents\Arduino\shifter\shifter.ino: In function 'void loop()':

shifter:138: error: expected unqualified-id before '.' token

Joystick.setButton(gear - 1, HIGH);

^

C:\Users\User\Documents\Arduino\shifter\shifter.ino: In function 'void desactivar()':

shifter:145: error: expected unqualified-id before '.' token

for (int i = 0; i <= 10 ; i++ ) Joystick.setButton(i, LOW);

^

exit status 1
'Joystick_' does not name a type

Ungültige Bibliothek C:\Program Files (x86)\Arduino\libraries\ArduinoJoystickLibrary-master in C:\Program Files (x86)\Arduino\libraries\ArduinoJoystickLibrary-master gefunden
Ungültige Bibliothek C:\Program Files (x86)\Arduino\libraries\ledpanel_8x2_max7219-master in C:\Program Files (x86)\Arduino\libraries\ledpanel_8x2_max7219-master gefunden
Ungültige Bibliothek C:\Program Files (x86)\Arduino\libraries\Matrix16x8-master in C:\Program Files (x86)\Arduino\libraries\Matrix16x8-master gefunden

Dieser Bericht wäre detaillierter, wenn die Option
"Ausführliche Ausgabe während der Kompilierung"
in Datei -> Voreinstellungen aktiviert wäre.

Out of the box the Arduino Leonardo or the Arduino Micro (and some other) can appear to the host computer as a generic keyboard and mouse but the arduino uno is not one of those and does not act as a USB joystick...

(which joystick class are you trying to use?)

@J-M-L

OK thank you for the info

I try to connect a Logitech G29 shifter on my PC

what about the arduino digispark does the work

J-M-L:
Out of the box the Arduino Leonardo or the Arduino Micro (and some other) can appear to the host computer as a generic keyboard and mouse but the arduino uno is not one of those and does not act as a USB joystick...

(which joystick class are you trying to use?)

/
l
l

Please post a link (using the chain links icon on the toolbar to make it clickable) to where you downloaded the joystick library from.

//Logitech Driving Force Shifter USB Adapter
//By Armandoiglesias 2018
//Based on Jason Duncan functionreturnfunction Project
//Video tutorial DIY LOGITECH USB SHIFTER ADAPTER DRIVING FORCE - YouTube
//Use Arduino Leonardo
//Install Joystick Library
//Attribution-NonCommercial-NoDerivatives 4.0 International

#include <Joystick.h>

// Create the Joystick
Joystick_ Joystick;

// H-shifter mode analog axis thresholds
#define HS_XAXIS_12 400
#define HS_XAXIS_56 500
#define HS_YAXIS_135 800
#define HS_YAXIS_246 300

// Sequential shifter mode analog axis thresholds
#define SS_UPSHIFT_BEGIN 670
#define SS_UPSHIFT_END 600
#define SS_DOWNSHIFT_BEGIN 430
#define SS_DOWNSHIFT_END 500

// Handbrake mode analog axis limits
#define HB_MAXIMUM 530
#define HB_MINIMUM 400
#define HB_RANGE (HB_MAXIMUM-HB_MINIMUM)

// Digital inputs definitions
#define DI_REVERSE 1
#define DI_MODE 3
#define DI_RED_CENTERRIGHT 4
#define DI_RED_CENTERLEFT 5
#define DI_RED_RIGHT 6
#define DI_RED_LEFT 7
#define DI_BLACK_TOP 8
#define DI_BLACK_RIGHT 9
#define DI_BLACK_LEFT 10
#define DI_BLACK_BOTTOM 11
#define DI_DPAD_RIGHT 12
#define DI_DPAD_LEFT 13
#define DI_DPAD_BOTTOM 14
#define DI_DPAD_TOP 15

// Shifter state
#define DOWN_SHIFT -1
#define NO_SHIFT 0
#define UP_SHIFT 1

// Shifter mode
#define SHIFTER_MODE 0
#define HANDBRAKE_MODE 1

// LED blink counter
int led = 0;

// Shifter state
int shift = NO_SHIFT;

// Handbrake mode
int mode = SHIFTER_MODE;

int b[16];

int gear = 0; // Default value is neutral

// Constant that maps the phyical pin to the joystick button.
//const int pinToButtonMap = 9;

void setup() {
// G29 shifter analog inputs configuration
pinMode(A0, INPUT_PULLUP); // X axis
pinMode(A2, INPUT_PULLUP); // Y axis

pinMode(2, INPUT);

for (int i = 0; i < 16; i++) b = 0;

  • b[DI_MODE] = 0;*
  • // Initialize Joystick Library*
  • Joystick.begin();*
    }
    // Last state of the button
    int lastButtonState = 0;
    void loop() {
  • int x = analogRead(0); // X axis*
  • int y = analogRead(2); // Y axis*
  • int _isreverse = digitalRead(2);*
  • int gear = 0;*
  • if ( _isreverse == 1 ) {*
  • gear = 8;*
  • b[DI_REVERSE] = 1;*
  • } else {*
  • if (b[DI_MODE] == 0) // H-shifter mode?*
  • {*
  • if (x < HS_XAXIS_12) // Shifter on the left?*
  • {*
  • if (y > HS_YAXIS_135) gear = 1; // 1st gear*
  • if (y < HS_YAXIS_246) gear = 2; // 2nd gear*
  • }*
  • else if (x > HS_XAXIS_56) // Shifter on the right?*
  • {*
  • if (y > HS_YAXIS_135) gear = 5; // 5th gear*
  • if (y < HS_YAXIS_246) gear = 6; // 6th gear*
  • }*
  • else // Shifter is in the middle*
  • {*
  • if (y > HS_YAXIS_135) gear = 3; // 3rd gear*
  • if (y < HS_YAXIS_246) gear = 4; // 4th gear*
  • }*
  • }*
  • }*
  • if (gear != 6) b[DI_REVERSE] = 0; // Reverse gear is allowed only on 6th gear position*
  • if (gear != gear ) {*
  • gear = gear;*
  • desactivar();*
  • Joystick.setButton(gear - 1, HIGH);*
  • }*
  • delay(50);*
    }
    void desactivar() {
  • // Depress virtual button for current gear*
  • for (int i = 0; i <= 10 ; i++ ) Joystick.setButton(i, LOW);*
    }

From the link you posted:

This library can be used with Arduino IDE 1.6.6 (or above) to add one or more joysticks (or gamepads) to the list of HID devices an Arduino Leonardo or Arduino Micro (or any Arduino clone that is based on the ATmega32u4) can support. This library will also work with the Arduino Due, thanks to @Palakis. A complete list of supported boards can be found in the Wiki. This will not work with Arduino IDE 1.6.5 (or below) or with non-32u4 based Arduino devices (e.g. Arduino UNO, Arduino MEGA, etc.).

It specifically says it can't be used with an Uno. The library can only use used with ATmega32U4-based boards and the Arduino Due.

jannikbaesken24:
what about the arduino digispark does the work

No. It won't work. The Digispark uses the ATtiny85 microcontroller. That microcontroller doesn't have the native USB functionality required by the library.

pert:
From the link you posted:It specifically says it can't be used with an Uno. The library can only use used with ATmega32U4-based boards and the Arduino Due.
No. It won't work. The Digispark uses the ATtiny85 microcontroller. That microcontroller doesn't have the native USB functionality required by the library.

OK Thank you

pert:
From the link you posted:It specifically says it can't be used with an Uno. The library can only use used with ATmega32U4-based boards and the Arduino Due.
No. It won't work. The Digispark uses the ATtiny85 microcontroller. That microcontroller doesn't have the native USB functionality required by the library.

Do you know another library that is compatible with the digispark

I have never used a digispark and don't know much about how their software USB implementation works. If you do a google search for digispark joystick you will get some helpful information.

It is also possible to use the ATmega16U2 on official or faithful clone Uno boards (many of the clones use a CH340 instead of the ATmega16U2, and that won't work) to emulate an HID joystick. You can find an example here:

However, that is a very advanced project and you may end up getting your Uno into a state where you can no longer use it if you do something wrong.

Digispark has its own keyboard, mouse and joystick libraries:
https://digistump.com/wiki/digispark/tutorials/digikeyboard