Libgdx getting mouse position in android - java

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.

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

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

Related

What hovering means on button in Android?

I know that we can catch Hovering event in Android. So, I added a Button in my layout files.
What does Hovering mean in Android ?
Press button and lifting finder from it?
Put your finger on button (Impossible in Android). We can do it by connecting mouse through OTP cable. But why would a developer implement it?
Also, on Android TV, it makes a lot of sense to Hover over an element, especially if it is supporting mouse pointer movement using TV remote
There are devices which supports 'Air Gesture' and hovering can be used for that. Check this:
https://play.google.com/store/apps/details?id=com.golgorz.hoveringcontrols&hl=en
IN some of the popular smart phone there is a way to dismiss call by just hovering the hand over the screen.
We can do it by connecting mouse through OTP cable. But why would a developer implement it?
The popularity of android id not limited to mobile devices alone there is TV,auto, variables etc. so with most of the tv you have universal remote which come with trackball also this is also used there .

Is this possible with libgdx?

I'm trying to develop an Android app for my own project. I was wondering if it is possible to develop such an app using libGDX, and if not, what do I need to learn to code this? (My only experience with Android app development is through libGDX for some simple games).
I would like to make an app that displays a story beautifully. (Think text rpg, but a poem instead or short story). The user will press a button for the story/poem to advance. (Think powerpoint) There will be a simple gradient background. (The gradient needs to be able to fade to different colours) And the text should fade in and out as well.
I'll need tight control over the audio. Ideally there will be a voiceover that syncs to when the text fades in. Some parts will have sound effects, or when the user reaches the end of a paragraph, the current bgm will fade out (regardless of whether or not the song is finished), and when the user press continue to the next paragraph, a new, different bgm will fade in.
I would just like to know if it is possible to make this app through libGDX. If it is, I'll continue to learn from tutorials. Or else I'll learn whatever is necessary to accomplish this.
In a word, yes.
If you have earlier LibGDX experience, it would be fairly easy to do in LibGDX.
The references required for features that you enumerated are
Drawing a gradient in Libgdx
Streaming music
Sound effects
Actions for fade effects
Hope this helps.
Good luck.

How to render mouse movement in android tablet

I have one linux laptop and one android tablet. I want to show my mouse movement in my android tablet that is i will move mouse in linux laptop and that movement will be shown on android tablet.Will libgdx will work for this??Is their any good study material or sample program to start ?
There was a Libgdx Remote project, but that went in the other direction (pushing Android sensor data to your desktop so you can debug tilt code on your desktop). However, I believe that's been deprecated in the most recent builds.
The remnants of that project are the RemoteInput
and RemoteSender classes. You may be able to adapt those for your case (setting up your Android device to be a network listener may be more work than forwarding mouse events).
This approach may be much lower-level than what you want (you may just want to get mouse coordinates from your laptop and map them directly to drawing something on the screen -- and not inject low-level events).

libGDX Causing Multitouch Problems

I am working on a game with a virtual joystick in the bottom right corner of the screen and a "move" button in the bottom left. So you use the joystick to point the character in the right direction and press the "move" button to go forward in that direction. This was all working great until today and now when I press on the screen to go forward my joystick is being affected. I know it is not a coding problem because I haven't opened the file that handles touches for 8 days and it has been working fine. Also after I close my app and then use another app that is completely separate from libGDX the multitouch is having the same issue. So do you guys think this is a problem with libGDX, my device, or am I just not coding the multitouch correctly for libGDX? I am using a Stage and the controls are Actors on the Stage I should note that after I restart my phone, the other app that is not using libGDX works correctly. It is only after I open my libGDX based game. So frustrated with this that I am about to give up on libGDX. I am happy to post any code that is requested.
EDIT: Please see comments below. This seems to be a specific issue with the Galaxy Nexus and probably some other Samsung devices as well. This libGDX based app has had no issues on other devices such as original droid, and ASUS Transformer tablet.
Turns out this is not a libGDX problem at all... Nor was it a problem with any of my code. There seems to be a bug in the way the Galaxy Nexus handles multitouch. You can view the bug report at this link. Seems that as of 4.0.4 there still is no fix for this bug. I am still currently running a VZW Galaxy Nexus with 4.0.2, I guess all we can do is wait and put a disclaimer in our games until (if ever) it is fixed.
By locking and unlocking the device, the problem does go away (sometimes), but will quickly come back if I go to my homescreen and re-open the app.

Accessing hardware buttons within the camera app

i wish to write a plugin that will enable me to access hardware buttons of the phone while using the camera app. how would i go about doing this. or is it even possible.
Sorry, you can't generally do this. There are some keys that applications can respond to while in the background (specifically the media play/pause/etc buttons) but it is not generally possible to process key events while another app has focus.
Your best best is to check the Camera source but you might consider making your own app based on Camera.

Categories

Resources