Code inside my handler - used to determine the current x and y value of the mouse pointer - Device initialized using default settings
Code: Select all
//direction (0=right, 1=left)
if((mouse_bytes[0] & 0x07)==0)
{
if((mouse_bytes[0] & 0x05)==0)
{
MousePositionX+=mouse_bytes[1];
} else {
MousePositionX-=mouse_bytes[1];
}
} else { //overflow
MousePositionX+=mouse_bytes[1]/2;
}
//direction (0=up, 1=down)
if((mouse_bytes[0] & 0x08)==0)
{
if((mouse_bytes[0] & 0x06)==0)
{
MousePositionY-=mouse_bytes[2];
} else {
MousePositionY+=mouse_bytes[2];
}
} else { //overflow
MousePositionY-=mouse_bytes[2]/2;
}
Code: Select all
//keep cursor inside the limits
if(MousePositionX>=800-16) { MousePositionX=800-16; }
if(MousePositionX<=0) { MousePositionX=0; }
if(MousePositionY>=600-24) { MousePositionY=600-24; }
if(MousePositionY<=0) { MousePositionY=0; }
Code: Select all
//check button state
if ((mouse_bytes[0] & 0x01)==1)
{
beep(440,1);
}
I have compared my code to a number of different codes, and I am not really seeing much difference, except that I am trying to account for overflow. When I test my code in VGA mode, it works perfectly in VPC and real hardware. But, I am writing this mouse driver to work in a graphical mode (800x600x16M), so I am not too sure if the problem is with my math. I did print out the x and y values right before where I actually print the cursor and both values would be within my screens range, both positive numbers. I do make sure to multiply by screen width and bytes per pixel in the back end, so if it is my math I don't see how it could be.
I hope someone can figure this out or has had this happen to them and can provide a possible solution. Thanks.