Mouse's weird behaviour
Posted: Mon Mar 14, 2011 11:05 am
Hello everyone,
I'm new to the forum but not new to this site. Me and my friend have been developing and OS for several months and finally we've decided to follow separate tracks. Now, I've written my own OS and I'm currently stuck at the very weird behaviour of the mouse.If I uninstall and then reinstall the mouse, the mouse starts to send strange packets and the cursor seems to go violent. I think the mouse has entered unknown mode but I'm not sure which. Here's the code to install and uninstall the mouse:
I tried updating the mouse_uninstall() code as much as I could including restoring original compaq status byte etc. but I don't seem to dig my way out.
What I'm surprised to see is that there's no any strange behaviour if I run this code under emulator. But under real hardware, the mouse starts to behave strange, sending random packets. I think the mouse is in some different mode. I even tried sending the 'Reset' Command to the mouse but then it starts to behave strange even under the emulator as it wouldn't do before(at least not under an emulator). This means that nor the hardware is faulty nor the emulator(MS virtual PC). I would highly appreciate if someone would help me or at least push in the right direction.
Thanks for any help.
--Rival
I'm new to the forum but not new to this site. Me and my friend have been developing and OS for several months and finally we've decided to follow separate tracks. Now, I've written my own OS and I'm currently stuck at the very weird behaviour of the mouse.If I uninstall and then reinstall the mouse, the mouse starts to send strange packets and the cursor seems to go violent. I think the mouse has entered unknown mode but I'm not sure which. Here's the code to install and uninstall the mouse:
Code: Select all
void mouse_install()
{
unsigned char _status;
mouse_wait(1); /*let's now enable the mouse port to generate interrupts*/
outportb(0x64,0xA8);
mouse_wait(1); /*modify the "compaq status byte", to enable the interrupt*/
outportb(0x64,0x20);
mouse_wait(0);
_status=(inportb(0x60) | 2);
mouse_wait(1);
outportb(0x64,0x60);
mouse_wait(1);
outportb(0x60,_status);
mouse_write(0xF6); /*Tell the mouse to use default settings*/
mouse_read(); /*Acknowledge*/
mouse_write(0xF4); /*Enable Data Reporting*/
mouse_read();
irq_install_handler(12, mouse_handler);
}
void mouse_uninstall()
{
unsigned char _status;
mouse_show();
mouse_wait(1); /*disable the auxillary mouse device*/
outportb(0x64,0xA7);
mouse_write(0xF5); /*Disable Data Reporting*/
mouse_read();
irq_uninstall_handler(12);
mouse_hide();
}
What I'm surprised to see is that there's no any strange behaviour if I run this code under emulator. But under real hardware, the mouse starts to behave strange, sending random packets. I think the mouse is in some different mode. I even tried sending the 'Reset' Command to the mouse but then it starts to behave strange even under the emulator as it wouldn't do before(at least not under an emulator). This means that nor the hardware is faulty nor the emulator(MS virtual PC). I would highly appreciate if someone would help me or at least push in the right direction.
Thanks for any help.
--Rival