Ps/2 Compatible Mouse Driver !!link!! Today
// Send EOI to PIC outb(0x20, 0x20);
The PS/2 interface has remained a standard for keyboard and mouse input in the IBM PC architecture since its introduction in 1987. Despite the prevalence of USB and Bluetooth in modern computing, the PS/2 protocol remains relevant in embedded systems, legacy hardware maintenance, and operating system development. This paper explores the low-level design of a software driver for a PS/2 compatible mouse. It details the hardware interaction via I/O ports, the initialization sequence required to enable the auxiliary device, the interpretation of the standard 3-byte data packet, and the management of hardware interrupts. The paper concludes with an analysis of the protocol's limitations and the handling of edge cases such as overflow and synchronization errors. ps/2 compatible mouse driver
// Pseudo-code for packet decoding int8_t x_movement = packet[1]; int8_t y_movement = packet[2]; // Send EOI to PIC outb(0x20, 0x20); The
sleep(10);
// Decode movement int dx = (int)mouse_packet[1]; int dy = (int)mouse_packet[2]; It details the hardware interaction via I/O ports,
void install_mouse_handler() set_idt_gate(0x2C, (uint32_t)mouse_isr, 0x08, 0x8E); outb(0x21, inb(0x21) & ~0x20); // Unmask IRQ12 on slave PIC outb(0xA1, inb(0xA1) & ~0x20);
volatile uint8_t mouse_cycle = 0; volatile uint8_t mouse_packet[4]; // We use 3 for standard volatile int mouse_x = 0, mouse_y = 0; volatile uint8_t mouse_buttons = 0;