threerings / playn

Legacy 1.x version of PlayN library.
http://playn.io/
Apache License 2.0
194 stars 66 forks source link

gamepad support? #34

Open ghost opened 10 years ago

ghost commented 10 years ago

Is gamepad support planned for playn?

I can propose an API and work on java and html implementation...

samskivert commented 10 years ago

Nothing planned. By all means feel free to put together a pull request.

ghost commented 10 years ago

Ok! I'll start to specify interfaces based on html5 gamepad API and lwjgl Controller* classes.

I saw that a google CLA notice in CONTRIBUTORS file. Is it still needed since Threerings took over playn development and it looks like google is not involved anymore?

Should I signed a CLA for Threerings? Just add my name to CONTRIBUTORS? Use a very liberal license (MIT?) that allows sublicensing and let you use whatever you want?

ghost commented 10 years ago

I started the API specs and lwjgl based implementation last night: https://github.com/devnewton/playn/commit/1f5605f6b5fd52e17d410bba81d998086d497cae

ghost commented 10 years ago

I made the lwjgl/jinput based gamepad support work.

I started html implementation, but gwt compiler put a lot of "null.nullMethod();" instead of methods calls. I cannot figure why...

samskivert commented 10 years ago

The general API looks reasonably as does the LWJGL implementation. I'm curious as to how dual axis controllers are exposed via this API. Is 0,1 up/down left/right for the first analog stick and then 2,3 up/down left/right for the second? It would be nice to be a bit more explicit about that, particularly if different backends make different assumptions.

Also, you should not use Java logging in the JavaGamepads init method. Just have JavaGamepads take a JavaPlatform instance (and save it), and use platform.log().warn(...) to issue the warning.

samskivert commented 10 years ago

Re: null.nullMethod(): that usually happens when GWT can prove that something will always be null, so you are probably failing to initialize a field somewhere or something.

ghost commented 10 years ago

I'm curious as to how dual axis controllers are exposed via this API. Is 0,1 up/down left/right for the first analog stick and then 2,3 up/down left/right for the second?

I have trouble to find a portable way to do this:

I also encountered a lot of html5 API problems (no way to retrieves dead zones, on Chrome default axis values are -1, something the gamepad array list contains undefined items...).

I'll remove the Java logging uses and prepare a cleaner pull request soon.

samskivert commented 10 years ago

Ugh, sounds like a mess. I'm a little wary of providing a cross-platform API for game pads when we're not actually able to provide consistent behavior across platforms. If each platform is so full of idiosyncrasies that one has to test on all platforms they plan to support and hack in workarounds to the different types of behavior, I'd rather not provide a cross-platform API and have developers just access the native APIs in their bootstrap code because then they are forced to read the underlying platform documentation, see how it works and test what they are using.

If they're going to have to do that anyway, I'd rather save them the frustration of first writing code against an API that is either totally vague or lies to them about how it behaves, and then discover that it doesn't do what they expect and they have to test on all platforms and hack in workarounds.

ghost commented 10 years ago

We can split Gamepad support in the following issues:

  1. retrieve gamepad list, get axis and buttons states.
  2. retrieve dead zones.
  3. provides way to find a good default input mapping.

With lwjgl controller API, html5 gamepad API and from what I've read about Android and iOS controller API, it is possible to provides a cross platform API for 1.

For 2 & 3 features some platform provides needed data, some don't. We can just do nothing or expose them as optional features (like sync i/o operations in Assets playn interface).

1 is enough to add gamepad input to a game configurable in "options menu". I think this will please 99% players.

samskivert commented 10 years ago

Sounds good!

ghost commented 10 years ago

Any news on this one?

ghost commented 9 years ago

Hello samskivert,

I saw that you talked about my pull request on the playn google group. I'm replying here, because I don't have a google account.

There is a pending pull request for gamepad support, but I'm still not thrilled by the state of gamepad support across platforms. The pull request just sort of glosses over the fact that the behavior of gamepads for HTML5 and gamepads for LWJGL are wildly incompatible

What do you mean? What is incompatible? Both API provide ways to enumerate gamepads and query button and axis states.

(Libgdx is doing the same kind of abstraction between desktop, android and html5 controller API).