how to get mouse input?

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
Adek336

how to get mouse input?

Post by Adek336 »

how to get direct mouse input from ports? do i just have to read com1 or do i have to initialise it?

Thnx, Adrian.
jamethiel

RE:how to get mouse input?

Post by jamethiel »

I'm afraid you're going to have to be a little more specific here. Serial mouse, PS/2 mouse, ADB mouse, Logitech mouse bus mouse, Microsoft mouse bus mouse, Commodore 64 mouse, SNES mouse, which?
Adek336

RE:how to get mouse input?

Post by Adek336 »

I've a PS/2. I've heard it is to be read by IRQ 12, but with keyboard ports. How may I enable pic1?

Thnx, Adrian.
jamethiel

RE:how to get mouse input?

Post by jamethiel »

The IRQs are your business, I'll cover some of the mouse side.

To enable the mouse port, write 0xa8 to port 0x64.

To enable the mouse, write 0xd4 to port 0x64, then send byte 0xf4 as if you were sending a keyboard command (as if you were changing the keyboard LED status with 0xed, whatever). The 0xd4 to port 0x64 says to send the next output byte to the mouse port instead of the keyboard port. The 0xf4 is a mouse command to start sending packets.

When a mouse byte (as opposed to a keyboard byte) comes in, port 0x64 will have the 0x20 bit high. This is how you distinguish the two input sources in a polled implementation, and can act as an extra safety check in an interrupt-driven system.

Hope this helps.
Adek336

RE:how to get mouse input?

Post by Adek336 »

It resets, weird.

outportb(0x64, 0xa8);
outportb(0x64, 0xd4);
outportb(0x64, 0xf4);

it resets after the third, i've checked.

perhaps i've got the ports all wrong?

Thnx, anyway,
Adrian.
jamethiel

RE:how to get mouse input?

Post by jamethiel »

Umm... By 'as if you were changing the keyboard LED status with 0xed' I meant to send it to port 0x60 after waiting for a bit in port 0x60 to reach a specific state (memory fails me, and I'm in no position to check for specifics right now).

Hope this helps.
Post Reply