Go Down

Topic: 'Joystick_' does not name a type (Read 712 times) previous topic - next topic

jannikbaesken24

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.

J-M-L

#1
Jan 05, 2019, 07:47 pm Last Edit: Jan 05, 2019, 07:49 pm by 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?)
Hello - Please do not PM me for help,  others will benefit as well if you post your question publicly on the forums.
Bonjour Pas de messages privés SVP, postez dans le forum directement pour que ça profite à tous

jannikbaesken24

@J-M-L

OK thank you for the info


I try to connect a Logitech G29 shifter on my PC

jannikbaesken24

what about the arduino digispark does the work

jannikbaesken24

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

pert

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


jannikbaesken24



//Logitech Driving Force Shifter USB Adapter
//By Armandoiglesias 2018
//Based on Jason Duncan functionreturnfunction Project
//Video tutorial https://www.youtube.com/watch?v=dLpWEu8kCec
//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);
}


pert

From the link you posted:
Quote
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.

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.

jannikbaesken24

#9
Jan 05, 2019, 09:53 pm Last Edit: Jan 05, 2019, 09:54 pm by jannikbaesken24
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

jannikbaesken24


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

pert

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:
https://github.com/NicoHood/HID
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.

oqibidipo


Go Up