Android Question Create mouse emulation with animation

Piperni

Member
Licensed User
Longtime User
Hi, I have started playing around with animation Library. Here is what I am seeking to do: I currently receive the position of a accelerometer , and I am looking to have a white dot moving on my activity based on the absolute position of that sensor. I want to use this as a mouse, I have tried to use the mouse diectely thorugh HID but all I could do with the mouse is have relative movements, I need absolute.

The accelerometer sensor would be installed on the head. So right now I receive the X and Y position of the sensor thorugh a serial BT link from an arduino, and I would like the dot move to the absolute X,Y coordinate in real time, the quickest possible. As if you were pointing on the screen with a laser pointer.

In addition to that, I would like to be able to detect that the dot is above one of the button views of my activity, because when it hovers over it I would have it click automatically that view.

My question: what is the best efficient way to do this? A translate animation? or simply change the position of the white dot view to new coordinates (adjusting the .top parameter of the view), or should I consider using anything else ? My biggest concern is the execution time so that the 'mouse' doesnt lag to much when the head moves.

Thanks !
 

Piperni

Member
Licensed User
Longtime User
Thank you both for your inputs, Ill go with that for now and see how it goes.
Hi guys, I have successfully developed my "mouse", it actually works better than I thought and moves very smoothly with my accelerometer. However, the problem remains to be able to actually click buttons when the mouse hovers over it. For now I am simply thinking of detecting whether the coordinates of the pointer are within the ranges of my buttons. Can anyone think of any simpler method? My mouse pointer is simply a small round button view. Thanks
 
Upvote 0

KMatle

Expert
Licensed User
Longtime User
I think it's easier to handle it on your own by checking if the pointer is inside a view (due to the limited amount of views related). You will to have to check, if there's a mouse click so it's easy to call f.e. Button1_Click or Setfocus on Edittextxxx.
 
Upvote 0
Top