Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

possible code source for friction / inertia effects ? #57

Closed
SynthetikzZ opened this issue Dec 27, 2023 · 46 comments
Closed

possible code source for friction / inertia effects ? #57

SynthetikzZ opened this issue Dec 27, 2023 · 46 comments

Comments

@SynthetikzZ
Copy link

SynthetikzZ commented Dec 27, 2023

so i kept thinking how you could implement it correctly and then i stumbled upon openffbboard. i used it prevously (2-3 years ago) with a motor from one of these hoverboards :D. it has its own opensource software so i started searching the code and found a hint


#define FFB_EFFECT_CONSTANT     0x01
#define FFB_EFFECT_RAMP         0x02
#define FFB_EFFECT_SQUARE       0x03
#define FFB_EFFECT_SINE         0x04
#define FFB_EFFECT_TRIANGLE     0x05
#define FFB_EFFECT_SAWTOOTHUP   0x06
#define FFB_EFFECT_SAWTOOTHDOWN 0x07
#define FFB_EFFECT_SPRING       0x08
#define FFB_EFFECT_DAMPER       0x09
#define FFB_EFFECT_INERTIA      0x0A
#define FFB_EFFECT_FRICTION     0x0B
#define FFB_EFFECT_CUSTOM       0x0C
 

here is the link to the file i found that https://ultrawipf.github.io/OpenFFBoard/doxygen/ffb__defs_8h_source.html

my programming skills are non existent so i dont know what im searching exactly for but maybe thats a good source for you ?

https://github.com/Ultrawipf/OpenFFBoard

@gotzl
Copy link
Owner

gotzl commented Dec 27, 2023

Interesting peace of code, but it doesn't help much, unfortunately. While the idea is similar, the protocol how to communicate with the device (eg the command codes you've posted) is vendor specific.

There are only 2 ways to find out the Fanatec protocol:
a) they provide a specification for it
b) by reverse engineering (using USB-trafffic dumps of known input).

Since a) is not likely to happen, we're stuck with b).. So I think what we need is a game using FF_FRICTION and another one using FF_INERTIA and a Windows user that is willing to create some USB-traffic dumps ....
For one of these, EA Sports WRC could be used for example.

@SynthetikzZ
Copy link
Author

SynthetikzZ commented Dec 28, 2023

In the next couple of days I will setup a windows machine ( have some parts laying around for a second PC) and install windows, i will dump all the USB traffic for you

There has to be some sort of documentation for you with what I did with the wheel for any given time right?

@ciscoyo
Copy link

ciscoyo commented Dec 28, 2023

oh god, u r our damn saviour for real! with these datas, we can complete this driver.. i can almost see light at the end of the tunnel ;D

@gotzl
Copy link
Owner

gotzl commented Dec 29, 2023

In the next couple of days I will setup a windows machine ( have some parts laying around for a second PC) and install windows, i will dump all the USB traffic for you

There has to be some sort of documentation for you with what I did with the wheel for any given time right?

This would be great! Not much docu is needed for this. Just playing the game for a few seconds should be enough. Then one can filter the data for unknown command codes.

@SynthetikzZ
Copy link
Author

SynthetikzZ commented Jan 1, 2024

Is EA sports WRC the only game you know with the effects? Have everything setup to dump the traffic but honestly don't want to buy the game at its current price and also not because it's ea :D do you know some older games maybe?

@gotzl
Copy link
Owner

gotzl commented Jan 2, 2024

@SynthetikzZ Up to now, besides WRC I only found Dirt Rally 2 that requires FF_FRICTION. Do you have that?
I did not find a game utilizing FF_INERATIA yet ...

@SynthetikzZ
Copy link
Author

Yes I have it in my steam library. I will do a dump as soon as I am at home again( im at work right now).

Do you need other dumps out of the fanatec driver itself? (Wheel centering/calibration or whatever ?)

I can provide the dumps as pcap or as JSON what do you prefer?

@gotzl
Copy link
Owner

gotzl commented Jan 2, 2024

