XBox 360 controllers take 2

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.

220563–8097–$xbox_controller_shim_756.zip (1.14 MB)

Oops, the 1.0a2 build couldn’t get the button input correctly.

Changed from bool to float type and that seems to work.

I updated the download above to 1.0a3.

Ah, just found this follow up post. Once Tattiebogle comes back up I’ll give the new drivers a whirl. I didn’t know he’d updated it to 0.09. It is difficult to tell based on the website that any updates have really occurred.

Last time I tried on a Core 2 machine the installer wouldn’t even run…

So, I suppose I’ll try this version.

oops, I’m using the 0.08 drivers from September. No problems with them this month, though I am using a 64-bit control panel that I recompiled from the source.