FabGL
ESP32 Display Controller and Graphics Library
PS/2 ports schema

PS2 Keyboard or Mouse connection uses two GPIOs (data and clock) and requires one 120 Ohm series resistor and one 2K Ohm pullup resistor for each signal:

schema_PS2.png

Using above GPIOs the PS2 Mouse Controller may be initialized in this way:

Mouse.begin(GPIO_NUM_26, GPIO_NUM_27);  // clk, dat

When both a mouse and a keyboard are connected initialization must be done directly on PS2Controller, in this way:

fabgl::PS2Controller PS2Controller;
fabgl::Keyboard Keyboard;
fabgl::Mouse Mouse;

// port 0 (keyboard) CLK and DAT, port 1 (mouse) CLK and DAT
PS2Controller.begin(GPIO_NUM_33, GPIO_NUM_32, GPIO_NUM_26, GPIO_NUM_27);
// initialize keyboard on port 0 (GPIO33=CLK, GPIO32=DAT)
Keyboard.begin(true, true, 0);
// initialize mouse on port 1 (GPIO26=CLK, GPIO27=DAT)
Mouse.begin(1);

A simplified way to configure Mouse and Keyboard, when you have all GPIOs as before is:

fabgl::PS2Controller PS2Controller;
PS2Controller.begin(PS2Preset::KeyboardPort0_MousePort1);