本文介绍了HID鼠标位置Linux内核源代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述



我应该使用哪个linux内核模块来处理这些事件?然后将这些事件(x,y)传递给输入子系统。

模块可以是

$ ul $ b

  • hid-core.c / usbhid


  • hid-quirks.c或

  • b
  • hiddev.c




  • 我拥有所有的内核源代码,我的内核。



    输出:lsmod | grep hid

    myusbhid ------------------ 35712 ---------- 0 p>

    hid ------------------ 50560 ----------- 1 myusbhid



    usbcore ------------------- 149488 ----------- 4 myusbhid,uhci_hcd,ehci_hcd



    原因是,我试图修改我的HID鼠标坐标,意思是我希望我的光标位置在我提到的位置移动,而不是默认的鼠标位置。

    谢谢

    解决方案

    版本,但现在被分割成多个文件

    HID键盘/鼠标/游戏杆事件可以在内核级监视/更改
    获取内核源文件你的内核版本。





    用于HID(hid.o)linux内核MODU le,将源文件重命名为

      my-hiddraw.c 
    *

    我的-hid-core.c
    *

    my-hid-input.c
    *

    my-hid -input-quirk.c

    Makefile: b

    obj-m:= myhid.o

    myhid-objs:= my-hiddraw.o my-hid-core.o my- hid-input.o my-hid-input-quirk.o

    KDIR:= / lib / modules / $(shell uname -r)/ build


    $ b

    PWD:= $(shell pwd)

    默认值:

    $(MAKE)-C $(KDIR)M = $(PWD)modules

    strong>



    $ sudo rmmod usbhid; sudo rmmod hid; sudo insmod myhid.ko; sudo insmod / [MODULE PATH] /usbhid.ko



    ************************ ************************************************** * b
    $ b hid-input.c可以将事件发送到输入子系统/ hiddev.c。



    有关参考资料,请参阅Linux hiddev.txt和input.txt。在hid-input.c中,hidinput _ hid _ event()负责发送事件


    • void hidinput _ hid _ event(struct
      hid _ device * hid,struct hid _ field
      *结构hid_usage *用法,__s32值)


    在输入_事件(输入,用法 - >类型,用法 - > code,value);

    printk(\ n hidinput _ hid _ event%i,%i,%i,usage-> type,usage- > code,value);

    获取/修改这些值并将其传递给输入_事件()



    ************************************************** *************************

    问候

    mmadni [AT] gmail [DOT] com

    I want to work on HID Mouse events.

    Which linux kernel module shall I work on to handle the events? And then pass those events (x,y) to input subsystem.

    The modules can be

    • hid-core.c / usbhid

    • hid-quirks.c or

    • hiddev.c

    I have all the kernel source code and am able to add in my kernel.

    Output: lsmod | grep hid

    myusbhid ------------------ 35712 ----------0

    hid ------------------ 50560 -----------1 myusbhid

    usbcore -------------------149488 -----------4 myusbhid,uhci_hcd,ehci_hcd

    Reason is, I am trying to modify my HID Mouse coordinates, means I want my cursor location to move in my mentiond position not as a default mouse locations.

    Thanks

    解决方案

    The hid.c was available in kernel 2.4.9 and older versions, but is now splited in multiple files

    The HID keyboard / mouse/ joysticks events can be monitored / change at kernel levelGet the kernel source file of your kernel version.

    http://lxr.linux.no/linux+v2.6.27.14/drivers/

    for HID (hid.o) linux kernel module, rename the source files as

      my-hiddraw.c
    *
    
      my-hid-core.c
    *
    
      my-hid-input.c
    *
    
      my-hid-input-quirk.c
    

    Makefile:

    obj-m := myhid.o

    myhid-objs := my-hiddraw.o my-hid-core.o my-hid-input.o my-hid-input-quirk.o

    KDIR := /lib/modules/$(shell uname -r)/build

    PWD := $(shell pwd)

    default:

    $(MAKE) -C $(KDIR) M=$(PWD) modules

    Add module in kernel as

    $ sudo rmmod usbhid; sudo rmmod hid; sudo insmod myhid.ko; sudo insmod /[MODULE PATH]/usbhid.ko

    ***************************************************************************

    The hid-input.c is responsiable to send the events to input subsystem / hiddev.c

    For reference look at the documentation Linux hiddev.txt and input.txt

    In hid-input.c the hidinput _ hid _ event () is responsiable to send the events

    • void hidinput _ hid _ event(structhid _ device *hid, struct hid _ field*field, struct hid_usage *usage, __s32 value)

    Use at the end of function before input _ event (input, usage->type, usage->code, value);

    printk("\n hidinput _ hid _ event %i, %i, %i",usage->type, usage->code, value);

    Get/Modify those values and pass it to input _ events ()

    ***************************************************************************

    Regards

    mmadni[AT]gmail[DOT]com

    这篇关于HID鼠标位置Linux内核源代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

    08-02 03:02