keyboard/mouse problem

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
FlashBurn

keyboard/mouse problem

Post by FlashBurn »

I?ve rewritten my code for the 2nd irq (irq 1) so that it could also receive data from the mouse. But I have to look if the data is from the keyboard or the mouse. I make this so:

Code: Select all

call kbd_wait_cmd
mov al,0c0h
out 64h,al
call kbd_wait_data
in al,64h
test al,1
jne .keyb
.mouse
 ;code
.keyb
 ;code
Bochs gives me the folowing error "kbd: OUTB set and command 0xc0 encountered". What made I wrong?

One more question. When the mouse is sending data, sends it the whole package and I have to inport all 3bytes or calls it the irq for every byte?
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:keyboard/mouse problem

Post by Pype.Clicker »

err. afaik, the mouse doesn't raise IRQ1 when data are available. I'm not sure what interrupt is used for PS2 mouse (for serial mice, it is the COM1 or COM2 interrupt), so i would say you can expect the byte in 8042 to be for the keyboard when the keyboard interrupt is fired and to be for the mouse if the mouse interupt is fired ...
FlashBurn

Re:keyboard/mouse problem

Post by FlashBurn »

But the ps2 mouse uses the kbd controller and so I think it uses the irq1, too! Because why should it use an extra irq? Also if the ps2 mouse doesn?t use the kbd irq, why gives me bochs this error?
distantvoices
Member
Member
Posts: 1600
Joined: Wed Oct 18, 2006 11:59 am
Location: Vienna/Austria
Contact:

Re:keyboard/mouse problem

Post by distantvoices »

On some older mainboards, afaik, irq 12 is used for ps/2 mice. i don't know if ps2 mice are handled by int 12 on newer mainboards.
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
FlashBurn

Re:keyboard/mouse problem

Post by FlashBurn »

Ok, I want to test if the mouse sends it data and fires irq1. But how can I test if the data is from the kbd or from the mouse? I can?t send the command "read input port" because before I have to read the data and then the bytes for data are cleared. So how can I determine from which device the data is?
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:keyboard/mouse problem

Post by Pype.Clicker »

on real hardware (pIII motherboard and Logitech PS2 mouse), i can remember i had IRQ12 fired when i moved the mouse by accident. And indeed the mouse data were stored at the 8042 (which is the microcontroller which handles keyboard, but NOT LIMITED to keyboard).

The result is that if you don't read bytes from the 8042 at the mouse interrupt, they will stay at the 8042 and lock further keyboard data.
Slasher

Re:keyboard/mouse problem

Post by Slasher »

To find out if the data is from the keyboard or from the mouse, you need to test the status register of the 8042. I have forgotten which, check docs on keyboards the AUX bit in one register indicates the source. Also, to use irq 12h for the mouse, the keyboard controller has to be instructed to use it for ps2 mice, how this is done i have forgotten :-[ but can be found in docs.
Post Reply