Mouse Button Driver
Posted: Sun Feb 05, 2012 8:11 am
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.
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.