Logitech k400 with touch pad : mouse position.

Monkey Targets Forums/Android/Logitech k400 with touch pad : mouse position.

hub(Posted 2015) [#1]
I'm searching a way to detect the mouse x,y position when i use my coordless Logitech Keyboard connected to my android device.

i see the pointer cursor on the screen. It is too small for use on the tv with old person. So i want display a big image as pointer (an hide the system pointer)

TouchX, TouchY or MouseX, MouseY return the position only when i 'click' with the touchpad buttons, not when they are released. Any idea ?

Thanks !


therevills(Posted 2015) [#2]
Looks like Mojo doesnt support this out of the box and it may be a bit of a pain adding it via externs, you may need to ask Mark directly to implement this.

From what I can find you need to use the interface OnGenericMotionListener on the main activity and then you can poll the mouse events using a MotionEvent.

From an extern you "may" be able to attach the GenericMotionListener:
UNTESTED:
BBAndroidGame._androidGame._view.setOnGenericMotionListener(new OnGenericMotionListener() {
       public boolean onGenericMotion(View v, MotionEvent event) {
         return false;
       });     
    }


And add code within onGenericMotion to capture the mouse x and y from the MotionEvent.

Good Luck!


hub(Posted 2015) [#3]
Hope Mark could add this or reply here. It's a pain for me to understand java !

I'm trying to add your code to my 'hub' class to return an x,y mouse coordonates. But i've a lot of difficulties to understand what i'm doing. Java errors messages or code structure seems to me a nightmare to debug !

Hope find a way to do this. The mouse pointer is very small on a tv screen.. At work, with Monkey magic help, my appli is very interesting for the very old persons..But they can't see the mouse pointer and they have some difficulties to choose their music track or click on my game 'memory' cards.

Many thanks Therevills for all your help. You always have a reply and save my appli !


hub(Posted 2015) [#4]


you can see the small mouse pointer on this tv screen screenshoot. I'm trying to replace it with the big 'hand image' but i must _click_ to have the mouse position and then put my image at the pointer position.

i'm sure Mark could help me.


therevills(Posted 2015) [#5]
I tried for a couple of hours last night to get this to work, but I couldnt figure it out.

I created another Java method called "initGenericMotion":
static void initGenericMotion() {
	bb_std_lang.print("initGenericMotion!!!");
	BBAndroidGame._androidGame._view.setOnGenericMotionListener(new OnGenericMotionListener() {
		public boolean onGenericMotion(View v, MotionEvent event) {
			final int pointerCount = event.getPointerCount();
			for (int p = 0; p < pointerCount; p++) {
				bb_std_lang.print("  pointer "+event.getPointerId(p)+": "+event.getX(p)+", "+event.getY(p));
			}
			return false;
		}
	});
}


And call it within Monkey.... but I never see the trace statements from the anonymous inner class (OnGenericMotionListener).

Could you try it?


hub(Posted 2015) [#6]
Thanks, what is the 'import android.something' to add into the java file ?


hub(Posted 2015) [#7]
import android.view.View.OnGenericMotionListener;

(http://developer.android.com/reference/android/view/View.OnGenericMotionListener.html)


hub(Posted 2015) [#8]
i've this


Cool, next how to read / have the values inside my code ?
i'm searchiing. i use the initial diddy java to find how to do.


hub(Posted 2015) [#9]
Ok. All works fine here ! But it is not possible to hide the mouse pointer with android sdk. This is not a problem for my appli.

Ton of thanks for Therevills.


hub(Posted 2015) [#10]


ehpad_borne_java.java



therevills(Posted 2015) [#11]
Excellent glad it worked! (Sorry about missing the import, I had it in my code, but forgot about it in my post!)

And well done on reading the inputs, you have done what I would have done if it had worked for me.

Just be aware that the joypad support may be lost overwriting the GenericMotionListener.


therevills(Posted 2015) [#12]
Oh BTW only call initGenericMotion once, either in Monkey's OnCreate or use a boolean to set it, no need to keep calling it per loop.


hub(Posted 2015) [#13]
I've updated my app code. (InitGenericMotion inside the OnCreate). Thanks.