Force feedback for racing wheels?

Force feedback for racing wheels?

Postby cedric » 14 Apr 2021, 09:19

I have a Microsoft sidewinder force feedback Wheel. This works great, but STK does not have force feedback.

Are there plans to add this to STK? How can I help development?

Cheers,
Cedric
cedric
 
Posts: 8
Joined: 14 Apr 2021, 08:30

Re: Force feedback for racing wheels?

Postby benau » 14 Apr 2021, 19:18

You can only help if you know SDL2 rumble api
Image
benau
STK Moderator
 
Posts: 505
Joined: 08 Dec 2015, 17:32

Re: Force feedback for racing wheels?

Postby cedric » 15 Apr 2021, 06:49

Thanks Beneau, I have gathered some information about the SDL rumble interface from the SDL2 wiki [1]:

The SDL haptic subsystem allows you to control haptic (force feedback) devices. The basic usage is as follows:
1. Initialize the subsystem (SDL_INIT_HAPTIC)
2. Open a haptic device
a. SDL_HapticOpen() to open from index
b. SDL_HapticOpenFromJoystick() to open from an existing joystick
3. Create an effect (SDL_HapticEffect)
4. Upload the effect with SDL_HapticNewEffect()
5. Run the effect with SDL_HapticRunEffect()
6. (optional) Free the effect with SDL_HapticDestroyEffect()
7. Close the haptic device with SDL_HapticClose()

The wiki mentions this blog by Edgar Simo Serra: SDL Haptic In Depth[2]. It uses SDL 1.3, so it may need some changes to work with the current SDL version (2.0.14)

The other half of the solution is to figure out what effects to apply to the steering wheel. I can think of the following events:
- A kart is blown up: a rumble. Maybe it's cool to add a sharp shake of the steering wheel when the kart leaves the ground, and another one when the kart hits the ground again.
- A kart is hit from the side: A sudden force on the wheel. The harder the kart is hit, the more force.
- A kart runs over wooden logs: A low-intensity rumble.

Do we want realistic forces on the wheel during cornering?

[1] https://wiki.libsdl.org/CategoryForceFeedback
[2] https://web.archive.org/web/20130728040 ... dl_haptic/
cedric
 
Posts: 8
Joined: 14 Apr 2021, 08:30

Re: Force feedback for racing wheels?

Postby forum » 15 Apr 2021, 09:46

Hi guys, this sounds really cool! :cool:

As you surely know, there are game controllers with vibration feedback. Could these be supported as well? I assume that there is a difference between a racing wheel with force feedback and a classic game controller with vibration feedback (which is not force feedback), but maybe the latter could be brought to STK as well, so there is at least some "rumble" (e.g. when driving over rough ground or wooden bridges etc.).

I have these controllers with FF and could support you with testing these, if you want and if this is needed/helpful:
EasySMX ESM 9013 Wireless 2.4G Game Controller for PC, Android, TV Box,PS3

Would you consider an option to switch force/vibration feedback on/off? As wireless controllers rely on batteries, some people might be happier not to use their batteries for vibration feedback. I assume that a racing wheel is usually connected via cable, so battery consumption would not be an issue, but maybe there are also some people who would like to have the possibility to switch FF off?
Best regards, 7wells
forum
 
Posts: 176
Joined: 04 May 2020, 12:29

Re: Force feedback for racing wheels?

Postby cedric » 15 Apr 2021, 18:36

Hey 7wells,

As far as I can tell, it's possible to ask the device what rumble / force capabilities it has, and then only use those effects.
SDL_HapticQuery() [1] returns a bitfield. Each bit means that feature is supported. I expect your game controllers with vibration feedback to return a bit field with fewer bits in it than my steering wheel. See SDL_haptic.h [2]
{l Code}: {l Select All Code}
#define SDL_HAPTIC_CONSTANT   (1<<0)
#define SDL_HAPTIC_SINE       (1<<1)
#define SDL_HAPTIC_LEFTRIGHT     (1<<2)
#define SDL_HAPTIC_TRIANGLE   (1<<3)
#define SDL_HAPTIC_SAWTOOTHUP (1<<4)
#define SDL_HAPTIC_SAWTOOTHDOWN (1<<5)
#define SDL_HAPTIC_RAMP       (1<<6)
#define SDL_HAPTIC_SPRING     (1<<7)
 #define SDL_HAPTIC_DAMPER     (1<<8)
#define SDL_HAPTIC_INERTIA    (1<<9)
#define SDL_HAPTIC_FRICTION   (1<<10)
 #define SDL_HAPTIC_CUSTOM     (1<<11)
/* These last few are features the device has, not effects */
#define SDL_HAPTIC_GAIN       (1<<12)
#define SDL_HAPTIC_AUTOCENTER (1<<13)
#define SDL_HAPTIC_STATUS     (1<<14)
#define SDL_HAPTIC_PAUSE      (1<<15)


I agree on your suggestion to give the user the option to switch force/vibration feedback on/off, some people prefer different things than others.

The first challenge is to let STK spit out text on the console when an effect is supposed to be triggered. When that's done, code can be added to initialize the rumble/vibration effects. Finally the printf statements can be converted into SDL_HapticRunEffect() calls. Lastly the gui changes can be added.

Cheers,
Cedric

[1] https://wiki.libsdl.org/SDL_HapticQuery
[2] http://www-personal.umich.edu/~bazald/l ... ource.html
cedric
 
Posts: 8
Joined: 14 Apr 2021, 08:30

Who is online

Users browsing this forum: No registered users and 1 guest