c/c++语言开发共享Android NativeActivity – 拦截Java级别的输入

有没有办法在NativeActivity中将输入拦截到本机代码中的AInputQueue之前? 我需要在Java中拦截输入的原因是支持我无法使用任何android/input.h函数捕获的游戏手柄/操纵杆事件,即。 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); } } 

      以上就是c/c++开发分享Android NativeActivity – 拦截Java级别的输入相关内容,想了解更多C/C++开发(异常处理)及C/C++游戏开发关注计算机技术网(www.ctvol.com)!)。

      本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

      ctvol管理联系方式QQ:251552304

      本文章地址:https://www.ctvol.com/c-cdevelopment/522519.html

      (0)
      上一篇 2020年12月10日
      下一篇 2020年12月10日

      精彩推荐