Shifty Hall sensor based Joystic emulator: error in code?

I am trying to build HALL sensor based magnetic paddle shifter gaming device (Hall sensor is linear which is ON/OFF)

Arduino program Shifty what i try to compile gives error message

/*
  Shifty.ino
  Copyright (c) 2019, Reid Miller
  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <https://www.gnu.org/licenses/>.
*/

//#define DEBUG 1

#include <Joystick.h>
Joystick_ Joystick;

#define SENSOR_COUNT 2
#define NO_BUTTON -1

const int reading_threshold = 90;
const int stale_count_threshold = 85;
const int sensor_pin[SENSOR_COUNT] = {A0, A2};
const int button_map[SENSOR_COUNT] = {0, 2};

int sensor_minimum[SENSOR_COUNT] = {1000, 1000                                  
                                   };
int button_active = NO_BUTTON;
int stale_count = 0;

void setup() {
  int sensor_num;
  for (sensor_num = 0; sensor_num < SENSOR_COUNT; sensor_num++) {
    pinMode(sensor_pin[sensor_num], INPUT);
    sensor_minimum[sensor_num] = analogRead(sensor_pin[sensor_num]);
  }
  Joystick.begin();
#ifdef DEBUG
  Serial.begin(9600);
#endif
}

void loop() {
  int sensor_num;
  int value = 0;
  int flag = 0;
  for (sensor_num = 0; sensor_num < SENSOR_COUNT; sensor_num++) {
    value = analogRead(sensor_pin[sensor_num]);
    if (value < sensor_minimum[sensor_num])
      sensor_minimum[sensor_num] = value;
    value -= sensor_minimum[sensor_num];

    if (value > reading_threshold) {
      flag = 1;
      stale_count = 0;
      if (button_active != NO_BUTTON && button_active != sensor_num) {
        Joystick.setButton(button_map[button_active], LOW);
      }
      Joystick.setButton(button_map[sensor_num], HIGH);
      button_active = sensor_num;
    }

#ifdef DEBUG
    Serial.print(value);
    if (sensor_num < SENSOR_COUNT - 1) {
      Serial.print(" / ");
    } else {
      Serial.println("");
      delay(10);
    }
#endif
  }

  if (!flag)
    stale_count += 1;

  if (stale_count >= stale_count_threshold) {
    Joystick.setButton(button_map[button_active], LOW);
    stale_count = 0;
  }


}

I get this error message. What i can understand is that
Joystick_ Joystick; dont have any type or reference and that is reason why there is error? Also i think i can see some other errors also? I have installed via Arduino IDE Joystick library so it should be there correct.

shifty.ino:19:1: error: ‘Joystick_’ does not name a type; did you mean ‘Joystick’?

Joystick_ Joystick;

^~~~~~~~~

Joystick

C:\Users\samvi\Documents\Arduino\shifty.ino\shifty.ino.ino: In function ‘void setup()’:

shifty.ino:40:11: error: expected unqualified-id before ‘.’ token

Joystick.begin();

^

C:\Users\samvi\Documents\Arduino\shifty.ino\shifty.ino.ino: In function ‘void loop()’:

shifty.ino:60:17: error: expected unqualified-id before ‘.’ token

Joystick.setButton(button_map[button_active], LOW);

^

shifty.ino:62:15: error: expected unqualified-id before ‘.’ token

Joystick.setButton(button_map[sensor_num], HIGH);

^

shifty.ino:81:13: error: expected unqualified-id before ‘.’ token

Joystick.setButton(button_map[button_active], LOW);

^

Multiple libraries were found for “Joystick.h”
Käytetty: C:\Users\samvi\Documents\Arduino\libraries\Joystick
Ei käytössä: C:\Users\samvi\Documents\Arduino\libraries\AxisJoystick
exit status 1
‘Joystick_’ does not name a type; did you mean ‘Joystick’?

Joystick_ should be Joystick.

The constructor for Joystick requires 3 arguments.

Joystick(int pinX, int pinY, int pinZ)

Perhaps you are using the wrong joystick library? The one from the IDE does not have setButton as a method.

I think it has something to do with me not having correct card?

I have this card:
Pro Micro ATmega32U4 5V 16MHz Replace ATmega328 Arduino Pro Mini IT

But it seems that also other Arduino sketches which uses Joystic.h library dont compile (not possible to set Joystic) Is it so that card is not correct model? What is Arduino Pro Micro model which is possible to use Joystic library?

samviljan:
I think it has something to do with me not having correct card?

I have this card:
Pro Micro ATmega32U4 5V 16MHz Replace ATmega328 Arduino Pro Mini IT

But it seems that also other Arduino sketches which uses Joystic.h library dont compile (not possible to set Joystic) Is it so that card is not correct model? What is Arduino Pro Micro model which is possible to use Joystic library?

From a simple Google search it looks like the library you are wanting is 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.

You may need to install that library. I haven’t used a joystick I just know you are not using the library your code is written for.

ToddL1962:
From a simple Google search it looks like the library you are wanting is 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.

You may need to install that library. I haven't used a joystick I just know you are not using the library your code is written for.

Yes you are correct. Original sketch writer responded that he had wrong library in his post.

But Google search maybe was easy for you if you know what to search :slight_smile: For me i spend some time trying to find explanation without success :slight_smile:

But when i installed manually correct Joystic library (one you referred) it worked!