Reputation: 908
I checked the Google Glass GDK, Mirror API and documentation on gestures.
A tap is detected as KeyEvent.KEYCODE_DPAD_CENTER
Is there any way to determine the position of the tap on the track pad?
Thank you.
Upvotes: 0
Views: 194
Reputation: 1019
You will need to subclass the Glass GestureDetector and override onMotionEvent(MotionEvent event) to capture the X_AXIS information. X increases as you tap closer to the front. 1000 is about at the front and 200 is towards the back.
package foo;
import android.content.Context;
import android.view.MotionEvent;
import com.google.android.glass.touchpad.GestureDetector;
public class CustomGestureDetector extends GestureDetector {
public CustomGestureDetector(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
@Override
public boolean onMotionEvent(MotionEvent event) {
// TODO Auto-generated method stub
System.out.println(String.format("X: %.2f Y: %.2f", event.getAxisValue(MotionEvent.AXIS_X), event.getAxisValue(MotionEvent.AXIS_Y)));
return super.onMotionEvent(event);
}
}
Upvotes: 3