Reputation: 367
I have a game that's running on ouya. I want to make a game object follow the cursor, but mouseMoved() only gets called in the desktop version of libgdx. Similarly, Gdx.input.getX() and getY() only update when the mouse is clicked (ouya touchpad tapped).
badlogic recommends using their controller api over the official ouya one for various reasons, and it works perfectly with everything else. Is there a way for libgdx to return the cursor position in android? I really want to avoid rewriting all my other controls when the libgdx controller extension works in every other aspect and supports multiple controllers. Thanks.
Upvotes: 1
Views: 1072
Reputation: 174
I know it's been a while and you probably figured out how to do it, but I just wanted to let you know that I've submitted a patch to libGDX that allows for mouse tracking in the same way you do it on the desktop.
It's now done natively, starting with libGDX 1.4.1
Upvotes: 0
Reputation: 3183
You might want to try a non-OUYA approach. I can plug a USB mouse and keyboard into my phone using a USB adapter and I can pair a bluetooth mouse with my phone too. In fact you have to do this with a lot those HDMI android pc on a stick things. A mouse should cause all the touch events you normally detect in LibGDX but I think the OUYA touchpad functions a mouse so if you want to track it like a regular mouse you should be able to.
If you look at how the Android backend and PC backend are implemented you'll see that getX
and similar query the mouse on PC but return the last stored touch location on android. But starting in Honeycomb you can get the cursor position with View.OnGenericMotionListener
(see Android: Tracking mouse pointer movement).
So you can add in some android specific (but not OUYA specific) code to track the cursor position. Oh, and Android 4 added even more mouse related support - https://developer.android.com/about/versions/android-4.0.html
Upvotes: 1