blog.world3.net

USB HID descriptors and Windows

While working on my USB/PSX joystick controller project I noticed that a) Windows isn’t very tolerant of some things and doesn’t care about other stuff, and b) MAME was giving some weird results.

In the end, the Windows thing came down to needed to pad out the reports the microprocessor was sending back to a multiple of 8 bits. It seems that Windows can’t cope with not being told what to do with unused bits in a byte, so you specifically have to mark them as usage type “undefined” to keep it happy. E.g. if you have 12 buttons, one bit each resulting in sending a two byte report you have to mark the unused 4 bits in the second byte as undefined. Linux and MacOS seem to be more tolerant. Maybe it’s just the existential quandary Windows is trapped in, forced to ask “why?” and so unable to cope with not knowing what those extra bits to.

Or, it’s just slack programming.

I’m thinking the latter. Windows copes quite well with other problems in the HID descriptor, like forgetting to change collection or usage page which was causing MAME to give the fire buttons funny names. It still insists on number buttons from zero, but that seems to be normal behaviour as it happens with all USB devices. In that sense USB is a minefield of off-by-one errors, because you count bits from 0 yet need to number your buttons starting at 1, and indeed Windows shows them in the control panel applet starting at 1. Unfortunately the official HID descriptor tool validates these kinds of errors so it’s easy not to notice them.

PS. I will update the site soon with new schematics (true 3.6V signalling instead of the old 5V stuff) and firmware.

This entry was written by mojo, posted on 06/03/2008 at 20:03, filed under hardware, windows. Bookmark the permalink. Follow any comments here with the RSS feed for this post. Post a comment or leave a trackback: Trackback URL.
« Movie industry doing well depite piracy and shite movies
Defence against capturing passwords from memory »

Post a Comment

Your email is never shared. Required fields are marked *

*
*

たとえ溺れても梦はゆめでしかない
  •  

    March 2008
    M T W T F S S
    « Feb   Apr »
     12
    3456789
    10111213141516
    17181920212223
    24252627282930
    31  
  • Meta

    • Log in
    • Entries RSS
    • Comments RSS
    • WordPress.org
  • Categories

    • audio (1)
    • avr (20)
    • BBC (1)
    • electronics (29)
    • genius (4)
    • hardware (22)
    • idiots (39)
    • Internet (21)
    • law (20)
    • microcontrollers (12)
    • networking (17)
    • politics (29)
    • privacy (19)
    • Retro Adapter (5)
    • security (17)
    • software (32)
    • Uncategorized (18)
    • windows (25)
  • Archives

    • February 2012
    • January 2012
    • December 2011
    • November 2011
    • October 2011
    • September 2011
    • July 2011
    • June 2011
    • May 2011
    • March 2011
    • January 2011
    • December 2010
    • November 2010
    • August 2010
    • July 2010
    • June 2010
    • May 2010
    • April 2010
    • March 2010
    • February 2010
    • January 2010
    • December 2009
    • November 2009
    • October 2009
    • September 2009
    • August 2009
    • July 2009
    • June 2009
    • May 2009
    • April 2009
    • March 2009
    • February 2009
    • January 2009
    • December 2008
    • November 2008
    • October 2008
    • September 2008
    • August 2008
    • July 2008
    • June 2008
    • May 2008
    • April 2008
    • March 2008
    • February 2008
    • January 2008
    • November 2005
  • Links:

    Main site: world3.net

    Electronics: denki.world3.net

WordPress | Sandbox