Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gamepad support? #34

Open
ghost opened this issue May 27, 2014 · 12 comments
Open

gamepad support? #34

ghost opened this issue May 27, 2014 · 12 comments

Comments

@ghost
Copy link

ghost commented May 27, 2014

Is gamepad support planned for playn?

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

@samskivert
Copy link
Member

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

@ghost
Copy link
Author

ghost commented May 28, 2014

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
Copy link
Author

ghost commented May 28, 2014

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

@ghost
Copy link
Author

ghost commented May 28, 2014

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
Copy link
Member

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
Copy link
Member

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
Copy link
Author

ghost commented May 31, 2014

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:

  • lwjgl API has usefull accessors (getXAxis, getYAxis, getPovX..), but there is no way to tell which axis is X, Y...
  • html5 API has only recommandations that 0/1 axis should be x/y, but on my gamepad, 0/1 is the right analog stick...

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
Copy link
Member

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
Copy link
Author

ghost commented Jun 4, 2014

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
Copy link
Member

Sounds good!

@ghost
Copy link
Author

ghost commented Sep 19, 2014

Any news on this one?

@ghost
Copy link
Author

ghost commented Oct 11, 2014

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant