Author Topic: Doubt Reg understanding of usb hid mouse  (Read 12889 times)

badri89

  • Member
  • ***
  • Posts: 4
Doubt Reg understanding of usb hid mouse
« on: May 03, 2012, 07:35:28 am »
Hi,
 I am trying to understand how a usb hid mouse works. After going through the hid documentation,still I am not quite clear with some of my doubts. The host is polling (say every 8 ms) the mouse(device). The interrupt is generated by any of the mouse actions(click or move), this is a software interrupt handled by the usb hid driver.is my understanding correct? I understand physical max and min are logical min and max with units applied. The HID descriptor returns only the logical max and min, how to find the physical max and min? Where to read the values of unit??? The values or the coordinates returned by the mouse are absolute values or relative ones, if its relative, wat is the origin, (0,0)? Are they the absolute coordinates or the adc values???That means everytime I read a coordinate value, should I have to average the values and take it as my absolute coordinate? I am not able to get what is specified in usb hid documentation. Please help me out.Thanks

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Doubt Reg understanding of usb hid mouse
« Reply #1 on: May 03, 2012, 11:32:19 am »
The HID driver causes the host PC to poll the mouse periodically. The endpoint returns NAK or data in response to the polls.

If there is no physical max/min, the default is the logical/max/min values.

The Input item in the report descriptor specifies absolute or relative.

http://www.usb.org/developers/hidpage#Class_Definitions

Jan


badri89

  • Member
  • ***
  • Posts: 4
Re: Doubt Reg understanding of usb hid mouse
« Reply #2 on: May 04, 2012, 01:21:57 am »
Thanks for the reply. But from which field of the descriptor I can find the unit, means whenever I move a mouse I will get the X and Y, how to find out what is the unit it has moved?(inch or meter). Because the HID descriptor I am getting consists of the following fields:
Usage Page-   05 01
Usage Mouse- 09 02
Collection(App)-a1 01
Usage(Pointer)-09 01
Collection(Physical)-a1 00
Usage Page(Button)-05 09
Usage Min- 19 01
Usage Max-29 05
Logical Min-15 00
Logical Max-25 01
Report Count-95 05
Report Size-75 01
Input(Data,Variable,Absolute)-81 02
Report Count- 95 00
Input-81 03
Usage Page-05 01
Usage X- 09 30
Usage Y- 09 31
Wheel   - 09 38
Logical Min-15 81
Logical Max-25 7f
Report Size -75 08
Report Count-95 03
Input-81 06

05 0c
0a 38
02 95
01 81
06 c0
c0
 I dont know what are the values after the input field.

This is what I am getting as hid descriptor from my logitech mouse. I understand it is relatve(from 81 06).And in addition to it, I get coordinates(X and Y) and buttons whenever I move or click. But where to get the unit and unit exponent(for finding the resolution and how much the mouse has moved)?? Thanks again
« Last Edit: May 04, 2012, 01:29:14 am by badri89 »

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Doubt Reg understanding of usb hid mouse
« Reply #3 on: May 04, 2012, 08:30:03 am »
The HID Usage Tables document says:

3.3 If Units are set to Optional or set to None (have not been declared) then an application can assume the usage represents a dimensionless value

How far a mouse movement causes a cursor to move on a screen will depend in part on the size of the screen and the user's settings for the mouse.

If you want to know the cursor's position and mouse movements, here is one source of information:

http://www.geekpedia.com/tutorial146_Get-screen-cursor-coordinates.html

Jan

badri89

  • Member
  • ***
  • Posts: 4
Re: Doubt Reg understanding of usb hid mouse
« Reply #4 on: May 05, 2012, 06:35:20 am »
Thank you. But if my understanding is not wrong, I need unit exponent value to calculate my mouse resolution? With usblyzer I monitored my descriptor and there was no unit exponent. How to find the resolution of the mouse?

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research

badri89

  • Member
  • ***
  • Posts: 4
Re: Doubt Reg understanding of usb hid mouse
« Reply #6 on: May 06, 2012, 03:02:53 am »
I have gone through the link you have provided, I could understand how physcial screen dimensions are calculated. What I could not make out is, the X and Y values returned by the mouse (as the descriptors unit,unit exponent and physical max and min are undefined, I used the algorithm given in the HIDdocumentation, so it turned out to be Resolution=(logmax-logmin)/(phymax-phymin)*10^(unit exponent), so my resolution comes as 1 counts per inch, as logical max=physical max(if undefined) and unit exponent =0), being dimensionless, is it the values returned are in mm( or is it something called as mickey as I read an article reg mouse ballistics from microsoft)??How to find out the resolution of a given mouse?Sorry to bother you much!

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Doubt Reg understanding of usb hid mouse
« Reply #7 on: May 06, 2012, 01:24:16 pm »
Using the first link I gave, you can find out the position of the mouse and how far it traveled in pixels.

Using the second link I gave, you can find out the screen size in pixels.

From those values, you can find out how far across the screen the cursor has traveled.

The second link also has some advice on finding the physical size of the screen if you truly need to know the absolute distance or position on the screen.

Jan