Mac osx Joypad axis

BlitzMax Forums/BlitzMax Programming/Mac osx Joypad axis

Robb(Posted 2011) [#1]
I recently bought a USB adaptor to use my original SNES controllers with my Mac.

The pads work perfectly in every app I've tested them with, except for Blitzmax. I can access all of the buttons but the dpad doesn't correspond to any of the axis available within Blitzmax (or the freejoy test example).

When I use the pad in other apps, the dpad appears to correspond to the standard joypad X & Y axis but within Blitzmax I get no response from these.

Has anyone else come across issues like this? is there something I've missed?


jkrankie(Posted 2011) [#2]
Is it being picked up as a hatswitch? Try the joycount example in the docs.

Cheers
Charlie


Robb(Posted 2011) [#3]
I tried it and nothing registers the dpad at all. The JoyHat bar is filled to the right but nothing changes when I move the dpad.

I'm very confused by it as the dpad works perfectly (as X & Y axis) in just about everything else.


skidracer(Posted 2011) [#4]
If you are able to rebuild modules and want to help fix the BlitzMax joystick driver could you please try the following:

Open the %BlitzMax%/mod/pub.mod/freejoy.mod/freejoy.macosx.c file and uncomment the lines at 140 and 179 so they read:


		printf("page=kHIDPage_GenericDesktop usage=%d cookie=%d\n",usage,cookie); 

....

		printf("page=kHIDPage_Button usage=%d cookie=%d\n",usage,cookie);



Then if you could post the information logged when you run your app and play with the joypad I should be able to suggest a fix.


Robb(Posted 2011) [#5]
I've uncommented the lines and rebuilt the modules but I'm not exactly sure what you mean by the 'information logged'. Do you mean the output of the joycount example?

In which case buttons 0,1,2,3,6,7,8,9 are registered
JoyButtonCaps(0) = 00000000000000001111111111111111
JoyAxisCaps(0) = 00000000000000000000001000001111


skidracer(Posted 2011) [#6]
You should get some new output in your program starting with "page=" etc. If not I shall look into better suggestion when I get home and plug some joysticks into my Mac to test.


Robb(Posted 2011) [#7]
EDIT: I rebuilt the app and got this output.

page=kHIDPage_GenericDesktop usage=4 cookie=1
page=kHIDPage_GenericDesktop usage=50 cookie=2
page=kHIDPage_Button usage=1 cookie=7
page=kHIDPage_Button usage=2 cookie=8
page=kHIDPage_Button usage=3 cookie=9
page=kHIDPage_Button usage=4 cookie=10
page=kHIDPage_Button usage=5 cookie=11
page=kHIDPage_Button usage=6 cookie=12
page=kHIDPage_Button usage=7 cookie=13
page=kHIDPage_Button usage=8 cookie=14
page=kHIDPage_Button usage=9 cookie=15
page=kHIDPage_Button usage=10 cookie=16
page=kHIDPage_Button usage=11 cookie=17
page=kHIDPage_Button usage=12 cookie=18
page=kHIDPage_Button usage=13 cookie=19
page=kHIDPage_Button usage=14 cookie=20
page=kHIDPage_Button usage=15 cookie=21
page=kHIDPage_Button usage=16 cookie=22
page=kHIDPage_GenericDesktop usage=50 cookie=41
page=kHIDPage_GenericDesktop usage=53 cookie=42
page=kHIDPage_GenericDesktop usage=48 cookie=43
page=kHIDPage_GenericDesktop usage=49 cookie=44
page=kHIDPage_GenericDesktop usage=57 cookie=45
page=kHIDPage_GenericDesktop usage=4 cookie=4
page=kHIDPage_GenericDesktop usage=50 cookie=5
page=kHIDPage_Button usage=1 cookie=24
page=kHIDPage_Button usage=2 cookie=25
page=kHIDPage_Button usage=3 cookie=26
page=kHIDPage_Button usage=4 cookie=27
page=kHIDPage_Button usage=5 cookie=28
page=kHIDPage_Button usage=6 cookie=29
page=kHIDPage_Button usage=7 cookie=30
page=kHIDPage_Button usage=8 cookie=31
page=kHIDPage_Button usage=9 cookie=32
page=kHIDPage_Button usage=10 cookie=33
page=kHIDPage_Button usage=11 cookie=34
page=kHIDPage_Button usage=12 cookie=35
page=kHIDPage_Button usage=13 cookie=36
page=kHIDPage_Button usage=14 cookie=37
page=kHIDPage_Button usage=15 cookie=38
page=kHIDPage_Button usage=16 cookie=39
page=kHIDPage_GenericDesktop usage=50 cookie=46
page=kHIDPage_GenericDesktop usage=53 cookie=47
page=kHIDPage_GenericDesktop usage=48 cookie=48
page=kHIDPage_GenericDesktop usage=49 cookie=49
page=kHIDPage_GenericDesktop usage=57 cookie=50

Last edited 2011


skidracer(Posted 2011) [#8]
Thanks for that.

It looks reasonable with usage=48 and 49 representing JoyX and JoyY values being reported by OS.

If you could also uncomment the printf lines above those (still inside the macjoyelement function) which report the axismin and axismax values I am interested in what these values report also.

Sorry for the inconvenience.

Also, what may be useful is if you run the USB prober app in Applications->Utilities you could find the device entry in the first window, expand all the internals, then select, copy and paste the contents here.

Last edited 2011


Robb(Posted 2011) [#9]
Its no problem at all, thanks for the help!

This is the output with axismin/axismax. 49's max of 7 looks a bit odd to me.


And the USB prober details



Robb(Posted 2011) [#10]
I just tested the SNES controller with my PC laptop and the X & Y axis work perfectly so this is definitely just a Mac OSX issue.


Robb(Posted 2011) [#11]
Another development I've noticed that might help.

The USB adaptor has two pad sockets on it so you can connect two pads at once. In Blitzmax one socket will only register the dpad, the other will only register the buttons.

As I said before though, both pads work perfectly in every other app I've tried.


Robb(Posted 2012) [#12]
Is there any chance of getting more help with this? I'm still getting the problems with the latest Blitzmax version.

The adaptor works perfectly with Blitzmax on Windows, but the Mac version just doesn't get the axis right. The buttons are picked up on one port and the axis on the other.

This is the only joypad I have and I can't properly test my game on Mac OS at the moment

OK so uncommenting the lines Skidracer suggests, the logs are like this:
page=kHIDPage_GenericDesktop usage=4 cookie=1
page=kHIDPage_GenericDesktop usage=50 cookie=2
page=kHIDPage_Button usage=1 cookie=7
page=kHIDPage_Button usage=2 cookie=8
page=kHIDPage_Button usage=3 cookie=9
page=kHIDPage_Button usage=4 cookie=10
page=kHIDPage_Button usage=5 cookie=11
page=kHIDPage_Button usage=6 cookie=12
page=kHIDPage_Button usage=7 cookie=13
page=kHIDPage_Button usage=8 cookie=14
page=kHIDPage_Button usage=9 cookie=15
page=kHIDPage_Button usage=10 cookie=16
page=kHIDPage_Button usage=11 cookie=17
page=kHIDPage_Button usage=12 cookie=18
page=kHIDPage_Button usage=13 cookie=19
page=kHIDPage_Button usage=14 cookie=20
page=kHIDPage_Button usage=15 cookie=21
page=kHIDPage_Button usage=16 cookie=22
page=kHIDPage_GenericDesktop usage=50 cookie=41
page=kHIDPage_GenericDesktop usage=53 cookie=42
page=kHIDPage_GenericDesktop usage=48 cookie=43
page=kHIDPage_GenericDesktop usage=49 cookie=44
page=kHIDPage_GenericDesktop usage=57 cookie=45
page=kHIDPage_GenericDesktop usage=4 cookie=4
page=kHIDPage_GenericDesktop usage=50 cookie=5

There is also a further set (most likely as there are two ports on the adapter):
page=kHIDPage_Button usage=1 cookie=24
page=kHIDPage_Button usage=2 cookie=25
page=kHIDPage_Button usage=3 cookie=26
page=kHIDPage_Button usage=4 cookie=27
page=kHIDPage_Button usage=5 cookie=28
page=kHIDPage_Button usage=6 cookie=29
page=kHIDPage_Button usage=7 cookie=30
page=kHIDPage_Button usage=8 cookie=31
page=kHIDPage_Button usage=9 cookie=32
page=kHIDPage_Button usage=10 cookie=33
page=kHIDPage_Button usage=11 cookie=34
page=kHIDPage_Button usage=12 cookie=35
page=kHIDPage_Button usage=13 cookie=36
page=kHIDPage_Button usage=14 cookie=37
page=kHIDPage_Button usage=15 cookie=38
page=kHIDPage_Button usage=16 cookie=39
page=kHIDPage_GenericDesktop usage=50 cookie=46
page=kHIDPage_GenericDesktop usage=53 cookie=47
page=kHIDPage_GenericDesktop usage=48 cookie=48
page=kHIDPage_GenericDesktop usage=49 cookie=49
page=kHIDPage_GenericDesktop usage=57 cookie=50


In one set of results the usage & cookie attributes for the axis match, and in the other they don't.

How does Blitzmax interpret the 'cookies'? currently when the controller is plugged into port1, the axis cookies are wrong, or not understood as axis by blitz (I have bolded them above)

Last edited 2012

Last edited 2012

Last edited 2012


Robb(Posted 2012) [#13]
Weirder still, Blitzmax recognises the d-pad as button pushes

Y-axis up: 12
Y-axis down: 14
x-axis left: 15
x-axis right: 13


skidracer(Posted 2012) [#14]
Can you post a web link to actual device, I may be able to pick one up cheap and sort this out.

The fact there are two controllers on one device is what is causing freejoy the most confusion I think.

Are you able to test with joycount example when two pads are connected?

Last edited 2012


Robb(Posted 2012) [#15]
The device is here, but will require original SNES control pads to plug in.

I've plugged two controllers in and it still only picks up one in the joycount example. Delving a little deeper, within MacOS I think it is assigning both controllers to a single joypad device:

Adapter Port 1 uses buttons 1-10 for SNES buttons and then assigns the dpad to buttons 12-15
Adapter Port 2 uses the joyaxis as the D-pad and then assigns the remaining buttons to higher button values (though I'm not sure what)

The joypads work in other MacOSX apps as those apps allow specific calibration of each input (i.e. press 'up' to set y axis).

In windows this isn't a problem because the device driver registers 2 separate joypads.


skidracer(Posted 2012) [#16]
I wonder what Usage Page (65280) means.

I think the trick will be for freejoy to recognize multiple page descriptions each featuring a Usage (Joystick) descriptor.

You could try to get freejoy to ignore second set of descriptors which may stop them overwriting first set.


Robb(Posted 2012) [#17]
Looking around on Google, Usage Page (65280) seems to just return 'unhandled page'. Hmm

It'd be fantastic if Freejoy could recognise each Usage (Joystick) as a separate pad.
I think the main problem at the moment is that it is combining both together. If I have both controllers plugged in at the same time they provide half of the input each!

This is starting to confound me now, because even though the dpad was being picked up as buttons 12-15 last night, the exact same test this morning is getting no response at all.

I have just borrowed a 2-port playstation to USB adapter from a friend and it is having the same issue: dpad & sticks on one pad, buttons on the other. Suggests that separating Freejoy by Usage (Joystick) might be the answer as other people with dual-port joypad hubs would likely have the issue.

Last edited 2012


Robb(Posted 2012) [#18]
I've tried to alter the freejoy module to separate joypads by usage page (joystick) but I've not had any luck. The code is too dense for me! :(

This is frustrating because it works fine on PC.

Is there any chance of an official update to the Mac freejoy module? I've now tested this with several adapters and this bug does seem to affect any usb joypad hub with two or more pads.


Robb(Posted 2012) [#19]
Still having these issues. I've created a bug report for the greater issue.
http://www.blitzbasic.com/Community/posts.php?topic=98219

I'd appreciate a little help in solving this, if anyone can decipher the freejoy module code :)