Cleric-K / vJoySerialFeeder

Feed Virtual Joystick driver with data from a serial port
GNU General Public License v3.0
258 stars 55 forks source link

the next improvement , middle position stick on disconnect or usb unplug #4

Closed tfoutfou closed 6 years ago

tfoutfou commented 6 years ago

would it be hard to implement a function to center stick (or idealy for the user to choice a value on each channel) on disconnect/connection lost/usb unplug/no data for X sec

i run in the case toonight where a game not seeing center stick was taking some input , but my Transmitter was far away (lazy guy here ;) ) and i could not get it to center without my transmiter.

maybe i could have cut vjoy or do something else but i think it was worth mentioning. it would have been more user friendly if i had nothing to do to fix it however if it is too much work i can live with it.

Aside that i am enJOYing every moment with my wireless transmitter

Cleric-K commented 6 years ago

I did not understand very well what the situation is, why would your receiver lose signal? How far did you move away?

Failsafe values are important for real world situations, because everything is dynamic - the rc model is moving away, hiding behind obstacles and so on. But when using with your pc you are more or less unmoving and very close. I don't see how you can lose signal.

Honestly, I don't see the practical benefit of having failsafe with vjoy (or I don't understand your motivation). When playing simulator, every disconnect/unplug/sig loss should be considered abnormal condition - in that case my least problem is that the sticks are not centered. I should resolve the hardware problem in the first place.

It is, of course, possible to implement such a feature, but I don't think it will be of much use.

Can you explain more precisely what is your use case - why failsafes occur? Are you using your tx for simulators? Or are you trying to command something else from greater distance (some kind of home automation)?

tfoutfou commented 6 years ago

i did not lost signal i purposely turn off my TX , so no failsafe occuration.

I am ok about failsafe , it is kind of useless in the simulator world , a crash is free so ...

The use case was that i play some games (not simulator in particular) with the transmitter as a joystick . Lets say Arma3 when i am in an helicopter for the exemple.

I may be in an helicopter only 2% of the time , or some round dont even require an helicopter. Or maybe sometime i will pilot the helicopter the "old" way with the keyboard. So i turn off transmitter to avoid battery drain , by doing so Vjoy is always sending the last received data to the game , so lets say a stick was not centered , or a button to activate some function was not switched back before putting the transmitter asleep , then the game will act as if the command is beeing send .

Lets say some throttle input , so the result will be that if dont turn the transmitter back on to center the stick , the game will see 2 input , Up from the joystick , and down from my keyboard or mouse , the result is that is mess up the command.

With the same TX but direct usb connection , as soon as i unplug usb , the game didnt see anymore input from the joystick since the pheripheral no longer exist , resulting in not messed up command.

I was just about to write that i kind of found a workaround a few moments ago , setting failsafe to "custom" value in opentx , and the custom values set as center on all channels , then as soon as i turn transmitter off every channel go to middle.

So i think it is becoming a no issue , didnt think about that deep enough

Cleric-K commented 6 years ago

Ok, now I understand much better.

The OpenTX failsafe is very smart idea, I'm glad you figured it out! I am fairly new to RC modelism so I would never thought of this trick :)

So let's consider this solution for the moment. I think it is pretty good and implementing failsafe in vjoyfeeder itself won't bring any additional benefits. Agree?

tfoutfou commented 6 years ago

Agreed , it will be ok for the moment and maybe forever.

The only downside if there must be one , is if you unplug arduino/receiver , you cant center channel value if you have not turned off TX before , but again a fix for that is to launch Vjoy itself and untick "Enable vJoy" at the bottom , "Enable vJoy" can also be used if you dont want to set failsafe or dont have OpenTx as it will be like disconnecting usb joystick (no more peripheral)

Cleric-K commented 6 years ago

I might try to reset all axes and buttons of vjoy upon disconnect. There is only one problem: it seems that C# does a very bad job of detecting usb com port disconnects. Look here.

I'll take a look these days and see what can be done.

tfoutfou commented 6 years ago

so dont use usb detection.

i would use a timer approach , reset timer at every frame , if timer more than 5 sec , then set channel to center , if frame or timer below 5 sec , then go back to normal mode

Just a sugestion , but we can really live without this ;)

Cleric-K commented 6 years ago

Hi, I've uploaded a new release. It supports failsafe settings. You can still use your transmitter's failsafe if you need to. Joysticks are also centered on disconnect. You can check it out.