I'm trying to capture touchpad data from within an IME on google glass. Following roughly the example given in the GDK docs, I've added the following to my top level view for my IME.
However none of these methods are ever triggered, so I don't get any touchpad data. In the meantime the activity (immersion) that I am in continues to get data from both dispatchGenericMotionEvent() and onGenericMotionEvent()
Any thoughts on why I can't access this data in the IME? I can get onKeyDown events within the InputMethodService no problem, but they don't give me access to all the touchpad gestures/controls I would like to use. InputMethodService also has a onGenericMotionEvent() method, but only API level 17 which is not helpful for glass which is API level 15 only.
public class TopLevelView extends LinearLayout {
public TopLevelView(Context context, AttributeSet attrs) {
super(context, attrs);
setFocusable(true);
setFocusableInTouchMode(true);
}
public TopLevelView(Context context) {
this(context, null);
}
@Override
public void onAttachedToWindow() {
requestFocus(); //returns true, isFocused() also returns true
}
@Override
protected void onDetachedFromWindow() {
}
/* Methods I normally get touch pad data from in a regular activity/view */
public boolean dispatchGenericMotionEvent(MotionEvent event) {
Log.d("TopLevelView", "dispatchGenericMotionEvent");
return super.dispatchGenericMotionEvent(event);
}
public boolean onGenericMotionEvent(MotionEvent event) {
Log.d("TopLevelView", "onGenericMotionEvent");
return super.onGenericMotionEvent(event);
}
public boolean dispatchGenericFocusedEvent(MotionEvent event) {
Log.d("TopLevelView", "dispatchGenericFocusedEvent");
return super.dispatchGenericFocusedEvent(event);
}
/* The kitchen sink */
public boolean onTouchEvent(MotionEvent e) {
Log.d("TopLevelView", "onTouch");
return false;
}
public boolean dispatchTouchEvent(MotionEvent event) {
Log.d("TopLevelView", "dispatchTouchEvent");
return false;
}
public boolean onHoverEvent(MotionEvent event) {
Log.d("TopLevelView", "onHoverEvent");
return false;
}
public boolean onTrackballEvent(MotionEvent event) {
Log.d("TopLevelView", "onTrackballEvent");
return false;
}
public boolean dispatchGenericPointerEvent(MotionEvent event) {
Log.d("TopLevelView", "dispatchGenericPointerEvent");
return false;
}
public boolean dispatchHoverEvent(MotionEvent event) {
Log.d("TopLevelView", "dispatchHoverEvent");
return false;
}
public boolean dispatchTrackballEvent(MotionEvent event) {
Log.d("TopLevelView", "dispatchTrackballEvent");
return false;
}
public boolean dispatchUnhandledMove(View focused, int direction) {
Log.d("TopLevelView", "dispatchUnhandledMove");
return false;
}
public boolean onFilterTouchEventForSecurity(MotionEvent event) {
Log.d("TopLevelView", "onFilterTouchEventForSecurity");
return false;
}
}