Great! Other than the game, what I would be interested in is the 'initialization' sequence. So, a capture of the traffic when powering on the device. (Make sure that fanatec tray app is not running, and also no other fanatec app is open at that time). And then a dump of the traffic when opening the fanatec controller settings app.

I can provide the dumps as pcap or as JSON what do you prefer?

I'd prefer pcap. Thank you!

Btw, which wheel-rim do you have?

@SynthetikzZ
Copy link
Author

CSL DD wheelbase with the CSL P1 v2 wheelrim.

I'll do the dumps later :)

@SynthetikzZ
Copy link
Author

https://github.com/SynthetikzZ/fanatec_usb_dump

you can find the files there

if you need something else just ask. and thank you for your work

@gotzl
Copy link
Owner

gotzl commented Jan 3, 2024

Thanks! But the DirtRally2 file lacks content... The other files look fine, though. Could you redo DR2?

@SynthetikzZ
Copy link
Author

SynthetikzZ commented Jan 3, 2024

tought it so, dr2 had very light ffb for me (barely noticible but it was there). seems to be a problem of the game as its a problem a lot of people have :D

have to resolve it first then or have to find another game :D

@gotzl
Copy link
Owner

gotzl commented Jan 3, 2024

Hmm... Maybe try editing DiRT Rally 2.0/input/devices/device_defines.xml file? Try this for example (adapted from WRC)

<device id="{00200EB7-0000-0000-0000-504944564944}" name="ftec_base_ddcsl" priority="100" type="wheel"/>

Or try it in compatibility mode.

@SynthetikzZ
Copy link
Author

SynthetikzZ commented Jan 3, 2024

i just did some other things and had good ffb strength going on from the tarmac etc. i just uploaded a new dump could you check?

the ffb problems are definitly related to the game a lot of people have issues on a lot of wheelbases

@SynthetikzZ
Copy link
Author

SynthetikzZ commented Jan 3, 2024

added a dump in csw mode.. definitly csw gave me the best ffb in the game now and in csw mode leds and display are working

@gotzl
Copy link
Owner

gotzl commented Jan 3, 2024

Thanks! Had a brief look into the data, but sadly couldn't identify where the FF_FRICTION is set ... Have to think about that...

Just for reference, here the little snippet I've hacked together to get the cmd-codes used in a capture file

import pcapng  # pip install python-pcapng --user
cmds = set()
with open('/tmp/dirtrally2_dump2.pcapng', 'rb') as fp:
    scanner = pcapng.FileScanner(fp)
    for i, block in enumerate(scanner):
        if not isinstance(block, pcapng.blocks.EnhancedPacket): continue
        if block.packet_data[16] != 0x0: continue  # direction
        if block.packet_data[21] != 0x1: continue  # endpoint
        hid_data = block.packet_data[27:]
        # not interested in cmds for display or leds, skip over
        if hid_data[1] == 0xf8 and hid_data[2] in [0x09, 0x13]:
            continue
        cmd = hid_data[2]
        cmds.add(cmd)
list(map(hex,cmds))

This outputs ['0x8', '0xb', '0xc'], which are the cmd-codes for (at least by current knowledge) FF_CONSTANT, FF_SPRING, FF_DAMPER.

@SynthetikzZ
Copy link
Author

did you tried the csw dump instead? ffb felt alot better there.

@ciscoyo
Copy link

ciscoyo commented Jan 4, 2024

In the next couple of days I will setup a windows machine ( have some parts laying around for a second PC) and install windows, i will dump all the USB traffic for you
There has to be some sort of documentation for you with what I did with the wheel for any given time right?

This would be great! Not much docu is needed for this. Just playing the game for a few seconds should be enough. Then one can filter the data for unknown command codes.

im not sure how this all work, but i think u have to trigger these eventcodes, no?
like u have to perform a full lockup, a understeer situation(driving to fast into a corner and just sliding straight/car not turning) and a oversteer situation(heck of the car come around/spin that car).
if u dont do this, needed evencodes will not be triggerd, the game will not send these datas, right?

@gotzl
Copy link
Owner

gotzl commented Jan 4, 2024

did you tried the csw dump instead? ffb felt alot better there.

