Mouse recognition & protocol used

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
arkady
Posts: 17
Joined: Wed Jan 02, 2008 3:14 pm
Location: Poland

Mouse recognition & protocol used

Post by arkady »

My mouse is A4tech X-750F model. When connected through USB it always sends 3 bytes after any mouse event and there is no way (AFAIK) to switch to other protocol using 'magic sequences' (like f3,c8,f3,64,f3,50 for Intellimouse). It also sends data after scrolling a wheel and pressing additional keys but the bytes sent are meaningless (always 08,00,00). After connecting through 'ordinary' mouse port it answers to the above sequence (ID=03)-sends 4 bytes in each packet so for example scrolling can be detected. It also uses some 'special protocol' (seq.: f3,c8,f3,64,f3,50,f3,3c,f3,28,f3,14, found here: http://linux.schottelius.org/gpm/browse ... int-0.01.c or http://rapidshare.com/files/80800633/gm ... .01.c.html)-sends 4 bytes per packet but they are completely different from ps2 or intellimouse standards...

1. I haven't tried 'usb things' yet but is it always the case that the mouse connected to usb port sends data to port 0x60 like an ordinary mouse? And why it doesn't respond to initialization sequences?
2. Is there a way to detect whether a mouse (responding through 0x60) is connected to usb or mouse port?
3. What are other so called 'magic sequences' for different models and where to get info about them?
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Re: Mouse recognition & protocol used

Post by jal »

arkady wrote:1. I haven't tried 'usb things' yet but is it always the case that the mouse connected to usb port sends data to port 0x60 like an ordinary mouse? And why it doesn't respond to initialization sequences?
It's not the mouse itself that 'sends data to a port', as the mouse is connected through the USB controller. It's the BIOS (through SMM) that emulates a PS/2 mouse (and keyboard). See e.g. this page and search for SMM. It presumably doesn't respond to initialization sequences because it is emulated one-way.
2. Is there a way to detect whether a mouse (responding through 0x60) is connected to usb or mouse port?
Not directly. The BIOS emulates a PS/2 mouse, so I would think it's rather BIOS and main board vendor specific what is emulated and what isn't.
3. What are other so called 'magic sequences' for different models and where to get info about them?
Check the WIKI! See here. Some additional information (also linked from the Wiki) can be found here.


JAL
arkady
Posts: 17
Joined: Wed Jan 02, 2008 3:14 pm
Location: Poland

Mouse recognition & protocol used

Post by arkady »

jal wrote: It's the BIOS (through SMM) that emulates a PS/2 mouse (and keyboard)...
Jal, you also said that 'BIOS emulates a PS/2 mouse'. But what if I'm in protected mode and a mouse is connected to usb? BIOS doesn't have a chance to emulate a ps2 mouse in this situation (I mean: no bios routines are called in PMode). Unless the BIOS did something while POST (or when DOS was loading-I'm running my VERY simple 'os' from DOS) and after that it's all taken care of by the hardware. Am I right??

BTW, thx for your answer!
User avatar
ucosty
Member
Member
Posts: 271
Joined: Tue Aug 08, 2006 7:43 am
Location: Sydney, Australia

Post by ucosty »

As far as I know the emulation dissapears when you enable USB, so the setting probably puts the usb controller in some mode that allows it to translate keyboard and mouse data into ps/2 data.
The cake is a lie | rackbits.com
User avatar
bluecode
Member
Member
Posts: 202
Joined: Wed Nov 17, 2004 12:00 am
Location: Germany
Contact:

Re: Mouse recognition & protocol used

Post by bluecode »

arkady wrote:
jal wrote:I mean: no bios routines are called in PMode
It is called SMM (System Management Mode). google and the intel manuals will tell you the details.
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Re: Mouse recognition & protocol used

Post by bewing »

arkady wrote: Jal, you also said that 'BIOS emulates a PS/2 mouse'. But what if I'm in protected mode and a mouse is connected to usb? BIOS doesn't have a chance to emulate a ps2 mouse in this situation (I mean: no bios routines are called in PMode).
Actually, as Brendan pointed out to me, the system can enter SMM at any time, without the OS even knowing about it. When in SMM mode, BIOS is active. And that is how a USB mouse emulates a PS2 mouse -- any USB mouse input flips the CPU into SMM mode, then passes the mouse input through the BIOS.
(oops, bluecode posted while I was typing. :wink:)
arkady
Posts: 17
Joined: Wed Jan 02, 2008 3:14 pm
Location: Poland

Post by arkady »

I'll take a closer look to that SMM... when I'm ready :D Looks like an interesting subject. Meanwhile, thank you all guys! You were very helpful!
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Post by jal »

arkady wrote:I'll take a closer look to that SMM... when I'm ready :D Looks like an interesting subject. Meanwhile, thank you all guys! You were very helpful!
Wikipedia also has a page on it. Basically, it's completely transparent to the OS, you cannot disable it or circumvent it directly. However, as the link to the M$ page I provided shows, you can disable it for USB, as it is a feature of the USB controller (which makes sense, as the USB controller must issue an SMI for SMM to kick in).


JAL
Post Reply