mouse implementation
mouse implementation
I want to implement mouse functions now, I can not find a good tutorial about how can I implement mouse driver. All I found is technical documentation of mouse but no idea how can I catch mouse movements. ıll be glad if someone helps...
Re:mouse implementation
Hello finda
Here's a quite complete site about the ps/2 mouse & keyboard
http://govschl.ndsu.nodak.edu/~achapwes ... index.html
And there are also some documents at bonafide
http://osdev.neopages.net/docs.php?cat=8&sort=1
regards,
gaf
Here's a quite complete site about the ps/2 mouse & keyboard
http://govschl.ndsu.nodak.edu/~achapwes ... index.html
And there are also some documents at bonafide
http://osdev.neopages.net/docs.php?cat=8&sort=1
regards,
gaf
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:mouse implementation
you may also wish to check the .:QuickLinkz:. thread ... the collected knowledge about PS2 and serial mice may be found there ...finda wrote: No answer?
Re:mouse implementation
But as I said before most links and tuts in quicklinks part is technical reference, no information about how can I identify mouse, how can I init it..etc...
Re:mouse implementation
When I make a search in forum, some people mentioning that they are going to write a mouse tutorial, is there a completed one from them?
Re:mouse implementation
If you haven't found one, there isn't one. You will find that tutorials only cover about 1% of OS development. 10% is covered by technical specifications. You can work out 50% on your own. The rest is either impossible or subject to research.
If you think there should be a tutorial on a topic, the best thing to do is learn it from whatever material you can find, then write the tutorial yourself.
If you think there should be a tutorial on a topic, the best thing to do is learn it from whatever material you can find, then write the tutorial yourself.
Re:mouse implementation
There are no impossible things, just subjects to research, which might at somepoint include hardware research though... ;DTim Robinson wrote: The rest is either impossible or subject to research.
Re:mouse implementation
If by "hardware research" you mean "paying ATI or nVidia for their chipset specs", then, yes, it's not impossible. Just very unlikely.
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:mouse implementation
one approach that often pays is to use the technical specs. to enlight your reading of a working driver (mobius, linux ...)
Re:mouse implementation
Well here is some code to start the PS2 mouse
there are no comments but the code is straight forward and follows the specs for the PS2 mouse. This is the mouse interrupt routine to be installed on IRQ 12 (slave pic)
this is the code to initiallise the PS2 mouse.
Can't explain it now (going out) but will answer any questions later.
Code: Select all
_mouse_int:
push eax
push edi
push ecx
push ebx
movzx ebx,byte [_mouse_in]
lea edi,[_mouse_data]
in al,0x60
mov [edi+ebx],byte al
inc ebx
cmp ebx,0x03
jb .mouse_out_pre
mov ch,byte [edi] ;multi infor byte
mov [_mouse_button],byte ch ;store mouse button info
test ch,0x40 ;check for X overflow
jz .no_x_overflow
mov [_mouse_dx],byte 0xff ;maximum x value
jmp .check_y_overflow
.mouse_out_pre:
jmp .mouse_out
.no_x_overflow:
mov cl,byte [edi+0x01] ;get change in x byte
mov [_mouse_dx],byte cl
.check_y_overflow:
test ch,0x80 ;check for Y overflow
jz .no_y_overflow
mov [_mouse_dy],byte 0xff ;sign bit set so 255 is maximum
jmp .check_x_sign
.no_y_overflow:
mov cl,byte [edi+0x02] ;get change in y byte
mov [_mouse_dy],byte cl
.check_x_sign:
test ch,0x10
jz .positive_x
movsx eax,byte [_mouse_dx]
jmp .check_y_sign
.positive_x:
movzx eax,byte [_mouse_dx]
.check_y_sign:
test ch,0x20
jz .positive_y
movsx ecx,byte [_mouse_dy]
jmp .going_out
.positive_y:
movzx ecx,byte [_mouse_dy]
.going_out:
mov ebx,0
add [_mouse_x],word ax
neg cx
add [_mouse_y],word cx
push dword [_mouse_semaphore]
call _wake
pop eax
.mouse_out:
mov [_mouse_in],byte bl
mov al,0x20
out 0xa0,al
out 0x20,al
pop ebx
pop ecx
pop edi
pop eax
iret
jmp $
Code: Select all
void initialize_mouse()
{
unsigned char data;
while(test_keyboard_data())
inportb(0x60);
wait_keyboard();
outportb(0x64,0xa8); /*tell controller to enable AUX interface*/
wait_keyboard();
outportb(0x64,0xd4); /*tell controller to send next command to Aux device*/
wait_keyboard();
outportb(0x60,0xea); /*tell device to enable itself*/
wait_keyboard_data();
if(test_keyboard_data())
printf("KEYBOARD ACK 3 [%02x]\n",inportb(0x60));
outportb(0x64,0x20); /*read command byte*/
wait_keyboard_data();
data=inportb(0x60);
printf("Data: [%02x]",data);
data=data|0x43;
printf(" Data: [%02x]",data);
outportb(0x64,0x60); /*write command byte*/
wait_keyboard();
outportb(0x60,data);
wait_keyboard();
k_memset(mouse_data,0,sizeof(mouse_data));
outportb(0x64,0xd4); /*tell controller to send next command to Aux device*/
wait_keyboard();
outportb(0x60,0xf4); /*reset mode*/
wait_keyboard_data();
if(test_keyboard_data())
printf("KEYBOARD ACK 4 [%02x]\n",inportb(0x60));
inportb(0x60);
while(test_keyboard_data())
inportb(0x60);
kenable_level(12);
return;
}
Can't explain it now (going out) but will answer any questions later.
Re:mouse implementation
Actually my point was something like: you could do all the research starting from what you have up to what you need, possibly including other sciences as well (say you want to factor large 2-prime composites, which might include maths and/or quantum physics just to start with) but I agree that it's rather unlikely that any of us is intelligent, rich and lucky enough to do that all within one's lifetime...Tim Robinson wrote: If by "hardware research" you mean "paying ATI or nVidia for their chipset specs", then, yes, it's not impossible. Just very unlikely.
In other words, you could call it a joke. (bad one it seems)