The csw dump looks similar. Strange that the FFB felt different. Did you use the same setting in tuning-menu and in-game?
Another question, when did you start the capture? Could you start the capture before starting the game?

im not sure how this all work, but i think u have to trigger these eventcodes, no?

Yes, you have to 'trigger' them. But what I saw in Dirt Rally 2 (proton) was, that it sends FF_FRICTION already at a standstill at the beginning of the stage...

@SynthetikzZ
Copy link
Author

Yes same settings, csw mode feels thousand times nicer compared to PC mode, also display and LEDs working in csw mode, not in PC mode.

I started the dump while already in-game, later today I'll do a complete dump from wheelbase initialization to in-game driving.

@dinuxlt
Copy link

dinuxlt commented Jan 4, 2024

(maybe this issue should be open? it's closed now)

Hi @gotzl I have suggestion here.

I have windows application, the title says iRacing Force Feedback Test 1.72 WheelCheck.exe downloaded from this link https://www.racedepartment.com/downloads/lut-generator-for-ac.9740/

I have windows only in VirtualBox. Connected my CSL Elite to linux box and forwarded my wheel to windows VM. Installed all drivers and this application sees my wheel. I can enable effect, for example Simple Spring and I get this on wheel.

There is Damping Force list: Damper, Inertia, Friction

image

Maybe this is possibility to use this application, change effects and monitor whats happens on USB port ?

image

WARNING !!! in some off these effects, wheel goes crazy

@gotzl
Copy link
Owner

gotzl commented Jan 4, 2024

@dinuxlt Hey there! Yes, I've this tool as well and using it in qemu is exactly what I did to find out the other effects. Strange thing here is, that choosing Damper/Inertia/Friction all result in the same op-code... (and I also believe that the wheel didn't feel differently...)

@gotzl
Copy link
Owner

gotzl commented Jan 4, 2024

Yes same settings, csw mode feels thousand times nicer compared to PC mode, also display and LEDs working in csw mode, not in PC mode.

I started the dump while already in-game, later today I'll do a complete dump from wheelbase initialization to in-game driving.

Just fired up DR2 (proton) again. What I see is that the game already sends FF_FRICTION just after the stage got loaded. So even before choosing 'Start' and sitting in the car. So I would also be interested in a capture of only the loading screen + some seconds in the menu before the stage.

I'm beginning to think that there are really are no op-codes for friction/inertia, and the fanatec driver somehow 'corrects' the applied forces to generate these effects...

@gotzl
Copy link
Owner

gotzl commented Jan 4, 2024

@dinuxlt Hey there! Yes, I've this tool as well and using it in qemu is exactly what I did to find out the other effects. Strange thing here is, that choosing Damper/Inertia/Friction all result in the same op-code... (and I also believe that the wheel didn't feel differently...)

yea, im testing right now.. so for me ndp / damper and nfr / friction feels completely the same now.. it wasnt before the update though. before update, the behavior was better, or lets say it WAS how it should feel! but not anymore. nin / inertia is fine.

Which update do you mean?

To my understanding, NDP/NFR/NIN are sort of base effects that are applied by the wheel / to the wheel directly, independent of the information coming from games. That's why they are called 'Natural ...'. You can change these values w/o a game running and you'll feel the difference. So the driver shouldn't have an influence on how these settings feel.

@ciscoyo
Copy link

ciscoyo commented Jan 4, 2024

ah no, its not true what i said. dont mind it, its all good ^^ i should have tested more, sry.

To my understanding, NDP/NFR/NIN are sort of base effects that are applied by the wheel / to the wheel directly, independent of the information coming from games. That's why they are called 'Natural ...'. You can change these values w/o a game running and you'll feel the difference. So the driver shouldn't have an influence on how these settings feel.

ye, i think so too. but i doubt that they r connected with the ff_friction eventcode only. ff_friction can be send with other eventcodes, to create a specific ffb ouput, a sliding tire for example. they just use different values for effect strength.

