Need Help With 2 axis control

I am new to coding and Arduino's and I'm making a sim racing wheel and connect it to my computer and i keep getting a error with peoples code and even with joystick lib driving controller example code on my Leonardo and the error is:

C:\Users\rexim\AppData\Local\Temp\822db133-87a6-41cb-b33e-234bfbeeee2a_ArduinoJoystickLibrary-version-2.0.zip.e2a\ArduinoJoystickLibrary-version-2.0\examples\DrivingControllerTest\DrivingControllerTest.ino:11:1: error: 'Joystick_' does not name a type; did you mean 'Joystick'?
 Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID,
 ^~~~~~~~~
 Joystick
C:\Users\rexim\AppData\Local\Temp\822db133-87a6-41cb-b33e-234bfbeeee2a_ArduinoJoystickLibrary-version-2.0.zip.e2a\ArduinoJoystickLibrary-version-2.0\examples\DrivingControllerTest\DrivingControllerTest.ino: In function 'void testSingleButtonPush(unsigned int)':
C:\Users\rexim\AppData\Local\Temp\822db133-87a6-41cb-b33e-234bfbeeee2a_ArduinoJoystickLibrary-version-2.0.zip.e2a\ArduinoJoystickLibrary-version-2.0\examples\DrivingControllerTest\DrivingControllerTest.ino:30:13: error: expected unqualified-id before '.' token
     Joystick.releaseButton(button - 1);
             ^
C:\Users\rexim\AppData\Local\Temp\822db133-87a6-41cb-b33e-234bfbeeee2a_ArduinoJoystickLibrary-version-2.0.zip.e2a\ArduinoJoystickLibrary-version-2.0\examples\DrivingControllerTest\DrivingControllerTest.ino:34:13: error: expected unqualified-id before '.' token
     Joystick.pressButton(button);
             ^
C:\Users\rexim\AppData\Local\Temp\822db133-87a6-41cb-b33e-234bfbeeee2a_ArduinoJoystickLibrary-version-2.0.zip.e2a\ArduinoJoystickLibrary-version-2.0\examples\DrivingControllerTest\DrivingControllerTest.ino: In function 'void testMultiButtonPush(unsigned int)':
C:\Users\rexim\AppData\Local\Temp\822db133-87a6-41cb-b33e-234bfbeeee2a_ArduinoJoystickLibrary-version-2.0.zip.e2a\ArduinoJoystickLibrary-version-2.0\examples\DrivingControllerTest\DrivingControllerTest.ino:46:17: error: expected unqualified-id before '.' token
         Joystick.pressButton(button);
                 ^
C:\Users\rexim\AppData\Local\Temp\822db133-87a6-41cb-b33e-234bfbeeee2a_ArduinoJoystickLibrary-version-2.0.zip.e2a\ArduinoJoystickLibrary-version-2.0\examples\DrivingControllerTest\DrivingControllerTest.ino:49:17: error: expected unqualified-id before '.' token
         Joystick.releaseButton(button);
                 ^
C:\Users\rexim\AppData\Local\Temp\822db133-87a6-41cb-b33e-234bfbeeee2a_ArduinoJoystickLibrary-version-2.0.zip.e2a\ArduinoJoystickLibrary-version-2.0\examples\DrivingControllerTest\DrivingControllerTest.ino:56:17: error: expected unqualified-id before '.' token
         Joystick.pressButton(button);
                 ^
C:\Users\rexim\AppData\Local\Temp\822db133-87a6-41cb-b33e-234bfbeeee2a_ArduinoJoystickLibrary-version-2.0.zip.e2a\ArduinoJoystickLibrary-version-2.0\examples\DrivingControllerTest\DrivingControllerTest.ino:59:17: error: expected unqualified-id before '.' token
         Joystick.releaseButton(button);
                 ^
C:\Users\rexim\AppData\Local\Temp\822db133-87a6-41cb-b33e-234bfbeeee2a_ArduinoJoystickLibrary-version-2.0.zip.e2a\ArduinoJoystickLibrary-version-2.0\examples\DrivingControllerTest\DrivingControllerTest.ino:64:15: error: expected unqualified-id before '.' token
       Joystick.releaseButton(button);
               ^
C:\Users\rexim\AppData\Local\Temp\822db133-87a6-41cb-b33e-234bfbeeee2a_ArduinoJoystickLibrary-version-2.0.zip.e2a\ArduinoJoystickLibrary-version-2.0\examples\DrivingControllerTest\DrivingControllerTest.ino: In function 'void testAcceleratorBrake(int)':
C:\Users\rexim\AppData\Local\Temp\822db133-87a6-41cb-b33e-234bfbeeee2a_ArduinoJoystickLibrary-version-2.0.zip.e2a\ArduinoJoystickLibrary-version-2.0\examples\DrivingControllerTest\DrivingControllerTest.ino:71:11: error: expected unqualified-id before '.' token
   Joystick.setAccelerator(value);
           ^
C:\Users\rexim\AppData\Local\Temp\822db133-87a6-41cb-b33e-234bfbeeee2a_ArduinoJoystickLibrary-version-2.0.zip.e2a\ArduinoJoystickLibrary-version-2.0\examples\DrivingControllerTest\DrivingControllerTest.ino:72:11: error: expected unqualified-id before '.' token
   Joystick.setBrake(260 - value);
           ^
C:\Users\rexim\AppData\Local\Temp\822db133-87a6-41cb-b33e-234bfbeeee2a_ArduinoJoystickLibrary-version-2.0.zip.e2a\ArduinoJoystickLibrary-version-2.0\examples\DrivingControllerTest\DrivingControllerTest.ino: In function 'void testSteering(int)':
C:\Users\rexim\AppData\Local\Temp\822db133-87a6-41cb-b33e-234bfbeeee2a_ArduinoJoystickLibrary-version-2.0.zip.e2a\ArduinoJoystickLibrary-version-2.0\examples\DrivingControllerTest\DrivingControllerTest.ino:78:13: error: expected unqualified-id before '.' token
     Joystick.setSteering(value);
             ^
C:\Users\rexim\AppData\Local\Temp\822db133-87a6-41cb-b33e-234bfbeeee2a_ArduinoJoystickLibrary-version-2.0.zip.e2a\ArduinoJoystickLibrary-version-2.0\examples\DrivingControllerTest\DrivingControllerTest.ino:80:13: error: expected unqualified-id before '.' token
     Joystick.setSteering(600 - value);
             ^
C:\Users\rexim\AppData\Local\Temp\822db133-87a6-41cb-b33e-234bfbeeee2a_ArduinoJoystickLibrary-version-2.0.zip.e2a\ArduinoJoystickLibrary-version-2.0\examples\DrivingControllerTest\DrivingControllerTest.ino: In function 'void setup()':
C:\Users\rexim\AppData\Local\Temp\822db133-87a6-41cb-b33e-234bfbeeee2a_ArduinoJoystickLibrary-version-2.0.zip.e2a\ArduinoJoystickLibrary-version-2.0\examples\DrivingControllerTest\DrivingControllerTest.ino:86:11: error: expected unqualified-id before '.' token
   Joystick.setAcceleratorRange(0, 260);
           ^
C:\Users\rexim\AppData\Local\Temp\822db133-87a6-41cb-b33e-234bfbeeee2a_ArduinoJoystickLibrary-version-2.0.zip.e2a\ArduinoJoystickLibrary-version-2.0\examples\DrivingControllerTest\DrivingControllerTest.ino:87:11: error: expected unqualified-id before '.' token
   Joystick.setBrakeRange(0, 260);
           ^
C:\Users\rexim\AppData\Local\Temp\822db133-87a6-41cb-b33e-234bfbeeee2a_ArduinoJoystickLibrary-version-2.0.zip.e2a\ArduinoJoystickLibrary-version-2.0\examples\DrivingControllerTest\DrivingControllerTest.ino:88:11: error: expected unqualified-id before '.' token
   Joystick.setSteeringRange(0, 300);
           ^
C:\Users\rexim\AppData\Local\Temp\822db133-87a6-41cb-b33e-234bfbeeee2a_ArduinoJoystickLibrary-version-2.0.zip.e2a\ArduinoJoystickLibrary-version-2.0\examples\DrivingControllerTest\DrivingControllerTest.ino:92:13: error: expected unqualified-id before '.' token
     Joystick.begin();
             ^
C:\Users\rexim\AppData\Local\Temp\822db133-87a6-41cb-b33e-234bfbeeee2a_ArduinoJoystickLibrary-version-2.0.zip.e2a\ArduinoJoystickLibrary-version-2.0\examples\DrivingControllerTest\DrivingControllerTest.ino:96:13: error: expected unqualified-id before '.' token
     Joystick.begin(false);
             ^
C:\Users\rexim\AppData\Local\Temp\822db133-87a6-41cb-b33e-234bfbeeee2a_ArduinoJoystickLibrary-version-2.0.zip.e2a\ArduinoJoystickLibrary-version-2.0\examples\DrivingControllerTest\DrivingControllerTest.ino: In function 'void loop()':
C:\Users\rexim\AppData\Local\Temp\822db133-87a6-41cb-b33e-234bfbeeee2a_ArduinoJoystickLibrary-version-2.0.zip.e2a\ArduinoJoystickLibrary-version-2.0\examples\DrivingControllerTest\DrivingControllerTest.ino:142:15: error: expected unqualified-id before '.' token
       Joystick.sendState();
               ^

