I have not tested on real hardware.I have not tested because my test bed had got spoilt and is under repair.Test in a emulator ,also inform me if it dose not work or works.
FRIST TEST IT IN A EMULATOR,PLZ
You need to have a functions inport,outport and wait.
=======================================================
Add this to your file were the you store variables
static unsigned char mouse_no = 0;
static char mousebyte[3];
=======================================================
#include<base.h>//Few variables and more
#include<hardware.h>//My IO is here
void load_mouse()
{
outportb(0x64,0xA8);
outportb(0x64,0x20);
unsigned char stbyt;
stbyt = (inportb(0x60) | 2);
outportb(0x64, 0x60);
outportb(0x60, stbyt);
outportb(0x64, 0xD4);
outportb(0x60,0xF6);
inportb(0x60);
outportb(0x64, 0xD4);
outportb(0x60,0xF4);
inportb(0x60);
}
void mouse_handler(struct regstrs * reg)
{
if (mouse_no == 3)
{
mouse_no = 0;
mousebyte[mouse_no++] = inportb(0x60);
if (mousebyte[0] & 0x4)
mouse_round_button();//Same thing as below but for the middle button.
if (mousebyte[0] & 0x2)
mouse_right();//Replace with you function to do if right button is clicked.
if (mousebyte[0] & 0x1)
mouse_left();//Same thing as above but for left
}
}
void init_mouse ()
{
load_mouse();
wait(2);//Give some time for the mouse
install_irq_to_system(12, mouse_handler);//This must be your IRQ function which installs IRQ's
}
=================================================================
Call init_mouse in your main.
i will be thankful to for a few correction's
Also can anybody tell how to get the x and y of the mouse.
Mouse Button Driver
Re: Mouse Button Driver
You should probably put
Code: Select all
tags around your example, makes it easier to read - looking good though, hope you figure out how to do coordinates/movement...
Re: Mouse Button Driver
Do you mean comments?
This driver is not easy, i got a datasheet of a PS/2 Mouse and prepared it.But i didnot understand about the x and y that sheet.
You will not get it anywhere on the web.The code.
I justed , a glitch.
I tested it 10 times, 5 times worked other 5 failed.I dint even change a bit of the code.
This driver is not easy, i got a datasheet of a PS/2 Mouse and prepared it.But i didnot understand about the x and y that sheet.
You will not get it anywhere on the web.The code.
I justed , a glitch.
I tested it 10 times, 5 times worked other 5 failed.I dint even change a bit of the code.
Re: Mouse Button Driver
Can you post a link to the datasheet so that others can help easier and maybe develop their own drivers?
Re: Mouse Button Driver
http://www.datasheetarchive.com/
I got here, i dono which one,I typed mouse microcontroller PS/2 in the search, i downloaded few from there.
I got here, i dono which one,I typed mouse microcontroller PS/2 in the search, i downloaded few from there.
Re: Mouse Button Driver
The mouse's are active only sometimes.Can anyone make a function for checking the mouse and keyboard weather it is ready to take in command or not.
Re: Mouse Button Driver
Pooling is not a good idea. What's wrong with IRQ?Yashas wrote:The mouse's are active only sometimes.Can anyone make a function for checking the mouse and keyboard weather it is ready to take in command or not.
By the way, check here Mouse_Input.
Re: Mouse Button Driver
I ment that your function of installing irq might be different from my function.
And also by the way thank you.I am trying the y-delta and the x-delta.
And also by the way thank you.I am trying the y-delta and the x-delta.