【问题标题】:How to create an event# device for a virtual input device (/dev/input/js3) in linux kernel module?如何在 linux 内核模块中为虚拟输入设备(/dev/input/js3)创建事件#设备?
【发布时间】:2013-07-27 05:34:40
【问题描述】:

我正在编写一个 linux 内核模块,它采用 N 个真实的 /dev/input/js# 设备并将它们代理为单个 /dev/input/js3 设备。目前我的模块正在创建 /dev/input/js3 就好了,jstest 对它很满意,但不是真正的应用程序。我猜(strace'd)之所以如此,是因为我的虚拟 js3 设备没有匹配的 /dev/input/event# 对。如何从我的模块创建一个?

这是我的模块的源代码,它可能有很多问题,但大部分都在工作:https://github.com/iamtakingiteasy/unijoy/blob/master/unijoy.c

【问题讨论】:

    标签: linux input linux-kernel kernel-module joystick


    【解决方案1】:

    这里是一个例子,你可以使用

    1. class_create to create the class specified for the device,
    2. device_create to create the device node
    3. cdev_init to initialize and 
    4. cdev_add to add the device to the /dev list
    

    例如您可以参考以下链接:Create a device node in kernel module

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-06
    • 1970-01-01
    • 2020-07-27
    相关资源
    最近更新 更多