tags:

views:

524

answers:

2

Hi all,

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

A: 

Thanks for your response

No I am not using X!!, as x server will NOT be available in the deployment of the system

Regards

Madni
:) This answer should maybe be a comment below my answer ...
Aiden Bell
A: 

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 level Get 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(struct hid _ 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

Madni