2013-07-26 88 views
0

我正在寫一個Linux內核模塊,它將N個實際的/ dev/input/js#設備作爲一個單獨的/ dev/input/js3設備。目前我的模塊正在創建/ dev/input/js3就好了,jstest對它很滿意,但不是真正的應用程序。我猜(strace'd)是這樣的,因爲我的虛擬js3設備沒有匹配的/ dev/input/event#對。我如何從我的模塊創建一個?如何在linux內核模塊中爲虛擬輸入設備(/ dev/input/js3)創建事件#設備?

這裏是我的模塊的源代碼,這可能有無數的問題,但主要工作:https://github.com/iamtakingiteasy/unijoy/blob/master/unijoy.c

回答

0

下面是一個例子,你可以使用

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

+0

你也可以參考http://stackoverflow.com/questions/5970595/create-a-device-node-in-code這是爲了更多的理解 –