Mouse Input: Difference between revisions
Jump to navigation
Jump to search
[unchecked revision] | [unchecked revision] |
Content added Content deleted
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
{{Convert}} |
{{Convert}} |
||
==PS/2 Mouse Input== |
|||
The mouse is read just like described on the [Getting Keyboard Input] 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] |
The mouse is read just like described on the [Getting Keyboard Input] 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> |
|||
<verbatim> |
|||
inline void mouse_wait(byte a_type) |
inline void mouse_wait(byte a_type) |
||
Line 39: | Line 39: | ||
return inportb(0x60); |
return inportb(0x60); |
||
} |
} |
||
</ |
</pre> |
||
==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). |
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). |
||
Line 48: | Line 48: | ||
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. |
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. |
||
!Todo |
|||
* Basic Packet Format |
|||
* Extended Modes (wheel and five-button mode) |
|||
* Cursor display |
|||
* Anything else...? |
|||
==See Also== |
|||
---- |
|||
===Threads=== |
|||
* [SANiK's mouse code| Forum:7336] |
* [SANiK's mouse code| Forum:7336] |
||
* [PS2 mouse IRQ| Forum:3888] |
* [PS2 mouse IRQ| Forum:3888] |
Revision as of 18:00, 5 April 2007
PS/2 Mouse Input
The mouse is read just like described on the [Getting Keyboard Input] 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.
See Also
Threads
- [SANiK's mouse code| Forum:7336]
- [PS2 mouse IRQ| Forum:3888]
- [PS2 mouse links| Forum:1143]