Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: Deepstar on March 30, 2017, 09:10:07 am

Title: Joysticks "Auto-Center" does only work for the first mission per session
Post by: Deepstar on March 30, 2017, 09:10:07 am
Hello everybody,

time for a new topic, because i did not found a similar one here.
Actually, i have some problems with my Sidewinder Force Feedback 2 Joystick.

The "Auto-Center" function seems to create some problems for a longer time now. In some builds it works without a problem, in others it were never functional or it looses the function right during a mission (that was very annoying) without any reason.
Recent nightlies create new problems with it on my system as it seems.

If i start the game, everything is alright, the Joystick centers automatically even in the menus and i can play the mission without a problem... and can finish it.
But then the problem appears, in the Debriefing it loses this function and it will never come back until i restart the game.
Actually this appears also, if i press escape or open any menu during the first mission i am playing, including alt-tabbing out of the game.

It seems, that the game transmit the "auto-center"-command only at the start of the game.

I hope somebody can help me and fix this problem :).

I used nightlies from 21st, 26th and the newest 30th march build. I am using the Win32 build, because win64 seems to run only with disabled movie playback on my system.
Title: Re: Joysticks "Auto-Center" does only work for the first mission per session
Post by: m!m on March 30, 2017, 09:15:03 am
What is the "Auto-Center" feature? I have never heard about that.
Title: Re: Joysticks "Auto-Center" does only work for the first mission per session
Post by: Deepstar on March 30, 2017, 09:21:39 am
It centers the joystick automatically.

If you want to turn your ship, you have so also to overcome some resistance.

Some joysticks are using springs for that, but afaik it is more likely for Force Feedback joysticks to use its engine for that. Without it, i can left the Joystick in a position for eternity. If i do not touch my control, my ship could fly circles forever.
Title: Re: Joysticks "Auto-Center" does only work for the first mission per session
Post by: m!m on March 30, 2017, 09:33:40 am
Are you referring to force-feedback effects?
Title: Re: Joysticks "Auto-Center" does only work for the first mission per session
Post by: Deepstar on March 30, 2017, 09:36:13 am
Yes, of course i do :).

But all others force feedback effects working fine, but not this one.
Title: Re: Joysticks "Auto-Center" does only work for the first mission per session
Post by: m!m on March 30, 2017, 10:06:39 am
Ah, ok. Our force feedback code is in pretty rough shape since pretty much no coder has a force feedback device but maybe a debug log may help. Please post your fs2_open.log file.  Instructions on how to do this can be found in this post.
Title: Re: Joysticks "Auto-Center" does only work for the first mission per session
Post by: AdmiralRalwood on March 30, 2017, 10:22:25 am
Ah, ok. Our force feedback code is in pretty rough shape since pretty much no coder has a force feedback device but maybe a debug log may help. Please post your fs2_open.log file.  Instructions on how to do this can be found in this post.
I do, and I'm pretty sure chief1983 does as well. Actually, I've been meaning to see if updating to SDL 2.0.5 would let us get rid of a hack preventing multiple connected force-feedback devices from selecting the correct one, so I can look into other problems at the same time.

EDIT: Actually, a quick look says that the spring effect should last indefinitely, although it... seems to be affected by how fast the player's ship is moving? The player's speed modifies the spring effect's coefficients, which affect how fast the force increases, so if your ship isn't moving... it's possible the spring effect would become unnoticeable? It depends on how the handling scalar works, which isn't entirely clear to me... I can try creating a test build that just removes that effect and you can see if that changes your experience.

Alternatively, maybe experiencing too many haptic effects is making your joystick "forget" the oldest one, which happens to be the spring effect? I always have a centering spring effect enabled globally, outside of the game, so I don't know if my own joystick behaves that way.
Title: Re: Joysticks "Auto-Center" does only work for the first mission per session
Post by: Deepstar on March 30, 2017, 10:53:39 am
Because i do not have any settings that i can change, my Joystick also have this feature enabled even in Windows, outside of the game.

And in the game it is also active... and works how it should. But only until any menu appear... than it does not center anymore.
That is kind of annoying, because i have to restart the game after every mission. Because i can not play without this feature very well, because you get used to this resistance, also you have this in every other flight game, that use Force Feedback.

And in older builds it is working... 3.7.4 is no problem. But that does not use SDL as far as i know.

