Is it possible to retrieve the player number assigned to a controller when it connects to the PC? I’ve looked around the Lime Joystick and GameInput APIs, and there are things like the GUID and name, but nothing to determine what player number a specific connected device has.
The device list you can access through getDeviceAt
using the GameInput API also isn’t of any use since its order entirely depends on the order in which controllers connect to it. So if one disconnects and reconnects, the order could be screwed up. It also doesn’t identify which the player number assigned to the connected controller.
I’m working on a project that relies upon being able to retrieve this information, so any help would be greatly appreciated.
I am using two official Xbox 360 wireless controllers with the official Xbox 360 Wireless Receiver for Windows.
On native platforms, Lime uses SDL’s “Joystick” APIs. It appears that SDL has methods to access the player index, but they are not currently exposed by Lime.
SDL_JoystickGetDevicePlayerIndex
SDL_JoystickFromPlayerIndex
SDL_JoystickGetPlayerIndex
SDL_JoystickSetPlayerIndex
For the html5 target, we use the JavaScript Gamepad API. However, as best I can tell, it does not appear to expose a method or property to identify the gamepad’s player index.
There’s a good chance that Lime doesn’t expose the player index simply because it isn’t available cross-platform.
I see. Is there any way to access those methods from SDL directly in Haxe? Or does it have to be exposed by Lime in order to be used at all?
Unfortunately, there is no workaround with Haxe alone. It would need to be exposed to Haxe by Lime’s C++ code.
Ah I see. Unfortunately that means I can’t do exactly what I was aiming for with my project, but I do appreciate the response.