Strange thing here is, that choosing Damper/Inertia/Friction all result in the same op-code... (and I also believe that the wheel didn't feel differently...)

i dont think that the driver is allowed to change that, only the output strength. this code can only be changed, with the firmware inside the wheelbase itself. i also could easily imagine, that the command output will look very similar. it will just have a different name ^^
i mean your drivers ffb output on these effects r how they should be and im pretty sure that they r the same as on windows.

@ciscoyo
Copy link

ciscoyo commented Jan 13, 2024

im not sure how this all work, but i think u have to trigger these eventcodes, no?
like u have to perform a full lockup, a understeer situation(driving to fast into a corner and just sliding straight/car not turning) and a oversteer situation(heck of the car come around/spin that car).
if u dont do this, needed evencodes will not be triggerd, the game will not send these datas, right?

Yes, you have to 'trigger' them. But what I saw in Dirt Rally 2 (proton) was, that it sends FF_FRICTION already at a standstill at the beginning of the stage...

ye, but with more "triggers" in diff situations, u might get other outputs. u can compare them, see whats different. u can better learn/understand, how the eventcodes actually work, even when there is no diff, right? ^^
so i was mainly referring to SynthetikzZ ^^

@SynthetikzZ can i suggest u to do a record run in raceroom? i know u dont like it, but its f2p and its a quick 20gb (i think) download anyway ^^ just a one lapper on the raceway bridge with the hillclimb for example. than u can enjoy the power and sound from that car as well ;)

@melroy89
Copy link
Contributor

@SynthetikzZ Up to now, besides WRC I only found Dirt Rally 2 that requires FF_FRICTION. Do you have that? I did not find a game utilizing FF_INERATIA yet ...

I'm also willing to dump USB packages if you wish. I also have a Windows machine running to the right of me, that have the official Fanatac software running.

I believe that Natural Friction is used in Asseta Corsa as well. But I could be wrong. I do notice quite some oscillation in Asseta Corsa with this Linux driver, I hope that natural friction (NFR) can help to prevent oscillation. Or like you said maybe it's just there in the firmware (or the Fanatec Windows software) that deals with this, instead of the game itself.

@SynthetikzZ
Copy link
Author

SynthetikzZ commented Jan 16, 2024

Pretty sure that the natural ff effects are all independent from the game you are playing. For AC I highly recommend gyroscopic ffb effects activated in content manager. This will handle oscillatioms really well without making the ffb effects dull because of friction.

Sorry @ gotzl for not updating the dumps. Something happened in Reallife, I wasn't at home since then . Tomorrow I can do the dumps you asked for.

@ciscoyo
Copy link

ciscoyo commented Jan 16, 2024

yes, give all the datas u want to give! the more, the better :)

  • just make sure, to do a quick summary on what u did. for example; doin initial/power one wheel/base + initializing; doin a lap on f1 23; raising and lowering specific effect; etc.
  • what wheel/base/pedals/shifter u use, coz some have more features and use more/other eventcodes than others. for example: leds; load cell; different wheelbases; etc.
  • what mode u used. pc/red or xbox/yellow
  • its not relevant in all cases, but just in case, activate all effects on the wheel/base AND ingame as well. like dont have them on zero("0") or "off"

and on the other hand, gotzl/coders do good so far, to let us know, were they stuck ^^
so we can research/test and provide infos ourself (and dont feel so useless ;o). even the dumbest thingy, can sometimes lead to a/n answer/enlightenment/solution ^^

i also wanna add, its all voluntary. take all the time u need. no one needs to apologise. irl is always more important!
and gotzl is away anyway. its non parent adult vacation/ski time after all ^^ so dont worry synthetikzz, hope u good!

@melroy89
Copy link
Contributor

melroy89 commented Jan 16, 2024

Should we just create a new issue for implementing friction / inertia? And do not close that ticket, until some version of friction/inertia is implemented?

@ciscoyo
Copy link

ciscoyo commented Jan 17, 2024

Should we just create a new issue for implementing friction / inertia? And do not close that ticket, until some version of friction/inertia is implemented?

we have #47 this thread for it. but i think we have all eventcodes in this driver now. just need a confirmation. than i will close this.
next step is to optimise/correct these eventcodes, coz not all work correct by now.
i think it would be best, just to create a single ticket with a specific issue in a game every time, instead a general thread.. coz new ppl dont read everything and just create new issues anyway, so its hard to keep it like overseeable/clean/neat. all the up to date/good infos r spread around diff. threads lately.. so its understandable that new ppl r confused a lot xD
but i would suggest to open this thread again and change titel to "windows dumb files(for natural effects)" or something like that for now.. but dosent really matter, coz all relevant ppl read everything anyway :D

@gotzl
Copy link
Owner

gotzl commented Jan 19, 2024

@melroy89 thanks for offering to test with windows as well

I've recently found ForceTest, but it doesn't work in qemu for whatever reason. It does work with wine, though. So, @melroy89 @SynthetikzZ, what I would be interested in is

  • usb-dump when enabling the friction effect (using windows)
  • qualitative comparison of how the wheel feels in windows vs wine/linux when setting friction/damping

@SynthetikzZ
Copy link
Author

SynthetikzZ commented Jan 19, 2024

Enumerated Joystick : FANATEC Wheel
Enumerated Joystick : FANATEC Wheel
Supported Effects : 
   - Constant
   - Ramp Force
   - Square Wave
   - Sine Wave
   - Triangle Wave
   - Sawtooth Up Wave
   - Sawtooth Down Wave
   - Spring
   - Damper
   - Inertia
   - Friction
   - CustomForce

Creating effects for FANATEC Wheel
Error creating Spring Effect. Your joystick may not support this effect.  : 
E_INVALIDARG : 
An invalid parameter was passed to the returning function
Error creating Friction Effect. Your joystick may not support this effect.  : 
E_INVALIDARG : 
An invalid parameter was passed to the returning function
Error creating Damper Effect. Your joystick may not support this effect.  : 
E_INVALIDARG : 
An invalid parameter was passed to the returning function
Error creating Constant Force Effect. Your joystick may not support this effect.  : 
E_INVALIDARG : 
An invalid parameter was passed to the returning function
Error creating Periodic Effect. Your joystick may not support this effect.  : 
E_INVALIDARG : 
An invalid parameter was passed to the returning function
Error creating Pavement Groove Effect. Your joystick may not support this effect.  : 
E_INVALIDARG : 
An invalid parameter was passed to the returning function

not working for me.. throws me this in its diagnosticswindow

@SynthetikzZ
Copy link
Author

https://github.com/SynthetikzZ/fanatec_usb_dump/blob/main/dirtrally_bootup_to_racestart_menu.pcapng

added the dump for the usbtraffic before the racemenu.. defenitly some commnunication happening just before it loads up.

@gotzl
Copy link
Owner

gotzl commented Jan 20, 2024

Enumerated Joystick : FANATEC Wheel
Enumerated Joystick : FANATEC Wheel
Supported Effects : 
   - Constant
   - Ramp Force
   - Square Wave
   - Sine Wave
   - Triangle Wave
   - Sawtooth Up Wave
   - Sawtooth Down Wave
   - Spring
   - Damper
   - Inertia
   - Friction
   - CustomForce

Creating effects for FANATEC Wheel
Error creating Spring Effect. Your joystick may not support this effect.  : 
E_INVALIDARG : 
An invalid parameter was passed to the returning function
Error creating Friction Effect. Your joystick may not support this effect.  : 
E_INVALIDARG : 
An invalid parameter was passed to the returning function
Error creating Damper Effect. Your joystick may not support this effect.  : 
E_INVALIDARG : 
An invalid parameter was passed to the returning function
Error creating Constant Force Effect. Your joystick may not support this effect.  : 
E_INVALIDARG : 
An invalid parameter was passed to the returning function
Error creating Periodic Effect. Your joystick may not support this effect.  : 
E_INVALIDARG : 
An invalid parameter was passed to the returning function
Error creating Pavement Groove Effect. Your joystick may not support this effect.  : 
E_INVALIDARG : 
An invalid parameter was passed to the returning function

not working for me.. throws me this in its diagnosticswindow

