Has anyone configured the digital “hatswitch” (the little joystick found at the top of many joysticks) in Unity? I tried configuring it as an analog device, but it went nutz. Now I’m trying to configure it as a button, but I’m not getting any response. Can anyone offer any suggestions?
Attached is a screen shot of the input manager settings I’m trying. You’ll notice that I’m using different settings for “vertical” vs. “horizontal”, but neither is working.
I’m using this code to test it:
print ("H: " + (Input.GetAxis ("TophatHorizontal")) + " V: " + (Input.GetAxis ("TophatVertical")) );
What happens is it appears to work for the first click or two, then it just “freezes” at a value of 1. Any ideas? Am I doing this right and is this a bug?
Still experimenting, but it doesn’t seem to be working. I tried this code:
// test joystick
var topHor = Input.GetAxis ("TophatHorizontal");
var topVer = Input.GetAxis ("TophatVertical");
print ("H: " + topHor + " V: " + topVer );
topHor = 0;
topVer = 0;
And the joystick seems to be "sticking. As before, it seems to work for a couple clicks, then stops working with the values at -1 or +1. This code should force the value to 0, but it’s not working. Has anyone used the “tophat” on a joystick with Unity? I’m wondering if maybe my joystick is broken… :shock:
For testing, why don’t you set up some axes and then build a standalone, and see if you can assign the hat from the setup dialog.
My guess (from other games) is that the hat may be treated as 4 separate on/off buttons.
The gravity and sensitivity and dead values for horizontal axis are setup a little insane. Maybe just make them match the Vertical ones, they seem fine.
Tried this, and still get the same results. The buttons seem to work for 2 or 3 clicks then “freezes”.
Good idea. I tried this with a standalone I already created and nothing happens when I move/click the tophat.
Has anyone actually tested the tophat with a Unity project on a Mac? If someone can confirm that it actually works, then it may be time to buy a new joystick…
It works with my logitech rumblepad.
Hmm… yeah but a Rumblepad is a game pad with 2 analog joysticks. May be a different beast. I’m still experimenting. I’ve gotten the horizontal input to work, but only in a standalone, not in the Unity editor.
Anyone else with a real joystick that has configured their tophat with Unity?
Well it’s definitely NOT the joystick. I just fired up my Windoze machine and gave the joystick a test with a couple games. The tophat works perfectly with all the games I tried, but still no luck with Unity.
It’s more like the D-pad of a rumblepad (which I think acts as 4 buttons).
But you can make an axis in Unity out of 2 buttons.
I found this nice little utility:
http://alphaomega.software.free.fr/joystickandgamepadtester/Joystick%20And%20Gamepad%20Tester.html
At any rate, it shows that my “tophat” is definitely working, it’s just that Unity isn’t reading the data properly. It appears that the tophat is an “8-way” on-off switch and I think that’s confusing Unity.
I wonder if there’s a work-around? I appears that the data the tophat feeds is like this:
center: 0
up: 1
left: 7 right: 3
down: 5
Joachim (or anyone else) any ideas on how to re-configure Unity so my tophat works? Based on what this utility shows me, I’m thinking that any -real- tophat will not work in Unity.
Although I could use keystrokes or joystick buttons instead, operating my sim is getting pretty confusing as it is, it will only be worse if I’m not able to use a tophat.
Thanks!
Have you tried setting the “Snap”?
Yup, tried that. I ended up getting a Logitech Rumblepad 2, works like a champ!
Darn! My joystick has a tophat, and I didn’t get as far as you did… I was hoping you’d figure it out for me! :twisted:
Thanks for this!
Works on my Nyko AirFlow, just peachy!
hi,
The Hatswitch problem is not solved yet!
We are using CH products Flightstick Pro, and We can´t get the HAT switch to work.
The problem is as far as we can see that Unity doesnt interperate it correctly, as a HAT switch is a special kind of Axis.
It sends out the following information.
Up = 1
Up&Right = 2
Right = 3
Right Down =4
Down = 5
Down Left = 6
Left =7
Left Up 8
but when using as a Unity Axis this is what we get:
Up = 1
Down = -1
Left = 1
Right = -1
which makes it impossible to se the diffrence in Right/Left and Up/Down etc.
I really hope this will be fixed since its kind of important, at least for us :-),
Or even better I´m wrong about this!
Thanks!
You need a third party solution to handle the HAT issue correctly.
I have CH products Fighterstick Pro and the solution was to use a commercial solution Rewired (advanced input for Unity) in the asset store. https://www.assetstore.unity3d.com/en/#!/content/21676.