Wireless Joystick Problem

BlitzMax Forums/BlitzMax Programming/Wireless Joystick Problem

Michel R.(Posted 2013) [#1]
[note: I don't know where I can post this topic so it's a copy of the one I've posted in Blitzmax beginners area; sorry for the double post]

Hello,
Well, first of all, I'm French and my english is not very good so excuse me for language errors...

I'm trying to create my first game with Blitzmax and I've a problem with the joystick management. I'm using a XBOX 360 wireless joystick (Microsoft). This joystick needs to be switch on to be seen by the PC before starting my game.
I can then use it in my game without problem; BUT if I don't use it for a while (maybe 1 minute) the joystick automatically switches off (to economise the battery) and at that time my program crashes on the instruction
FlushJoy()

I've tried to replace this line with:

If Joycount() then FlushJoy()

but the problem is the same (with a crash on Joycount())

I didn't see any solution in the forums. Does anyone can help me ?

Thanks in advance


Henri(Posted 2013) [#2]
What kind of crash ? Any details ? Does the testjoy.bmx example work ?

-Henri


Michel R.(Posted 2013) [#3]
To Henri:
There is only a box which says "GnB.Debug.exe a cessé de fonctionner"
I have the same problem in release mode or debug mode.


Michel R.(Posted 2013) [#4]
Oups ! I've forgotten to say the I'm working with Windows 7...


Henri(Posted 2013) [#5]
At first thought it feels like you are accessing some driver related function after Windows joystick device object is deleted. Can you post your joy handling code ?

Ps. Can you turn off this feature directly from driver options ?

-Henri


Derron(Posted 2013) [#6]
As I answered your other thread (you just stated HERE that it is a double post :D).

--- snip

"Joycount()" is directly accessing a function in freejoy.win32/linux.c so there may the fault be created.

FlushJoy is using "for i=0 to JoyCount()" - so "if JoyCount() then FlushJoy" is really useless and will crash too when reaching the JoyCount()-part.

Does it crash on the line
"print JoyCount()"
or only on "If JoyCount() then FlushJoy()"?

Just to get the function call which is not working properly.

--- snip


In another thread here there was a suggestion to leave out "joyCount"-related things from the mainloop as it made some computers stuttering. Long stutters lead to "not working anylonger, should i stop the application?"-events.
So to test just comment "FlushJoy" and "JoyCount" out and test again.
If that helps, you will have to code your own wrapper - this one helds all button states and has a personal reset/flush option. This will circumvent any additional calls to JoyCount.
Just run a JoyCount during startup or some special "detect joypad"-events (you can run them every X seconds to avoid that lagspikes/stuttering).


bye
Ron


Michel R.(Posted 2013) [#7]
Thanks Derron for your answer.

Well, I don't understand but this morning the problem seems to have disappeared...
Perhaps my PC needed to pause a while (or me ?) ;)

I already met this problem a few days ago so I think it will be back soon.
I can't say if my program crashed on JoyCount() or FlushJoy() because Windows shutted down my game and my Blide windows.
I'll try to redo that and i'll post my investigations.
Thanks again

Michel