Joysticks?

Archives Forums/MacOS X Discussion/Joysticks?

ima747(Posted 2007) [#1]
It looks to me like HID compliant joysticks/gamepads atleast don't work with blitz on macOS (JoyCount always returns 0)... anyone know of a workaround? for 1 of the games I'm working on it doesn't matter I can just map the controls to the keyboard, but for another I need dual analog sticks and even if I map 1 to the mouse I'm still short 1 analog input...


RiK(Posted 2007) [#2]
I use an XBox 360 controller via Colin Monroe's excellent driver, works great.

http://www.tattiebogle.net/index.php/ProjectRoot/Xbox360Controller


skidracer(Posted 2007) [#3]
Unfortunately there is nothing generic about HID controllers on the Mac, the code was tested with three different controllers so should be able to enumerate any device that reports itself as kHIDUsage_GD_Joystick, kHIDUsage_GD_GamePad, or kHIDUsage_GD_MultiAxisController classes.

Exactly what joystick are you testing with?


ima747(Posted 2007) [#4]
interesting. I plugged both of my game pads in and now they work... I'm guessing I had a wierd driver installed that was trying to take over somewhere. I have game pad companion installed now but not active. I may have had the Xbox HID driver and or USB overdrive installed the last time I tried... so appologies for a stupid question, and if you're having trouble make sure 3rd party apps are removed.


ima747(Posted 2007) [#5]
well after more testing there's still problems... on the PC axis's report in a range of -1 to 1 like they should... on the mac they report very differently. one joystick reports from -257 to 254 on most axis's and another reports from -1 to 7 on one axis and 1(that's positive) to 3 on another... looking at the data with joystick and gamepad tester they both look to be working fine, axis ranges are -3k to +3k on the first controler and -13k to +13k on the second (which should be interpreted to a percentage and expressed as -1 to 1 I think)... since they apear to be calibrated on a hardware level, and they work in other programs without a hitch I think it's a blitz issue... any thoughts?


skidracer(Posted 2007) [#6]
Can you uncomment the printf lines in mod/pub.mod/freejoy.mod/freejoy.macosx.c lines 124 and 129 and rebuild modules. This should report the ranges which the mod uses to scale each axis to -1..1.


ima747(Posted 2007) [#7]
there's no printf on those lines... what is the line so I can search for the content.

it looks like on line 92 is where it's doing the scaling with this:
axis[i]=(event.value-128)/128.0

which would work great if the value was 0-256 but it doesn't look like it's using a range value for scaling...

freejoy.bmx says it is version 1.08 and synchinc my modules doesn't get anything new so I'm assuming I've got it up to date...


ima747(Posted 2007) [#8]
I made a sample app that just gets all the axis values and draws them to the screen so you can see what it's saying.

I took the numbers it was generating (the wierd ranges) and pultiplied them by 128 then added 128 and I got some more usefull info...

using that method the axis ranges for the first joystick (was -1 to 7) is now 0 to 1024

the second stick which was giving me -256 to 256 is now -32768 to 32768

so it looks to me like the freejoy module is assuming the range is always 0 to 256 and not using actual axis ranges...

is my verson of freejoy out of sync? Syncing doesn't update but I don't know where to check for the most recent version...


skidracer(Posted 2007) [#9]
Are you on intel or ppc? Anyway here is replacement .c file for now. Will bump the module version and resync once you have it working.




ima747(Posted 2007) [#10]
copy + paste = success

I'm on PPC. It's working 100% now with both controlers and all axises. Everything reads -1 to 1 like it should. The file you posted was substantialy different from the one I had. Just out of curiosity does the update system differentiate between PPC and Intel?

btw thanks for all the help, it was much appreciated!