[Solved] Lime.ui.gamepad

Could anyone point me in the direction of how to listen for the events dispatched through this API? I’ve found the events but I’m not quite sure how to access them and can’t find any instructions on this. I’m keen to get a long term gamepad solution for our game engine and it seems from what I’ve read that using the lime.ui.gamepad API is the way to go!

You can connect to these events through lime.ui.Window, it has 5 events:

onGamepadAxisMove = new Event<Gamepad->GamepadAxis->Float->Void> ();        
onGamepadButtonDown = new Event<Gamepad->GamepadButton->Void> ();
onGamepadButtonUp = new Event<Gamepad->GamepadButton->Void> ();
onGamepadConnect = new Event<Gamepad->Void> ();
onGamepadDisconnect = new Event<Gamepad->Void> ();

between the “<” and “>” is the event function signature.

lime.app.Application.current.windows[0].onGamepadConnect.add(function(g:Gamepad):Void {
    trace("Got a new gamepad!");

Spot on! Thanks so much, you absolute hero :smile:

You should also be able to use:

import openfl.Lib;


Lib.application.window.onGamepadConnect.add (myConnectHandler);

Oh brilliant - that looks much nicer - thanks to you both :smile:

I get an error saying

lime.ui.Window has no field onGamepadConnect

for both versions of that code. I run with the Haxe compiler version 3.2.0 and OpenFL is at version 3.3.5. I don’t see it in the docs either. Has this functionality been removed?

They have been moved outside of window to support multiple windows.

You now have lime.ui.Gamepad.onConnect and for each gamepad you have onAxisMove, onButtonDown, onButtonUp and onDisconnect.

Indeed, thanks! :grinning: