indigo icon indicating copy to clipboard operation
indigo copied to clipboard

Support DualSense (PS5 controller) as a gamepad

Open kubukoz opened this issue 1 year ago • 7 comments

I tried using a DualSense for the Pirate game demo, and to my surprise it doesn't seem to work.

I see this in the console:

image

According to the mapping, 14 is 14 D Left, which I suppose is the left arrow on the D-pad... which seems to be an axis in the DualSense layout:

MDN's demo

image

It would be great to support this gamepad as well :)

kubukoz avatar May 21 '23 17:05 kubukoz

My guess is that, to properly handle this, GamepadInputCaptureImpl will have to dispatch to a device-specific mapping, and someone with a controller will have to implement that layout for DualSense. Happy to give it a go sometime :)

kubukoz avatar May 21 '23 17:05 kubukoz

Just to echo what I said on Discord: Any and all assistance welcome here if you're interested in having a go!

I implemented PS4 gamepad support a long time ago and very quickly, and haven't revisited it since. It wouldn't surprised me if it needed a bit of a rethink!

Thanks for raising the issue.

davesmith00000 avatar May 21 '23 18:05 davesmith00000

OK, it's even funnier: this is only on Firefox. The d-pad is actually represented as buttons in Chrome. It still doesn't work in your demo, but apparently for another reason.

I... don't like this very much.

kubukoz avatar May 21 '23 22:05 kubukoz

Frontend dev is always... exciting. Accounting for how different hardware / browsers / platforms works, getting a bit creative with how to support things. :smile:

One thing we're been discussing, is for Indigo to become a Tyrian App: https://github.com/PurpleKingdomGames/indigo/issues/506

If we do that, all the work around interacting with the browser / world (websockets, frameticks, gamepads...) becomes a Tyrian problem. There's actually nothing preventing this from happening right now as embedding Indigo into Tyrian is really easy.

Might be worth making something similar to https://luser.github.io/gamepadtest/ in Tyrian and seeing how it looks. Also has the benefit of not needing to conform to the existing Indigo implementation.

Just an idea, maybe it'll go nowhere, but it could be interesting. :shrug:

davesmith00000 avatar May 22 '23 07:05 davesmith00000

There's an example of an Indigo game inside a Tyrian App here, just if you're interested: https://github.com/PurpleKingdomGames/tyrian/blob/main/examples/indigo/src/main/scala/example/Main.scala

davesmith00000 avatar May 22 '23 07:05 davesmith00000

That surely seems interesting. I suppose we'd still want the button mappings to live in Indigo or a helper library, and Tyrian would only deal with the DOM nonsense... either way, I like the idea of a gamepadtest in Tyrian. Might pick this up some time.

kubukoz avatar May 22 '23 13:05 kubukoz

I like the idea of a gamepadtest in Tyrian

Yeah so do I. Be good to see it working and then worry about the other details like who owns the config and so on. Let me know if you have a go. :+1:

davesmith00000 avatar May 22 '23 19:05 davesmith00000