[ Solved ] Issues with Joystick on new OpenFL

Hello.
I get trouble handling joystick events with the current version of openfl.

I followed Joshua’s exemples and even looked at how it’s handled in haxePunk (the same way, in fact) but my nes usb gamepad is not found at all :flushed:
No result on Neko/C++.

My HaxePunk older builds (with older lib versions) still work, so I know it’s not because of the gamepad itself…

Could someone try it on another computer, with any usb gamepad plugged in ?
I’m on windows 8.1.

You may download my very-light tester project here (zip).
It doesn’t display anything, but should trace some stuff in the debug console.

And here’s my code :

package;

import openfl.display.Sprite;
import openfl.events.Event;
import openfl.events.JoystickEvent;
import openfl.Lib;

class Main extends Sprite {
    public function new(){
        super ();        
        addEventListener (Event.ADDED_TO_STAGE, this_onAddedToStage);
    }
    private function this_onAddedToStage (event:Event):Void {        
        construct ();        
    }    
    private function construct ():Void {        
        stage.addEventListener (JoystickEvent.AXIS_MOVE, stage_onJoyAxisMove);
        stage.addEventListener (JoystickEvent.BUTTON_DOWN, stage_onJoyButtonDown);
        stage.addEventListener (JoystickEvent.BUTTON_UP, stage_onJoyButtonUp);
        stage.addEventListener (JoystickEvent.HAT_MOVE, stage_onJoyHatMove);
        trace("joystick events added...");    
    }
    private function stage_onJoyAxisMove (event:JoystickEvent):Void {
        trace("axis move");        
    }
    private function stage_onJoyButtonDown (event:JoystickEvent):Void {
        trace("btn down");
    }
    private function stage_onJoyButtonUp (event:JoystickEvent):Void {
        trace("btn up");        
    }
    private function stage_onJoyHatMove (event:JoystickEvent):Void {
        trace("hat move");
    }

}

and my config (everything’s up to date but actuate) :

actuate: [1.8.5]
box2d: [1.2.3]
hxcpp: [3.2.102]
layout: [1.2.0]
lime-samples: [2.3.0]
lime: 2.4.1 [2.4.3]
openfl-samples: [2.2.2]
openfl: 3.0.6 [3.0.8]
spritesheet: [1.2.0]
swf: [1.8.7]
tweenx: [0.0.5] 

This is kind of strange, I’ll try with another gamepad tonight.
Thanks for the help !

hmmm. just tried with my 360 controller, but no that doesnt work with it. though did try my other code for joysticks, which did work. sometihng quick and dirty @singmajesty cropped up for when i asked ‘how the chuff can joysticks work in openfl’ :wink:

package;
import openfl.display.Sprite;
import openfl.Lib;
// import openfl.events.JoystickEvent;
// import openfl.display.SimpleButton;

class Main extends Sprite {
	public function new () {
		super ();
		Lib.application.window.onGamepadAxisMove.add (function (gamepad, axis, value) {
			trace ("Gamepad " + gamepad.id + " axis " + axis + " = " + value);
		});
	}
}

Thanks for your code.
I wanted hard to believe in it, but it doesn’t work for me…

I added onGamepadConnect and onGamepadDisonnect events too, and they never fire neither.

I can see that the events listeners are really created, though.

package;
import openfl.display.Sprite;
import openfl.Lib;
// import openfl.events.JoystickEvent;
// import openfl.display.SimpleButton;

class Main extends Sprite {
    public function new () {
        super ();
        Lib.application.window.onGamepadAxisMove.add (function (gamepad, axis, value) {
            trace ("Gamepad " + gamepad.id + " axis " + axis + " = " + value);
        });
        Lib.application.window.onGamepadButtonDown.add (function (gamepad, btn) {
            trace ("Gamepad " + gamepad.id + " btn " + btn.toString());
        });
        Lib.application.window.onGamepadConnect.add (function (gamepad) {
            trace ("Gamepad " + gamepad.id );
        });
        Lib.application.window.onGamepadDisconnect.add (function (gamepad) {
            trace ("Gamepad " + gamepad.id );
        });
        trace(Lib.application.window.onGamepadAxisMove.listeners.length + ' event on axis move');
        trace(Lib.application.window.onGamepadButtonDown.listeners.length + ' event on btn down');
        trace(Lib.application.window.onGamepadConnect.listeners.length + ' event on connect');
        trace(Lib.application.window.onGamepadDisconnect.listeners.length + ' event on disconnect');
    }
}

That’s weird, isn’t it ?
I tested it with a nes usb pad, a snes buffalo one, and a generic ps2 controller.
Same result for all.
All recognised in my previous builds based on older versions of haxe/neko/lime/openfl…

I may try do downgrade a bit and see what happens.

@lewislepton Did you rebuild your old code with current libs up-to-date ?

Just updated my zipped test project, with both Lime and OpenFL joystick handlers.
No detection at all for me (Neko, Neko64, C++)…

aye the code i posted was using the latest of everything. and that code you posted back up, the update version of the one i did. that works completely fine for me

this post is good actually. ive still had trouble getting joysticks to work, not in your case, but just understanding them more than anything. so this ahas slightly cleared up a few thing :wink:

I’m going to try on another computer, and see what happens…
It’s strange that I’m the only one with this issue, and that it worked fine with previous versions on this same computer :disappointed_relieved:
I feel like I’m wasting my time.

Ok, let’s call the computer I struggle with the “new” one, and my old computer the “old” one.

The new one is up-to-date.
The old one isn’t (Haxe 3.1.1, Lime 1.0.1, OpenFL 2.0.1).

I made a build from the new one, with both Lime and OpenFL handling of joysticks :

  • doesn’t work on the new computer
  • doesn’t work on the old neither
    No error but no detection.

I took the same source file, and made a build on the old computer : it works on both computers !

Except that the Lime method is off (creates an error, Lime version API issue I guess), but the official OpenFL method works great !

I guess now I should upgrade the old computer, or downgrade the new one… to continue testing.
This is really time consuming, but it’s important that I find a way to handle joysticks on my new computer, as I’ll have a professionnal use for it soon.

To be continued !

It’s been a hard time to downgrade Lime/OpenFL !

I was never able to get back to my old config :

  • Lime 1.0.1
  • OpenFL 2.0.1
    -> Lime 1.0.1 just doesn’t want to work and gives me a “does it need to be installed ?” when I try to run the setup.

And of course you can’t put an old version of OpenFL with a new Lime.

Looking at all the versions of both, I managed to put together Lime 2.2.2 and OpenFL 2.2.8
and it works, joysticks are back with openfl.events.JoystickEvent !

I think I’m going to stick with it for now, as Lime 2.4.3 + OpenFL 3.0.8 is a fail to me (on the joysticks side).
I’ll check with next releases to see if the issue disappears…
The strange thing is : I don’t know what the problem is, and I don’t know why I seem to be the only victim of it :flushed:

@lewislepton Where you using openfl in legacy mode ?

I posted on github and was able to detect my gamepads with HaxeFlixel… I finally found out flixel is using the legacy mode, and now it works fine for me as long as I don’t use the hybrid mode.

I currently use <set name="openfl-legacy" /> in my project.xml.
I found about it here.

I have not been able to play with my gamepads in hybrid mode at all.

hmm thats strange. i dont have any trouble at all with the joystick. i dont use legarcy either. trying to not use it because i just want to use the later tech :wink: since only really just starting on it :wink:

so are you now on haxeflixel? i saw when playing abstractpixel, that it was haxepunk you used. just interested :wink: have been tempted to use haxeflixel to get some things done quicker. maybe, but trying not to :wink: