-
Notifications
You must be signed in to change notification settings - Fork 65
Description
Hello
I made a program based on your lib
When i am using WheelCheck arduino gets information about forces and returns them to the serial port
However, when i try to get forces in games, it doesn't see it. it returns 0
Here is my code
`#include "Joystick.h"
Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID,JOYSTICK_TYPE_JOYSTICK,
0, 0,
true, false, false,
false, false, false,
false, false,false, false, false);
Gains mygains[1];
EffectParams myeffectparams[1];
int32_t forces[1];
unsigned long t,lt,dt,lastT; //time part
int x, lx, deltaX, dx,ldx, dx2; //differential part
void setup() {
mygains[0].totalGain = 50; //setting gains
mygains[0].rampGain = 50;
mygains[0].squareGain = 50;
mygains[0].sineGain = 50;
mygains[0].triangleGain = 50;
mygains[0].sawtoothdownGain = 50;
mygains[0].sawtoothupGain = 50;
mygains[0].springGain = 80;
mygains[0].damperGain = 50;
mygains[0].inertiaGain = 50;
mygains[0].frictionGain = 50;
mygains[0].customGain = 50;
Joystick.setGains(mygains);
Joystick.begin();
Joystick.setXAxisRange(-512, 512);
Serial.begin(500000);
lt=millis();
}
void loop() {
lt = t; //time part
t = millis();
dt = t - lt;
if(millis()-lastT>0){
lastT=millis();
lx=x; //last x
ldx=dx; // last x velocity
x=analogRead(A0)-512; //x
deltaX=x-lx;// delta x
dx=deltaX/dt;//x velocity
dx2=(dx-ldx)/dt;//x acceleration
myeffectparams[0].springMaxPosition = 512;
myeffectparams[0].springPosition = x;
myeffectparams[0].damperMaxVelocity = 100;
myeffectparams[0].damperVelocity = dx;
myeffectparams[0].inertiaMaxAcceleration = 5;
myeffectparams[0].inertiaAcceleration = dx2;
myeffectparams[0].frictionMaxPositionChange = 10;
myeffectparams[0].frictionPositionChange = deltaX;
Joystick.setXAxis(x);
Joystick.sendState();
Joystick.setEffectParams(myeffectparams);
Joystick.getForce(forces);
Serial.print(x);
Serial.print(" ");
Serial.println(forces[0]);
}
}`
I think games just don't recognize it as a force feedback device, that can use effects(like spring, friction, ect) because while Wheel check is working, Force Test says "Your joystick may not support this effect" for each effect
Do you know how to fix that?
Thanks in advance