Strange JoyX and JoyY results..

BlitzMax Forums/BlitzMax Programming/Strange JoyX and JoyY results..

Docster(Posted 2009) [#1]
Hello ppl!

Today I bought a gamepad (dual action) for my PC. And I was playing arround with the Joystick commands in BlitzMax. BlitzMax documentation says:

JoyX: Zero if the joystick is centered, -1 if Left, 1 if Right or a value inbetween.

JoyY: Zero if the joystick is centered, -1.0 if Up, 1.0 if Down or a value inbetween.

I get these results:

When centered:
JoyX results in: -1.5xxxxxE-xxx
JoyY results in: -1.5xxxxxE-xxx

Moving up:

JoyY results halts on -0.99, will never be -1.

Anyone else that has the same problem? Please help. :)

PS! I'm using the latest version of BlitzMax.

Best regards,
Docster


jkrankie(Posted 2009) [#2]
i don't know if this is the right answer, but some joystick return values greater than 1 or less than minus 1, try dividing the number it returns by 128 or 256 (or some other power of 2) and see if that helps.

Quite often this sort of thing is down to the joystick driver, maybe if you installed the diver that came on the CD with the joystick you could try uninstalling it and using a generic windows one instead?

Cheers
Charlie


Floyd(Posted 2009) [#3]
The values are floating point, hence approximate.

Where the docs say the values will be -1, 0, +1 they will actually be very close but not necessarily equal.


GfK(Posted 2009) [#4]
When centered:
JoyX results in: -1.5xxxxxE-xxx
JoyY results in: -1.5xxxxxE-xxx
Those are actually miniscule numbers. Don't rely on 'dead centre' ever being exactly 0. Treat anything less than 0.01 as 0 and you'll be fine.

All of this is perfectly normal.


*(Posted 2009) [#5]
All things need a dead zone as gfk said normally -.01 to .01 you may have to play with the value as it depends on the joystick/mouse's calibration.


ziggy(Posted 2009) [#6]
A good aproach is to multiply the result per 100 and store it inside a int. then you'll get -100 to 100 values, with real zeros. less acurate but with a scale of 201 values is usually enought for games (-100 to 100).


Sokurah(Posted 2009) [#7]
I had this problem with my joypad when I made my last game (but for some reason I didn't have the same problem on any of my earlier games).

I ended up with reading in the values of the X & Y axes into a variable at the start of the program, and then instead of going;

If JoyX>0 then something

I do this instead;

If JoyX>BaseValueX then something

It's simple but it works. :-)


Docster(Posted 2009) [#8]
Thanks for all help. I think I can manage to get this thing working after all these good suggestions. :)

Doc