mouse_send_command(0xF3); // Set sample rate mouse_send_command(200); mouse_send_command(0xF3); mouse_send_command(100); mouse_send_command(0xF3); mouse_send_command(80); mouse_send_command(0xF2); // Get device ID – should return 3
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.
In the standard IBM PC architecture, the PS/2 controller (typically an 8042 microcontroller) is accessed via I/O ports 0x60 and 0x64 .
// Pseudo-code for packet decoding int8_t x_movement = packet[1]; int8_t y_movement = packet[2];