Lennard Electronics

Kiwi made, innovative electronics

Sometimes it is useful to be able to emulate a keyboard or a mouse – that’s what this code does. For example, it might be better to have a device with a few buttons on it that provide the same functions as a combination of keystrokes, rather than having a dedicated keyboard. The PS/2 port is used for Keyboards and Mice on Windows based PCs. PCs still have a PS/2 port, although most Keyboards and Mice are USB based now. A device designed to work on the PS/2 port will also work on USB via a PS/2-USB adapter. I have also tested this on a Macintosh, using a PS/2 to USB adapter, and it works just fine.

I used information from this website here to figure out how to work with the PS/2 standard.

Some of the information from that website is included in the code comments. These routines are written in Keil Micro C for the Silicon Labs C8051F005 MCU. I’ve provided functions to send and receive data and commands on the PS/2 bus. They work just fine in the application I’m using them for, although error recovery is not fully implemented (I’m too confident ).

You just need to fill in the blanks for your needs. Here is the skeleton code here.

This is a Matrix Orbital GTT50A touch screen LCD with a QWERTY keyboard I threw together.  It is connected to an 8051 via serial, and sends a touch region code when a key is touched.  The 8051 looks up the code from a table, and determines which scan code/s to send out the PS/2 port.