YukMingLaw / ArduinoJoystickWithFFBLibrary

An Arduino Joystick Library With Force Feedback Feature
GNU Lesser General Public License v3.0
208 stars 55 forks source link

Device crashing some games #32

Closed JB2120 closed 2 years ago

JB2120 commented 2 years ago

I used a very basic setup just to test the library and so far have a potentiometer and two buttons set as the steering wheel and two buttons, windows seems to pick it up just fine but when I tried to launch F1 2020 with the Arduino Leonardo plugged in it wouldn't respond at all. So I tried it in Assetto Corsa and that seems to behave fine.

Here's the code I was using:

include

Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID,JOYSTICK_TYPE_JOYSTICK,2,0,false, false,false,false, false, false,false, false,false, false, true);

void setup() { //put your setup code here, to run once: Joystick.setSteeringRange(0,1023); Joystick.begin(); pinMode(A0,INPUT); pinMode(5,INPUT); pinMode(4,INPUT); //Serial.begin(9600); }

void loop() { //put your main code here, to run repeatedly:

Joystick.setSteering(1023-analogRead(A0)); if (digitalRead(5) == HIGH){ Joystick.pressButton(1); } else{ Joystick.releaseButton(1); } if (digitalRead(4) == HIGH){ Joystick.pressButton(0); } else{ Joystick.releaseButton(0); } //Joystick.sendState(); //Serial.print(digitalRead(4)); //Serial.print(digitalRead(5)); //Serial.println(analogRead(A0)); //delay(10); }

If anyone can help me out with this I'd greatly appreciate it.

JB2120 commented 2 years ago

This was solved by including the 'Joystick.getForce(forces);' function, a previous Issue seemed to state it had something to do with the HID identity of the device as being force feedback.