Joyhat -1 or 0?

BlitzMax Forums/BlitzMax Beginners Area/Joyhat -1 or 0?

Idiot(Posted 2006) [#1]
I have two controllers I'm testing a game with. One is a classic Sega Genesis controller, the other is a Nyko AirFlo. The Genesis controller has no joyhat, and when I check what the joyhat value is, it reports zero.

The AirFlo controller uses its d-pad as a joyhat and reports -1 if it is not being used, and 0 when up is pressed on the pad.

Obviously this is creating some problems for me. How can I detect if the stick has a joyhat? I see there are functions for JoyAxisCaps and JoyButtonCaps, but I don't know if/how these releate to the joyhat.


Yan(Posted 2006) [#2]
Have a look here and here.


Idiot(Posted 2006) [#3]
That's not answering my question, Ian. The problem is my other controller reports the joyhat as being at position 0, not -1. I believe this is because it has no joyhat.

"Reports the position of the joystick's HAT/POV controller if supported." if it isn't supported, it's returning a zero? How can I tell if it's supported, or if the user is just pressing up on it?

Here's the button caps and axis caps for the two controllers I have.

This is the airflo:
I believe it has 13 buttons, two analog sticks and a d-pad (joyhat)

stick 0 button caps:00000000000000000001111111111111
stick 0 axis caps:00000000000000000000001000001111

This is the genesis controller:
It has a d-pad that reports as joyX/joyY and as buttons, and 7 actual buttons, for a total of 11 buttons.

stick 1 button caps:00000000000000001111111111111111
stick 1 axis caps:00000000000000000000000000000011


Yan(Posted 2006) [#4]
That's not answering my question, Ian.
It is, you're just not looking. ;o)

Did you run, or look at, the example code?

I'll give you a hint...
If JoyAxisCaps(joySelected) & (1 Shl JOY_HAT) then Print "Woohoo, a JoyHat!"

:o)

[edit]
I don't really understand why Skid didn't just define the FreeJoy constants as bitmasks in the first place. We could of just used...
If JoyAxisCaps(joySelected) & JOY_HAT
...etc
[/edit]


Idiot(Posted 2006) [#5]
Did you edit your post? ;) I didn't see the first link. I think this is what I need, thanks!


Yan(Posted 2006) [#6]
Yeah, I was in mid edit when you posted. ;o)

The information you needed was in the original link, it was just hidden a bit in the example code. :o)


Idiot(Posted 2006) [#7]
Got it... but now MORE PROBLEMS!

On the Mac, the hat is all screwy. Not hitting it *is* zero, all the numbers are shifted and when you get to up+left, it returns -1 !

Is this a bug? X(


Yan(Posted 2006) [#8]
It certainly doesn't seem too clever. ;o)


Hotcakes(Posted 2006) [#9]
Probably a difference in the Windows drivers vs the Mac drivers for joysticks (or possibly a BRL mistake). If you want code that can handle all platforms using the same code, you'll probably have to write a 'callibration' system which stores the values returned for up/down/whatever and translates in between values on the fly.