Re: how to map USB MOUSE EVENT in device driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 1/31/06, mayank rana <mayank_rana_it@xxxxxxxxxxx> wrote:
Hi to all
 I am writing device driver for USB mouse. Now I'm facing one problem : how to map USB mouse button events in driver ?
In probe function I'm registering input device and related key or button events using set_bit( ) function. And in IRQ call I'm mapping mouse button events to particular bits using
input_report_key(dev, BTN_LEFT,   !!(data[2]&0x01));
NOW can anyone tell me which value I should provide as last argument in above function. When I am using different values , Kernel is going to hang. I searched  some information, but not available.
please tell me how to know particular interrupt event for USB mouse and how to map that events using above to functions.
tnx in advance.
regards,
_-_mayank rana_-_
 
 
 
 


Yahoo! Mail
Use Photomail to share photos without annoying attachments.

 
 
hi Rana,
              This is the code some where i got from net...pls someone explain it...
 
 
static void *mouseprobe(struct usb_device *udev,unsigned int
interfaceno,const struct usb_device_id *id)
{
struct usb_interface *iface;
struct usb_interface_descriptor *interface;
struct usb_endpoint_descriptor *endpoint;
struct usb_mouse *mouse;
int pipe,maxp;
iface=&udev->actconfig->interface[interfaceno];
interface=&iface->altsetting[iface->act_altsetting];
if(interface->bNumEndpoints!=1)
return NULL;
endpoint=interface->endpoint+0;
if(!(endpoint->bEndpointAddress & 0x80))
return NULL;
if((endpoint->bmAttributes & 3)!=3)
return NULL;
if(udev->descriptor.idVendor == 0x056a)
return NULL;
pipe=usb_rcvintpipe(udev,endpoint->bEndpointAddress);
maxp=usb_maxpacket(udev,pipe,usb_pipeout(pipe));
mouse=kmalloc(sizeof(struct usb_mouse),GFP_KERNEL);
if(!mouse)
return NULL;
memset(mouse,0,sizeof(*mouse));
mouse->usbmouse=udev;
mouse->idev.evbit[0]=BIT(EV_KEY) | BIT(EV_REL);
mouse->idev.keybit[LONG(BTN_MOUSE)]=BIT(BTN_LEFT) | BIT(BTN_RIGHT) |
BIT(BTN_MIDDLE) | BIT(BTN_SIDE) | BIT(BTN_EXTRA);
mouse-> idev.relbit[0]=BIT(REL_X) | BIT(REL_Y) | BIT(REL_WHEEL);
mouse->idev.private=mouse;
//mouse->idev.open=
//mouse->idev.close=
//mouse->idev.name=mouse->
mouse->idev.idvendor=udev->descriptor.idVendor ;
mouse->idev.idproduct=udev->descriptor.idProduct;
mouse->idev.idversion=udev->descriptor.bcdDevice;
if(maxp>8)
maxp=8;

FILL_INT_URB(&mouse->ur,udev,pipe,mouse->data,maxp,usb_mouse_irq,mouse,endpoint->bInterval);
if(usb_submit_urb(&mouse->ur))
{
kfree(mouse);
return NULL;
}
//info("in the probe");
input_register_device(&mouse->idev);
return mouse;
}
 
you can click if you need the full usb mouse DD that i got...
 
http://geocities.com/jashtech/usb-drv.zip
 


 

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux