Joycon input doesn't work in Defold on Windows

I opened an issue on Github for not being able to use Joycons.
The Joycon input isn’t being received in any defold game.
I’ve tried using this gamepad tester for defold, it doesn’t get any input either, but with this online tester https://gamepad-tester.com/ I can verify that the controllers work fine

I suspect the issue is that there is no profile for Nintendo Joycons in the default.gamepads for Windows.

Copy this file from the builtins and then modify it to add a profile matching what that testing site reports its name as.

There are fields for Joy-Con (L) (osx, linux, switch, android) but not for Windows or HTML5.

We’d happily accept a pull request to the default gamepads once it is confirmed to be working on Windows (and HTML5):

Also, if at any time you come across a gamepad that doesn’t have any bindings then try using the gdc tool to create the correct bindings to add to your gamepads file:

Als, there is the option of using the raw gamepad input:

1 Like

I have 2 switch joycons connected with bluetooth to my Pc.
Is it possible to get the gyroscope / orientation data from both of them at once?

I have almost 0 experience with this side of things but the very first step, if you haven’t yet done so, is to check the raw input. Hopefully someone else will respond with more info soon.

2 Likes

There should be a unique gamepad index/ID in the action table when getting input.

I tried that, also used publicexamples/examples/gamepad_tester at master · britzl/publicexamples · GitHub but its not showing any input from the joycons.
Using Gamepad Tester - Check Controllers and Joysticks Online (gamepad-tester.com) everything works, so the issue is most likely in defold

I tried to connect it on Linux and Windows. The results are the same :confused:

I added: pprint(action_id, action) in on_input, but nothing is printed (not even a single message gamepad_connected, disconnected nor raw, so it is not only not mapped, but also not recognised at all)

Generally JoyCons, as equipment meant for Nintendo Switch, might be part of Switch support for Defold, which is offered to Sponsors (Defold development for Nintendo Switch).
Sadly, there is no single Bluetooth standard implementation and each company might have their own, so with every gamepad there might be issues.

Can anyone with a joycon test adding a profile and see if it works after that?

There are fields for Joy-Con (L) but not for Windows.

Merging with Joycon input doesn't work in Defold on Windows - #4 by britzl

I tested on my Linux machine and both Joy-Cons were recognized and functional.

The gamepads mapping files has listing for Linux / macOS / Switch but not HTML5 / Windows. I’ll buy one today and see what works on Windows and HTML5 when they have mappings setup.

1 Like

device: "Joy-Con L+R (STANDARD GAMEPAD Vendor: 057e Product: 200e)"

This works to get input for HTML5. So it’s only a matter of getting the correct mappings for the L+R. I’ll try to get that working soon. Not sure what Windows needs.

1 Like

Does this show you gyroscope/orientation data for your joycons?

https://gamepad-tester.com/

I think this is a separate API and not part of the gamepad API.

1 Like

Defold doesn’t see joycons on Windows 11 at all / not even with the raw input feature. They may need something special to get them to work on Windows. Some programs like Chrome know how to handle them directly but others like Steam do not. There are programs like XJoy which convert the joycon input into xbox gamepad input so programs which know how to use xbox gamepads will work with joycons, but we want joycons to work directly without extra programs. That also doesn’t solve gyro support either. I did download a Switch emulator (yuzu) and tested its input settings to see what it see and it had no problem handling the joycons (not surprising) and it also could handle the gyro.

HTML5 does work. At least with Chrome this is what the driver needs to be to get the input:

device: "Joy-Con L+R (STANDARD GAMEPAD Vendor: 057e Product: 200e)"

I don’t have a mapping for it ready but I’ll try to get it tomorrow. It’s really cool to be able to use joycons for Defold HTML5 games! But gyro is not supported it seems.

You can also use a single joycon at a time for HTML5. You need another mapping for it (I only tested one side the other may be a slightly different device name / I’ll confirm that tomorrow).

driver {
    device: "Wireless Gamepad (STANDARD GAMEPAD Vendor: 057e Product: 2006)"
    platform: "web"
    dead_zone: 0.200
    map { input: GAMEPAD_LSTICK_LEFT type: GAMEPAD_TYPE_AXIS index: 0 mod { mod: GAMEPAD_MODIFIER_NEGATE } mod { mod: GAMEPAD_MODIFIER_CLAMP } }
    map { input: GAMEPAD_LSTICK_RIGHT type: GAMEPAD_TYPE_AXIS index: 0 mod { mod: GAMEPAD_MODIFIER_CLAMP } }
    map { input: GAMEPAD_LSTICK_DOWN type: GAMEPAD_TYPE_AXIS index: 1 mod { mod: GAMEPAD_MODIFIER_CLAMP } }
    map { input: GAMEPAD_LSTICK_UP type: GAMEPAD_TYPE_AXIS index: 1 mod { mod: GAMEPAD_MODIFIER_NEGATE } mod { mod: GAMEPAD_MODIFIER_CLAMP } }
    map { input: GAMEPAD_LSTICK_CLICK type: GAMEPAD_TYPE_BUTTON index: 10 }
    map { input: GAMEPAD_LSHOULDER type: GAMEPAD_TYPE_BUTTON index: 4 }
    map { input: GAMEPAD_RSHOULDER type: GAMEPAD_TYPE_BUTTON index: 5 }
    map { input: GAMEPAD_RPAD_LEFT type: GAMEPAD_TYPE_BUTTON index: 2 }
    map { input: GAMEPAD_RPAD_RIGHT type: GAMEPAD_TYPE_BUTTON index: 1 }
    map { input: GAMEPAD_RPAD_DOWN type: GAMEPAD_TYPE_BUTTON index: 0 }
    map { input: GAMEPAD_RPAD_UP type: GAMEPAD_TYPE_BUTTON index: 3 }
    map { input: GAMEPAD_START type: GAMEPAD_TYPE_BUTTON index: 16 }
    map { input: GAMEPAD_BACK type: GAMEPAD_TYPE_BUTTON index: 9 }
}

I mentioned in another thread, but gdc doesn’t see the joycons on Windows / gdc crashes when trying to detect the joycons.

(gdc also doesn’t see my PS5 controller / but this is one that Steam can see and use)