Oh, looks similar to what I got in qemu... Then it seems this prog just doesn't like windows....

@SynthetikzZ
Copy link
Author

It was win 11 tho maybe I can try it in compability mode or maybe it works for win 7. I will have a look into it as soon as I have spare time for it.

@melroy89
Copy link
Contributor

To be honest this forcetest. exe is also 6 years old. Moreover, the same log output (logfile.txt) was submitted to the repo: https://github.com/denisn73/JoyFFB/blob/cb8fd82d052a8348af35eea3b370def19f93e85e/logfile.txt#L31

@melroy89
Copy link
Contributor

melroy89 commented Jan 20, 2024

Ps. I also tried this ForceTest.exe same results as you're seeing. I tried compatibility mode Windows 7 and even Windows XP. No luck. I also tried running as admin. Also no luck.
I bet the binary is compiled with a too old .NET maybe?

Anyhow, I have everything up and running under Windows (I have the drivers installed already, I have AC running, I have recently now installed Device Monitoring Studio Ultimate as well). What is next?:

image_2024-01-20_20-19-13
image_2024-01-20_20-19-56

@gotzl
Copy link
Owner

gotzl commented Jan 30, 2024

What is next?

In terms of the FF_FRICTION/FF_INERTIA, I actually don't know. The most recent dumps don't contain more information, unfortunately. And I would say that with the current code, DR2 should produce similar USB traffic/cmds in Linux vs Windows... But does it feel similar?

Another topic would be to create USB traffic dumps for FW upgrades for various parts, especially the base. Not sure if FW update will ever be supported in Linux, but having the dumps surly doesn't hurt...

@melroy89
Copy link
Contributor

melroy89 commented Jan 30, 2024

In terms of the FF_FRICTION/FF_INERTIA, I actually don't know. The most recent dumps don't contain more information, unfortunately. And I would say that with the current code, DR2 should produce similar USB traffic/cmds in Linux vs Windows... But does it feel similar?

Not sure about DR2, but under AC (assetto corsa) I do feel a big difference in friction / inertia under Windows vs Linux. It doesn't oscillate as much under Windows (under Linux my steer under AC, if I let it go, goes from left to right, to left to right very intense and fast). Also I noticed the steering wheel is going back to enter again when you drive in a straight line and leave your hands off the wheel, just like a real car.

In terms of USB dumps, I think it's basically the same kind of USB packages. Maybe that is why you do not really see a difference?

Getting USB traffic dumps during a firmware upgrade would be nice indeed.

@gotzl
Copy link
Owner

gotzl commented Jan 30, 2024

Hmm... I don't think I have this oscillation in AC. I'll check later.

In terms of USB dumps, I think it's basically the same kind of USB packages. Maybe that is why you do not really see a difference?

What do you mean by that? I wanted to say, that the commands that are send to the wheel look similar in Linux and Windows. So in terms of the fanatec-usb-protocol, I don't see a difference...

@melroy89
Copy link
Contributor

What do you mean by that?

Maybe you expected different kind of USB packages for friction and/or inertia...

@gotzl
Copy link
Owner

gotzl commented Jan 30, 2024

What do you mean by that?

Maybe you expected different kind of USB packages for friction and/or inertia...

Yes, I expect different packages for damper/friction/inertia, but what the windows dumps show so far is that they are not different. That's what's puzzling...

@melroy89
Copy link
Contributor

melroy89 commented Jan 30, 2024

I think it's just the same kind of USB packages, but let's say the racing game force feedback says rotate the wheel 20 degrees, with inertia and friction algorithms within the driver it will only rotate 10 degrees for example and reduce the torque or visa versa.

Just thinking out loud here... Not sure if this is how the driver is working under Windows.

@gotzl
Copy link
Owner

gotzl commented Jan 30, 2024

Ah, yes, I was thinking in this direction too ... Maybe have to give it a shot ...

@gotzl
Copy link
Owner

gotzl commented Feb 23, 2024

Does s.o. own F1 2X and is willing to capture windows usb-traffic for it? There are still some doubts about the effects these games use ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants