Freejoy OSX not working properly

Archives Forums/BlitzMax Bug Reports/Freejoy OSX not working properly

Robb(Posted 2012) [#1]
The pub.freejoy module for MacOSX doesn't assign devices correctly.

It looks like the module allocates Blitzmax Joypads per HID device and not how many Generic Desktop Joystick usage pages are contained within each HID.
This means that USB joypad hubs don't work properly with Blitzmax. Freejoy tries to allocate all of the joypad inputs to the same blitzmax device which renders all connected joypads completely unusable. To give an example:

If your hub has four joypads connected, the buttons and axes will be randomly distributed amongst them - one pad has buttons 1-4, another has the X & Y axes etc.

Separation of the HUB connected joypads is definitely possible in MacOSX (the joypads work fine in other apps) but anything made with Blitzmax isn't working properly.

I've raised this issue a few times now, but never seem to get very far in solving the problem. Is there any chance that an update could be made to Freejoy to alter how it enumerates joypads?

Last edited 2012

Last edited 2012


marksibly(Posted 2012) [#2]
Hi,

Are you talking about a special type of joypad hub here, or any old usb hub?

[edit]
Just tested with 2 gamepads and 1 dirt-cheap usb hub, and freejoy seems to work. I modified the joycount sample code to toggle ports when space is hit and neither gamepad interfered with the other.

Can you provide more details of your setup? Are you using a special kind of hub? Does it happen with only 2 gamepads? etc...
[/edit]

Last edited 2012


Robb(Posted 2012) [#3]
Hi, thanks for the reply I *really* appreciate the help.

It seems to be joypad specific hubs. I've tested with a SNES to USB hub with two sockets. The same thing happens if I use a similar HUB for two PS2 controllers.

Other OSX apps recognise the hub as two separate usb controllers, but with blitz games input is always split. It doesn't matter if there are one or two controllers connected to the hub - one socket gets the buttons, the other socket gets the dpad. I think the freejoy module is registering only one USB device and trying to map the inputs of two controllers to one blitz 'joypad'.

This is the USB prober profile for the device:



Printing the cookie output in freejoy module gives the following:
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



marksibly(Posted 2012) [#4]
Hi,

Can you give this a try?

It's based on GLFW and wont work exactly the same as freejoy, but we'll be able to see if it can handle your hardware at least. It can be freejoy-ified later if it works.

New code for freejoy.mod/freejoy.macosx.c



And modified joycount demo - hit space to change joy port being tested:




Robb(Posted 2012) [#5]
Hi,

I've compiled the tests and get these results:

Socket 1 now works perfectly - the dpad corresponds to the R&Z axis and the buttons match up correctly. Amazing!

Socket 2 isn't yet registered as a separate joypad in blitz - the dpad doesn't work and the buttons register as buttons 16 and over on the other pad

Great progress though, thanks! :D


marksibly(Posted 2012) [#6]
Hi,

> Socket 2 isn't yet registered as a separate joypad in blitz - the dpad doesn't work and the buttons register as buttons 16 and over on the other pad

But that's a FAIL isn't it? SO GLFW doesn't work properly either?

Alas, that's probably as far as I can go without any actual hardware to play with. Even then, I don't really have a clue what's going on (Why does a normal hub work? Is the SNES/hub thing therefore a 'special' device type? Are there specs somewhere? Sample code?) and given that I'm FAR from an expert on low-level USB coding/drivers (which you apparently have to be just to read a freaking gamepad on the Mac!) combined with the general dearth of information out there re: getting gamepads going on the Mac, it could all just be a massive waste of time!

Anyway, I'll talk it over with skidracer (who knows far more about this stuff than I do) but right now I'm stuck.