Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » Mac OS X Joystick Patch

This thread is locked; no one can reply to it. rss feed Print
Mac OS X Joystick Patch
Todd Cope
Member #998
November 2000
avatar

While working on my current project I noticed a problem with the OS X implementation of joystick support.

I have a Mayflash Wii U Pro Controller adapter connected to my Mac. This device supports connecting up to 4 Wii U Pro Controllers. All of the inputs are are reported through the same HID device which means there are lots of buttons and sticks to keep track of.

This brings me to the first problem. Allegro has a hard-coded limit of 32 buttons. This is not enough to handle the maximum number of buttons that can be reported by the adapter (48).

The second problem is in the way the OS X implementation enumerates the buttons. Allegro uses IOHIDElementGetUsage() to determine button indices, but this is not enough to differentiate between the buttons of separate controllers connected to the adapter. Each controller reports usage values of 1-12 so Allegro will only count the buttons on the first controller. Buttons on all other controllers are ignored.

I have attached a patch that fixes these issues. I have raised the hard-coded limit to 64 and changed how the buttons are enumerated.

Append: I'm going to look into this further. I think the device may break each controller's inputs up into separate collections. If that's the case, I should be able to separate the data for each controller.

Append 2: I've attached a new patch which breaks up the inputs for each controller based on the collections specified by the device. The imeplementation now creates four ALLEGRO_JOYSTICKs for the device, as it should.

Append 3: New patch (osx_joystick_patch_r3.diff) described below.

SiegeLord
Member #7,827
October 2006
avatar

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Peter Hull
Member #1,136
March 2001

I can have a look at this but I don't have any hardware to test it with, unfortunately.
Pete

Todd Cope
Member #998
November 2000
avatar

I have attached a new patch to the first post. The new patch includes code that will store the name of the HID device instead of just calling it "Joystick". I also went ahead and made proper default names for the various types of elements. Now you will get Primary Stick, Hat Switch, X-Axis, etc. instead of Stick 0, Axis 0, etc.

The default names are based on data reported by the HID device so they should be accurate if the device manufacturer set things up properly.

Go to: