Spent some more time on the xbox controller integration today.
Given how screwed Unity’s input subsystem is, I decided to bypass it via a native HIDManager plugin.
I guess Tattlebogie’s 0.09 drivers for 10.6 are working OK, I haven’t seen any KPs today with them at least.
http://tattiebogle.net/index.php/ProjectRoot/Xbox360Controller/OsxDriver
I took his control panel test code and rewrapped it as a shim that reports the state of up to 4 connected controllers. Eg:
void Update()
{
Buttons buttons0 = XBoxController.GetDeviceButtons(0);
Axes axes = XBoxController.GetDeviceAxes(0);
Vector3 forces = new Vector3(0, axes.leftY, axes.leftX);
rigidbody.AddForce(forces*Time.deltaTime*500);
if ( !bullet.active buttons0.A)
tests pretty robustly WRT device connect/disconnects . . .
axes and buttons will come back zeroed if you are polling an invalid device – and so will XBoxController.GetDeviceID() – it will return “invalid” if the device is gone.
Note that if player 1 unplugs then player 2 will become player 1; the device IDs are persistent though so one can keep track of which input is still active that way.