[SOLVED] Searching for gamepad

Started by Klems, December 30, 2011, 20:58:57

Previous topic - Next topic

Klems

Hi !

I'm looking for a efficient way to search for connected gamepad.

Right now, here is the code I'm using :
Controller controller = null;
for (int i = 0 ; i < Controllers.getControllerCount() ; i++) {
	Controller c = Controllers.getController(i);
	String name = c.getName().toLowerCase();
	
	if (name.indexOf("joystick") != -1 || name.indexOf("pad") != -1 || name.indexOf("game") != -1) {
		controller = c;
		break;
	}
}

It work because Windows assign the name "USB Joystick" to my gamepad. But it didn't work with another gamepad which was called "dual analog something". This code is temporary.

I'm looking for a more clean code.
Something along the line of "c.isGamepad()" would be perfect.

Does anyone have documentation about LWJGL controllers ? Or do I have to use JInput ?

Thanks !

EDIT : is it possible to make the gamepad vibrate ?


EDIT 2 : Nevermind. Using JInput solved everything.
You can check the type of the controller and enable the rumblers.

Happy coding !