ネイティブコードでAInputQueueにディスパッチされる前に、NativeActivityの入力をインターセプトする方法はありますか?android/input.h
Javaで入力をインターセプトする必要がある理由は、どの関数を使用してもキャプチャできないゲームパッド/ジョイスティックイベントをサポートするためです。MotionEvent.getAxisValue(MotionEvent.AXIS_RZ)
。
以下は機能しません(私のマニフェストは派生したNativeActivityクラスを正しく指します):
public class CustomNativeActivity extends NativeActivity
{
private View.OnTouchListener touchListener = new View.OnTouchListener() {
public boolean onTouch (View v, MotionEvent event)
{
// This is never called!
System.out.println("onTouch");
return false;
}
};
public void setContentView(View view)
{
// This method is called, but registering a touch listener does nothing!
view.setOnTouchListener(touchListener);
super.setContentView(view);
}
public boolean dispatchTouchEvent(MotionEvent ev)
{
// This is never called either!
System.out.println("dispatchTouchEvent!");
return super.dispatchTouchEvent(ev);
}
}