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.