跟踪从驱动程序到应用程序的输入/事件流

发布于 2024-10-05 13:21:01 字数 662 浏览 5 评论 0原文

我正在为自定义输入硬件创建一个驱动程序,该驱动程序将尝试将数据作为输入传递到内核,然后内核将通过操作系统向上传递该数据并通过 MotionEvent 向应用程序级别公开。看看其他一些设备驱动程序,看起来通过 Android 2.2 内核 (2.6.32) 的 input.h 中公开的一些函数设置输入事件可能会成功,但我很想确认这一点。在开始这条道路之前,我试图更好地了解现有的输入(无论是来自屏幕、轨迹球等)如何通过操作系统传递。最终目标是确保我们可以将数据从设备传递到应用程序级别,然后再投入太多时间走这条路。

linux内核2.6.32的输入头

http://lxr.free-electrons.com/source/include/linux/input.h?v=2.6.32

我浏览过 Android 类源代码,但不确定在哪里查看操作系统如何实例化可通过 View 类的 onTouchEvent() 方法访问的 MotionEvent 类。任何人都可以为我指明操作系统如何填充 MotionEvent 以及操作系统如何从内核获取该数据的正确方向吗?

谢谢,

保罗

I am creating a driver for a custom piece of input hardware that will attempt to pass data to the kernel as an input, which the kernel will then pass up through the OS and expose to the app level via MotionEvent. Looking at some other device drivers, it looks like setting input events via some of the functions exposed in input.h of the Android 2.2 kernel (2.6.32) might do the trick, but I'd love to confirm this. Before starting down this path I am trying to get a better understanding of how existing inputs, be it from the screen, trackball, etc are passed up through the OS. The ultimate goal is to ensure that we can pass data from device to App-level before investing too much time going down this path.

Input header of linux kernel 2.6.32

http://lxr.free-electrons.com/source/include/linux/input.h?v=2.6.32

I've browsed through the Android class sources, but not sure where to look to see how the OS instatiates the MotionEvent class that can be accessed via the onTouchEvent() method of the View class. Can anyone point me in the right direction in terms of how MotionEvent is populated by the OS and how the OS gets that data from the kernel?

Thanks,

Paul

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

救赎№ 2024-10-12 13:21:01

我首先要在frameworks/base/libs/ui/EventHub.cpp中查看,它将通过/dev/input来查找平台上的不同输入设备以及这些输入的“类型”。

更多...

下一步位于frameworks/base/services/jni/com_android_server_KeyInputQueue.cpp 和frameworks/base/services/java/com/android/server/KeyInputQueue.java 中。

如果您所做的只是实现新硬件的输入接口,那么我认为您不需要做更多的事情......

The first place I would look at in in frameworks/base/libs/ui/EventHub.cpp, it will go through /dev/input to find the different input devices on your platform and what "kind" of input those are.

More...

Next step is in frameworks/base/services/jni/com_android_server_KeyInputQueue.cpp and frameworks/base/services/java/com/android/server/KeyInputQueue.java.

If all you are doing is implementing the input interface for a new piece of hardware, I don't think you need to do any further than that...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文