PS/2 Mouse ('Real' mode) (no int 33h) v0.02
Submitted By:
MI_7
Rating:





(
Rate It)
Share:
By Email
This program is made for people who want to make their own
drivers for an PS/2 port without using the int 33h. ( easy to
understand example, I hope ;) ) For use in own OS or MS-DOS
enviroment. This is educational perpose version and the effects
of the program are undefined. By downloading the program the
downloader downloads it at his own risk.
NOTE: Some downloads must be obtained through publishers´s site.
Do you want to get your software listed on this site? Go to our
submissions area.
Screenshot
Details
Number of downloads:
2664
Comments (8)
Little but efficient code !




Posted on Sunday, March 05, 2006
It is very pleasant to have in few lines
of assembly language the solution which
allows me to continue my os development.
A big thank you !
i need help




Posted by: emily anna on Monday, May 07, 2007
exellent code, could you help me traslating this into tc?? i have tried a lot, but it wont work.i got this
#include <stdio.h>
#include <dos.h>
#include <conio.h>
char sp2;
void CHKPRT(){
char exit=0,ap;
asm xor cx, cx
do{
asm in al, 0x64
asm mov ap,al
if ((ap&2)==0)
{exit=1;
}
}while (exit==0);
}
void PS2SET(){
asm mov al, 0xa8
asm out 0x64, al
CHKPRT();
}
void WMOUS(){
asm mov al, 0xd4//; write to mouse device instead of to keyboard
asm out 0x64, al//; write to keyboardcontroller
CHKPRT();//; check if command is progressed (demand!)
}
voidMBUFFUL (){
char exit=0,ap;
asm xor cx, cx
do {
asmin al, 0x64 //; read from keyboardcontroller
asm mov ap,al
if ((ap&0x20)==0)
{exit=1;
}
}while (exit==0);
}
void CHKMOUS(){
char exit=0,ap;
sp2=-1;
asm xor cx, cx
do{
asm in al, 0x64//read from keyboardcontroller
asm mov ap,al
if ((ap&1)!=0)
{exit=1;
}
sp2++;
}while (exit==0); // check if controller buffer (60h) has data
}
voidACTMOUS(){
WMOUS();
asm moval, 0xf4 //; Command to activate mouse itselve (Stream mode)
asmout0x60, al //; write ps/2 controller output port (activate mouse)
CHKPRT();//; check if command is progressed (demand!)
CHKMOUS();//; check if a byte is available
}
void DKEYB(){
asm mov al, 0xad//; Disable Keyboard
asm out 0x64, al//; write to keyboardcontroller
CHKPRT(); //; check if command is progressed (demand!)
}
void EKEYB(){
asm mov al , 0xae//; Disable Keyboard
asm out 0x64, al//; write to keyboardcontroller
CHKPRT(); //; check if command is progressed (demand!)
}
void GETB(){
char ps;
do{
CHKMOUS();
}while(sp2!=0);
DKEYB();
asm in al, 0x60//; read ps/2 controller output port (mousebyte)
asm mov ps,al
EKEYB();//; enable keyboard
printf("\n%d",ps);
}
int main(void)
{
char b, d =0;
PS2SET();
WMOUS();
GETB();
do {
clrscr();
GETB();
GETB();
GETB();
} while(d==0);
return 0;
}
My Appreciation




Posted by: Maxinator on Thursday, October 11, 2007
I cant say, how much i thank you, i searched for exemples overall in the net, because my selfwritten-code based on the ralf-browns-list didnt work, but i couldnt find anything. I also searched programmersheaven archives, but it seems, like i oversaw your code, or i thought, id dont work as well, because when i first searched fpr ps/2-mouse-drivers i tested it while running xp and now i always test the drivers with my own written OS, for that a also needed this piece of code. THANKS..
P.S.: This is my 5th search. Between the over searches there was a gap of around some weeks or even months.
Well this is not the best place to ask for my help..




Posted by: MI-7 on Tuesday, November 20, 2007
For questions and stuff you can contact me by internal mail of programmersheaven or by email.
email: MI-7@badassdummies.nl
the main fault i see in your tc script is that you use the asm not in the right way.
you can use this as following:
asm {
xor ax,ax
}
if you want to use variables of c in the asm for in or output you can do that as follows:
char vari;
asm {
mov AH, vari
cmp AH, 0
}
and as i remember its not easy to use the asm command in tc. this should be enabled, if it isnt by default, somewhere at the compiler settings.
[this is what i remembered at this moment so it might be a little bit different]
I can help better by mail,irc,msn and such.
Greetz MI_7
ece




Posted by: ravi on Monday, October 05, 2009
GOOD CODE. But i need to know how this code is installed in DOS. By using MASM can v directly install this driver. could anyone give the details for installing device driver in os after writing code.
Important




Posted by: Convert Mouse X,Y coords to screen X,Y coords on Friday, February 26, 2010
How can i convert the PS/2 mouse coordinates to screen coordinates?
I want to use it to move a mouse cursor for my os.
How can i convert the PS/2 mouse coordinates




Posted by: MI-7 on Friday, May 14, 2010
Hi,
the Values given by the mouse are displacement values.
this value tells you how many "mickey's" :P youre has moved in a direction.
So if you have a resolution of 1024x768 and your mouse is at the middle 512x 384y and your mouse said that you have moved 100 in the x direction than you add this value to you Xcoorinate on you screen and save that one again as the current Xcoordinate.
If your mouse moves too fast like you moved an Inch and your mouse gives 100000 as a moved value than you might want to consider using a factor to reduce the movement.
like:
mouse gives: 10000 (x direction)
screen width: 1024
current cursor pixel: 512 (x direction)
Xcoordinate = 512 + (10000 * 0.001)
so your new Xcoordinate = 522
If I remember correctly I've also included this in this code.
(grmbl, why must I rate my own code if i only want to reply...)
Greetings MI-7
Mouse driver stalls keyboard after exit.




Posted by: Pete on Friday, November 26, 2010
I read that the keyboard stalls after the pgm exits.
Have you tried deactivating the mouse port before exiting to the OS ?
Add Your Rating