Skip to main content
GameDev.net gamedev.net
🔒 Locked

Getting raw data from a USB mouse (ie, writing a driver)

Started by Alan Kemp Apr 29, 2005 at 1:49 PM 2 replies 16.6k views
Original Post
Alan Kemp
Alan Kemp
Hi, I want to understand how a USB mouse outputs data (movement and buttons) so that I can write a driver for a device I have that has a USB socket. I cant seem to find any information about if this is some standard protocol. I need to know things like, do I have to initialize the mouse somehow? Or do I just need to read from its port and it will automatically send me data as it moves/clicks? Can anyone point me to any information about this? I tried MSDN but the little information I can dig up all relates to writing windows drivers, but eventually I will be writing this in Java (belive me, dont ask). At this point even the smallest piece of information would be useful. Thanks, Alan
"There will come a time when you believe everything is finished. That will be the beginning." -Louis L'Amour
Promit
Promit
Quote:
Original post by Alan Kemp
but eventually I will be writing this in Java (belive me, dont ask).


Uh...forget it?

First of all, you need the Windows DDK (driver dev kit) from MSDN, which is a free download for subscribers, and free + S&H for others to mail a CD to. You need the headers and libs in that DDK, which more or less forces you to use C/C++ afaik. After that, I think the mouse just sends raw data that you need to interpret.

Unlike Linux, Windows doesn't provide a character device for the mouse that you can just read from. With Linux, you can simply cat /dev/input/mice and you'll actually see the raw data translated to ASCII.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
Alan Kemp
Alan Kemp
Sorry, I explained badly. I only mentioned MSDN as a source of information, this driver is not for use on windows, its for a lump of custom hardware that happens to have a usb port and I want to plug a mouse into. Unfortunatly the only real way to access the ports without going into assembly and hacking the propriatary OS is through java (which can open and read/write to the port fine).

Quote:

With Linux, you can simply cat /dev/input/mice and you'll actually see the raw data translated to ASCII.


You unintentionally showed me how to figure out the format of the messages for myself. Thanks :-)

Although, if anyone has any information about the protocol or just general mouse hardware stuff I would be very intrested in reading it.

Alan
"There will come a time when you believe everything is finished. That will be the beginning." -Louis L'Amour
benryves
benryves
If it uses the same software protocol as the PS/2 mouse (via the AT hardware protocol), this document explains the packet format quite nicely.
[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.