exit status 1

Compilation error: 'Joystick_' does not name a type; did you mean 'Joystick'?

This says your problem might be in your sketch/program, on line 11 (probably the Joystick_ thing). Please post the sketch.

// Program used to test the driving simulator functions on 
// the USB Joystick object on the Arduino Leonardo or 
// Arduino Micro.
//
// Matthew Heironimus
// 2016-05-29   Original version.
//------------------------------------------------------------

#include "Joystick.h"

Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID, 
  JOYSTICK_TYPE_MULTI_AXIS, 4, 0,
  false, false, false, false, false, false,
  false, false, true, true, true);

// Set to true to test "Auto Send" mode or false to test "Manual Send" mode.
//const bool testAutoSendMode = true;
const bool testAutoSendMode = false;

const unsigned long gcCycleDelta = 1000;
const unsigned long gcButtonDelta = 500;
const unsigned long gcAnalogDelta = 25;
unsigned long gNextTime = 0;
unsigned int gCurrentStep = 0;

void testSingleButtonPush(unsigned int button)
{
  if (button > 0)
  {
    Joystick.releaseButton(button - 1);
  }
  if (button < 4)
  {
    Joystick.pressButton(button);
  }
}

void testMultiButtonPush(unsigned int currentStep) 
{
  for (int button = 0; button < 4; button++)
  {
    if ((currentStep == 0) || (currentStep == 2))
    {
      if ((button % 2) == 0)
      {
        Joystick.pressButton(button);
      } else if (currentStep != 2)
      {
        Joystick.releaseButton(button);
      }
    } // if ((currentStep == 0) || (currentStep == 2))
    if ((currentStep == 1) || (currentStep == 2))
    {
      if ((button % 2) != 0)
      {
        Joystick.pressButton(button);
      } else if (currentStep != 2)
      {
        Joystick.releaseButton(button);
      }
    } // if ((currentStep == 1) || (currentStep == 2))
    if (currentStep == 3)
    {
      Joystick.releaseButton(button);
    } // if (currentStep == 3)
  } // for (int button = 0; button < 32; button++)
}

void testAcceleratorBrake(int value)
{
  Joystick.setAccelerator(value);
  Joystick.setBrake(260 - value);
}

void testSteering(int value)
{
  if (value < 300) {
    Joystick.setSteering(value);
  } else {
    Joystick.setSteering(600 - value);
  }
}

void setup() {

  Joystick.setAcceleratorRange(0, 260);
  Joystick.setBrakeRange(0, 260);
  Joystick.setSteeringRange(0, 300);
  
  if (testAutoSendMode)
  {
    Joystick.begin();
  }
  else
  {
    Joystick.begin(false);
  }
  
  pinMode(A0, INPUT_PULLUP);
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {

  // System Disabled
  if (digitalRead(A0) != 0)
  {
    // Turn indicator light off.
    digitalWrite(LED_BUILTIN, 0);
    return;
  }

  // Turn indicator light on.
  digitalWrite(LED_BUILTIN, 1);
  
  if (millis() >= gNextTime)
  {
   
    if (gCurrentStep < 4)
    {
      gNextTime = millis() + gcButtonDelta;
      testSingleButtonPush(gCurrentStep);
    } 
    else if (gCurrentStep < 9)
    {
      gNextTime = millis() + gcButtonDelta;
      testMultiButtonPush(gCurrentStep - 5);
    }
    else if (gCurrentStep < (9 + 260))
    {
      gNextTime = millis() + gcAnalogDelta;
      testAcceleratorBrake(gCurrentStep - 9);
    }
    else if (gCurrentStep < (9 + 260 + 600))
    {
      gNextTime = millis() + gcAnalogDelta;
      testSteering(gCurrentStep - (9 + 260));
    }
    
    if (testAutoSendMode == false)
    {
      Joystick.sendState();
    }
    
    gCurrentStep++;
    if (gCurrentStep >= (9 + 260 + 600))
    {
      gNextTime = millis() + gcCycleDelta;
      gCurrentStep = 0;
    }
  }
}

Where is your Joystick.h file located? The sketch says the file is a "local" within your sketch folder, rather than <system> file in the .\libraries folder.

Have you installed the Joystick library?

If it fails to find it there, the search will pick up where using <> would have started.

a7

i have it installed i got the error to stop but now my computer sees it as a serial port not a game controller

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.