Multiple controllers are switching names, guid with lime.ui.Joystick

Hi there,
I have a problem with lime.ui.Joystick, one of my controller is an old Logitech, it works only with the Joystick API not Gamepad.

My other controller is a classic xbox360, it works with both API so I decided to use lime.ui.Joystick.
My problem is when they are both connected, they switch their name, button mapping, guid… everything.

So to be clear, when I push a button on the Logitech controller in there
gamePad.onButtonDown.add (function (button:Int)
{
trace("gamePad.name : " + gamePad.name);
trace("gamePad.guid : " + gamePad.guid);
}
I get the name and the guid of the xbox controller. And same goes for the Xbox controller, they sort of switched their index id…

I tried to look inside the Joystick class and also in lime NativeApplication but It’s hard for me to see what the issue could be… I don’t see anything wrong in there.

I need your help, thanks !

Has anyone experienced this behaviour ?

Also, is there another way to use lime.ui.Joystick and Gamepad than this :
Gamepad.onConnect.add (function (gamepad) {
gamepad.onAxisMove.add (function (axis:GamepadAxis, value:Float) {
trace ("Moved Axis " + axis + ": " + value);
});
});

Encapsulated functions are not the best to work with.
And I found out that it needs to be placed in the document class in order to detect controllers when they are already plugged before the game start.
Once the game started, disconnection and reconnection of controllers works as expected.

Sorry to bump this, but I still have the same problem with lime.ui.Joystick
Plus, my beta testers found out that if they have 2 or more identical controllers (2 ps4 for ex), they overlap each other and they control two players with one controller.

I can’t seem to glue a joystick to a player, and it’s also because of the way this class is made. It contains single joystick events but also the devices Map…

I’m trying to do something like this :

Joystick.onConnect.add (function (joystick:Joystick) {
if (gamePads.indexOf(joystick) == -1){
var gp:GamePad = new GamePad();
gp.init(joystick);
gamePads.push(gp);
}
}

Thank you for your help

When you begin, you can access Gamepad or Joystick objects using Gamepad.devices or Joystick.devices

Once you have a Gamepad or Joystick instance, you can keep a reference to it, and add listeners, etc.

I just went through and noticed at least one issue – SDL has “device index” and “instance ID” for joysticks and gamepads. The “device index” is a zero-based index which has to do with connecting a device. Elsewhere, I believe the instance ID value is always used. We appear to use this value in our gamepad and joystick events, however I noticed that we accidentally used an API for getting the GUID based on the device index value, not instance ID. I have just corrected this in a recent commit to the development version of Lime.

Are you basing unique events from the API using the id value? The GUID value is actually intended to be hardware-specific – meaning two gamepads of the same make and model would have the same GUID. It’s for knowing what kind of gamepad it is. The ID value is meant to be unique globally, unless I misunderstand SDL’s API.

Oh this could help me ! I think the problem is linked.
Stupid question but what’s the clean way for me to update lime with this commit.
I tried to install lime dev with haxelib, but it says openFl is not compatible with Lime 4.0.0. I had to go back to lime 3.7.4.
I’m not sure how to proceed.

Thank you so much Joshua !

Try using a development version of OpenFL with a development version of Lime

When I use development version for both I get those errors when compiling :

C:/Users/Guest/openfl/openfl/display3D/textures/Texture.hx:40: characters 101-102 : Int should be lime.utils.BytePointer
C:/Users/Guest/openfl/openfl/display3D/textures/Texture.hx:40: characters 101-102 : For function argument 'data’
C:/Users/Guest/lime/lime/text/Font.hx:32: characters 2-11 : Build failure
Build halted with errors.

When I switch back to the release version with “haxelib dev lime” “haxelib dev openfl” setting the previous version… I get this :

Called from ? line 1
Called from CommandLineTools.hx line 1683
Called from CommandLineTools.hx line 24
Called from CommandLineTools.hx line 131
Called from CommandLineTools.hx line 686
Called from lime/project/PlatformTarget.hx line 99
Called from lime/tools/platforms/WindowsPlatform.hx line 373
Called from lime/tools/helpers/AssetHelper.hx line 50
Called from /usr/lib/haxe/std/neko/_std/sys/io/File.hx line 38
Called from /usr/lib/haxe/std/neko/_std/sys/io/File.hx line 54
Uncaught exception - [file_open,bin/windows/cpp/debug/bin/manifest]

Please help…

Don’t mind the last post, doing a clean build fixed it.

I still have those with dev version though even with a clean build.
C:/Users/Guest/openfl/openfl/display3D/textures/Texture.hx:40: characters 101-102 : Int should be lime.utils.BytePointer
C:/Users/Guest/openfl/openfl/display3D/textures/Texture.hx:40: characters 101-102 : For function argument 'data’
C:/Users/Guest/lime/lime/text/Font.hx:32: characters 2-11 : Build failure
Build halted with errors.

.

Try and pull again, this should be resolved in the latest OpenFL dev build

Thanks again for your help in testing things out, I’m interested to hear if things work better now :slight_smile:

Thank you, I did “haxelib dev lime lime” “haxelib dev openfl openfl” to set it back to dev, udpated both and got changes in few files but still have the same errors popping up when I compile a clean build.

This should have been fixed since five hours ago

Double-check that you are on the “develop” branch, and that OpenFL is pulling in new changes?

Oh, wait, that fixes a different issue.

That type should be lime.utils.DataPointer, which allows conversion from an Int. Make sure Lime is up-to-date and on the develop branch?

If you have ever used a fork of Lime or OpenFL, also check git remote -v to make sure you are working with the right origin repository. Thanks :slight_smile:

When I do git remote -v I get :
origin https://github.com/openfl/lime (fetch)
origin https://github.com/openfl/lime (push)

How can I choose the correct one, and whish one is it ?
Thank you !

Ok I made it work by deleting and haxelib git lime again.

Unfortunately I still have the same problem.
Here is the code in case I do something weird, it’s really simple.

Joystick.onConnect.add (function (joystick:Joystick) {
	var gp:GamePad = new GamePad(); //my own class
	gp.init(joystick);
    //here I store the joystick and have events in the gp class
	gamePads.push(gp);
}

when I plug only one gamepad, I have the correct name & guid.
But when 2 gamepads are plugged I get
name => null
guid => 00000000000000000000000000000000
for one of the gamepad, the other one is recognised correctly.
And they switch completely, id name guid, when I check it in their respective events…
Apparently with 2 identical gamepads, only one is stored and functionning.

I was using the dev version of Lime and openFl for a few days and noticed the fps drops significantly after a while in the game. Sometimes creating a new player will set it back to 60fps and then it drops again untill it’s not playable anymore.

I don’t have this problem with the last released version, so there must be a leak or something in the development versions.

We got two identical gamepads yesterday, I will be testing soon.

Could you double-check if you have the latest development versions, and see if it performs any better? There have been have been big changes to the OpenGL bindings, but I don’t believe it should have a performance regression

I double checked my haxelib and updated lime and openfl and did lime rebuild windows so I’m sure to have the last version. (I changed this also on mac VM today but it’s too slow to test there)
I still have FPS droping slowly, so I went ahead and try to understand why creating a player set the FPS back to 60fps.
It turns out creating a new textfield (starling) reset the fps back to 60.

If I create var tex:TextField = new TextField();every frame, the FPS is stable between 58/60.

Hope this helps, thank you !

I just realised this FPS drop “fix” only works when the Starling.showstats() is true.
I also saw some player UI switching z-index (or texture was gone for a sec) during game.
And lastly, I had a computer crash after a long play. I had to manually restart my pc, I couldn’t control anything on windows, I hope it’s linked and not my laptop :smile:

This problem with Joystick switching IDs is still there.

So when I have 2 Xbox controllers plugged, they switch their ID, Lime register 2 controllers and eveything is fonctionning well because their events are working and you don’t know they switched when you play but for example when I ask to vibrate one controller, it’s the other controller that does vibrate.

It’s also visible when I try to remap buttons, the name (called from id) are switched, so if I have 1 Logitech controller and 1 Xbox controller, they switch their mapping.