Any alternatives to JoystickFFB library(Force feedback)

Hello everybody! I am making a steering wheel for games. I have made an another topic similar to this one asking how to implement force feedback. I eventually tried using the JoystickFFB library which does ''work'' but, it's really not that good. Whenever I get into a game with standard force feedback settings it's really jittery and shaky. Whenever I try to let it go to center itself it overshoots and then again it tries to center itself and it overshoots again. I have to center it myself which completely destroys the point of force feedback. I determined the cause is that the JoystickFFB library gives a lot higher value than expected. When I rotate the wheel even 90 degrees the value is at 255(the max value) . The wheel rotates 900 degrees. I am pretty sure the JoystickFFB library calculates it wrong. I tried lowering the voltage and the force feedback from the game and yet it is still shaky and jittery. Are there any other ways of extracting and using force feedback data from a game?
Here is my code:

#include <FFBDescriptor.h>
#include <Joystick.h>

#include "Joystick.h"

//X-axis & Y-axis REQUIRED
Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID,
                   JOYSTICK_TYPE_GAMEPAD, //JOYSTICK, GAMEPAD, MULTI_AXIS
                   4, 0,                     //Button Count, Hat Switch Count
                   true, true, true,         //X,Y,Z
                   false, false, false,      //Rx,Ry,Rz
                   false, false, false,      //Rudder,Throttle,Accelerator
                   false, false);            //Brake,Steering

Gains mygains[2];
EffectParams myeffectparams[2];
int32_t forces[2] = {0};

void setup() {
  pinMode(A3, INPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(13, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(12, OUTPUT);
    pinMode(A5, INPUT);
  //Joystick.setXAxisRange(0, 1023);
  //Steering wheel
  Joystick.setXAxisRange(0, 1023);
  Joystick.setYAxisRange(0, 1023);
  //set X Axis gains
  mygains[0].totalGain = 100;//0-100
  mygains[0].springGain = 100;//0-100
  //enable gains REQUIRED
  Joystick.setGains(mygains);
  Joystick.begin();
  Serial.begin(9600);
  digitalWrite(6,HIGH);
  digitalWrite(4,LOW);

analogWrite(9,25);
delay(50);
analogWrite(9,255);
delay(2000);
analogWrite(9,0);
delay(10000);
  digitalWrite(4,LOW);
  digitalWrite(3,HIGH);

  analogWrite(10,25);
delay(50);
analogWrite(10,255);
delay(2000);
analogWrite(10,0);
  digitalWrite(3,LOW);
  digitalWrite(4,LOW);
  digitalWrite(13,HIGH);
  Serial.begin(9600);
  
}

void loop() {
  int value = analogRead(A3);

  //set X Axis Spring Effect Param
  //myeffectparams[0].springMaxPosition = 1023;
  //myeffectparams[0].springPosition = value;//0-1023
  //Steering wheel
  myeffectparams[0].springMaxPosition = 512;
  myeffectparams[0].springPosition = value - 512; //-512-512

  //Send HID data to PC
  //Joystick.setXAxis(value);

  //Recv HID-PID data from PC and caculate forces

  Joystick.setXAxis(value);
  Joystick.setEffectParams(myeffectparams);
  Joystick.getForce(forces);
  if (forces[0] > 0) {
digitalWrite(6, HIGH);
digitalWrite(4,LOW);
  analogWrite(9, abs(forces[0]));

  } else {
digitalWrite(6, LOW);
digitalWrite(4,HIGH);

    analogWrite(9, abs(forces[0]));
  }
  Serial.println(abs(forces[0]));
}

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