And no, it does not matter how fast my ship is, the center-effect is completely gone.
Title: Re: Joysticks "Auto-Center" does only work for the first mission per session
Post by: Lykurgos88 on March 30, 2017, 04:43:18 pm
This is my exact problem as well. Those who do not have a Force Feedback joystick don't understand how irritating it can get to fly missions without auto-center.

This problem is definitely SDL2 related. The older 3.7.4 had no problem whatsoever.

My experience is that the auto-center often disappears when something "Force Feedback" -intensive happens or simply during cutscenes (like in JAD 2.22).
Title: Re: Joysticks "Auto-Center" does only work for the first mission per session
Post by: chief1983 on March 31, 2017, 09:44:42 am
There are references to supporting autocenter in the code, and there's SDL auto-center documentation (https://wiki.libsdl.org/SDL_HapticSetAutocenter?highlight=%28%5CbCategoryForceFeedback%5Cb%29%7C%28CategoryEnum%29%7C%28CategoryStruct%29), so maybe this is just something that was accidentally omitted.  We don't seem to be using that function currently.  In the SDL Haptic init function it seems to disable autocenter by default and set gain to max intentionally, so it looks like we may just need to re-enable autocenter after our haptic init call?  Current haptic code (I think) (http://hg.libsdl.org/SDL/file/fd1b8fd3b937/src/haptic/SDL_haptic.c), see SDL_HapticOpen().

I thought we wanted to bump to 2.0.5 to try to fix some other SDL issues as well, specificially with Haptic, before we go to 3.8.  Might be getting a bit close to make that change now though but I'm willing to start testing that upgrade.

Now that I read closer, I'm surprised this works for even one mission if we never call to enable SDL_HapticSetAutocenter() in our own code.
Title: Re: Joysticks "Auto-Center" does only work for the first mission per session
Post by: AdmiralRalwood on March 31, 2017, 01:15:22 pm
Look at the pSpring effect in the force-feedback code.
Title: Re: Joysticks "Auto-Center" does only work for the first mission per session
Post by: chief1983 on March 31, 2017, 01:20:19 pm
I submitted a PR that moves the windows SDL lib to 2.0.5 and reverts the Haptic hack (haven't verified if the detection bug was actually fixed in 2.0.5 yet though, couldn't find the Bugzilla report you mentioned).
Title: Re: Joysticks "Auto-Center" does only work for the first mission per session
Post by: AdmiralRalwood on July 23, 2017, 08:37:58 am
Anyone experiencing this problem: m!m wrote a potential fix and I've uploaded some test builds (http://www.hard-light.net/forums/index.php?topic=93734.msg1851762#msg1851762). Give them a try and see if they work for you.
Title: Re: Joysticks "Auto-Center" does only work for the first mission per session
Post by: jr2 on July 23, 2017, 08:48:24 am
Offtopic:  Can we get a list of coders who would appreciate a force feedback device, and a list of FF devices that would be appropriate to get?  I can't imagine it would be impossible to snag a few used FF devices over time and get them where they need to go.
Title: Re: Joysticks "Auto-Center" does only work for the first mission per session
Post by: Trivial Psychic on July 23, 2017, 12:14:05 pm
I had a FF-enabled joystick a long time ago, and I DID have trouble with the FF dying after a while, but i am certain it was due to overheating, because I remember once I was playing a mission and my brother called up so I had to pause the mission for a while.  When I finished the call and came back to the game, I was able to finish the mission without the FF dying on me.
Title: Re: Joysticks "Auto-Center" does only work for the first mission per session
Post by: taylor on July 26, 2017, 01:05:14 am
I'm not sure of the current state of the code, but the problem may be quite simple. When the haptic effects are created, the spring effect is immediately started. When a mission ends all haptic effects are stopped, also stopping the spring effect, and it doesn't ever get restarted.

So you should just need to either start it in joy_ff_mission_init(), or make sure that it's playing at the end of joy_ff_adjust_handling().

But don't confuse it with the SDL auto-center functionality since that isn't the same thing that the pSpring effect is going for. pSpring isn't auto-center.
Title: Re: Joysticks "Auto-Center" does only work for the first mission per session
Post by: m!m on July 26, 2017, 02:41:18 am
I tried restarting the spring effect when all other effects were stopped but that didn't work for some reason. I noticed that the original code only stopped a few specific effects so I tried porting that code to the SDL equivalent but it hasn't been tested yet.

Here is the PR with the current status: https://github.com/scp-fs2open/fs2open.github.com/pull/1420