Mouse Input article

All about the OSDev Wiki. Discussions about the organization and general structure of articles and how to use the wiki. Request changes here if you don't know how to use the wiki.
Post Reply
User avatar
Tomaka17
Member
Member
Posts: 67
Joined: Thu Oct 02, 2008 8:20 am

Mouse Input article

Post by Tomaka17 »

Hello,

I think there is a typo in the Mouse Input article

Near the end of the page:
If mouseID is 0, send: Set Samplerate 200, Set Samplerate 100, Set Samplerate 80, Get MouseID. If mouseID changed to 3, mouse has a scroll wheel, and is now in 4 byte packet mode.
If mouseID is 3, send: Set Samplerate 200, Set Samplerate 200, Set Samplerate 80, Get MouseID. If mouseID changed to 4, mouse has 5 mouse buttons -- otherwise only 3.
The second thing we should send when mouseID is 3 is certainly "samplerate 100" and not 200, though I'm not sure because the PS/2 chipset is such a strange thing


By the way you should also precise that the three or four packets each trigger a different IRQ12
On first IRQ12 you can only read the first data byte (port 0x60)
On the second you can only read the second data byte, etc.

I've learned this the hard way :)

Thanks BOCHS logs:
00170792000d[KBD ] [mouse] Dx=1 Dy=1 Dz=0
00170792000d[KBD ] mouse_enQ(08)
00170792000d[KBD ] mouse_enQ(01)
00170792000d[KBD ] mouse_enQ(01)
00170850037d[KBD ] [mouse] read from 0x60 returns 0x08
00170850051d[KBD ] num_elements = 0
00170850051d[KBD ] read from port 60h with outb empty
00170850065d[KBD ] num_elements = 0
00170850065d[KBD ] read from port 60h with outb empty
00170850500d[KBD ] service_keyboard: key(from mouse) in internal buffer waiting
00170891288d[KBD ] [mouse] read from 0x60 returns 0x01
00170891302d[KBD ] num_elements = 0
00170891302d[KBD ] read from port 60h with outb empty
00170891316d[KBD ] num_elements = 0
00170891316d[KBD ] read from port 60h with outb empty
00170891500d[KBD ] service_keyboard: key(from mouse) in internal buffer waiting
00170932550d[KBD ] [mouse] read from 0x60 returns 0x01
00170932564d[KBD ] num_elements = 0
00170932564d[KBD ] read from port 60h with outb empty
00170932578d[KBD ] num_elements = 0
00170932578d[KBD ] read from port 60h with outb empty
00170933000d[KBD ] service_keyboard(): no keys waiting
MysteriOS
Currently working on: TCP/IP
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Re: Mouse Input article

Post by bewing »

Hmmmm. I will look back into it -- but on first glance, I'm pretty sure the article is correct.
The SetSampleRate 200 command is what "turns on" the extra buttons and sets the new mode. You cannot repeat the same command as before, or it would set the same old mode as before.

And you do not precisely have to wait for an IRQ12 to get each byte. If port 0x64 says that there is another byte to read, you can read it without waiting for the next IRQ. You certainly cannot just go and do another inb(0x60), though. You MUST verify that there is a new char available using some method.

I am certainly planning on rewriting that article of mine sometime soon, however -- what is there now was only my first draft. So it certainly may need some modifications.
Post Reply