Mouse Input: Difference between revisions
Jump to navigation
Jump to search
[unchecked revision] | [unchecked revision] |
Content deleted Content added
m Fixing the See Also Thread links |
m →PS/2 Mouse Input: fixed link |
||
Line 3: | Line 3: | ||
==PS/2 Mouse Input== |
==PS/2 Mouse Input== |
||
The mouse is read just like described on the [ |
The mouse is read just like described on the [[PS2 Keyboard]] page, except that any write to the mouse must be preceded by writing 0xD4 to port 0x64, and then writing your byte to port 0x60. For more information, see [http://www.isdaman.com/alsos/hardware/mouse/ps2interface.htm] |
||
<pre> |
<pre> |
||
Line 40: | Line 40: | ||
} |
} |
||
</pre> |
</pre> |
||
==Initialization== |
==Initialization== |
Revision as of 02:25, 22 September 2007
PS/2 Mouse Input
The mouse is read just like described on the PS2 Keyboard page, except that any write to the mouse must be preceded by writing 0xD4 to port 0x64, and then writing your byte to port 0x60. For more information, see [1]
inline void mouse_wait(byte a_type) { dword _time_out=100000; if(a_type==WAIT_FOR_DATA) { while(_time_out--) { if((inportb(0x64) & 1)==1) return; } return; } else { // WAIT_FOR_SIGNAL while(_time_out--) { if((inportb(0x64) & 2)==0) return; } return; } } inline void mouse_write(byte a_write) { mouse_wait(WAIT_FOR_SIGNAL); //Wait to be able to send a command outportb(0x64, 0xD4); //Tell PS2 we are sending a command to the mouse mouse_wait(WAIT_FOR_SIGNAL); outportb(0x60, a_write); //Finally write data byte. } byte mouse_read() { mouse_wait(WAIT_FOR_DATA); //Get's response from mouse return inportb(0x60); }
Initialization
You'll basically have to send a couple of commands to the PS2 controller (not to the mouse itself), so that it enables auxiliary device (command 0xA8), enable interrupts on that device (command 0x20 to read the status, then command 0x60 to write the status back, with bit 1 set).
Once this is done, you can send the "SET_DEFAULTSETTINGS" mouse command using mouseWrite above, then the "ENABLE" command. See SANiK's driver for details.