Um meinen alten Acorn RISC PC in mein KVM Switch Setup zu integrieren, war ich schon länger auf der Suche nach einem Adapter, um USB Eingabegeräte an PS/2 Buchsen des Rechners anzuschließen. Am besten so, dass man auch mit nur einem USB Anschluss machen kann, an dem ein Hub hängt. Mein KVM Switch gibt die USB Geräte nämlich nur mit einem Kabel an die Rechner weiter.
Es gibt zwar fertige Adapter, aber die sind recht teuer. Daher versuche ich jetzt mir selbst so einen Adapter selbst zu bauen, auf Basis eines ESP32-S3. Der ESP32 sollte für diese Aufgabe eigentlich überqualifiziert sein, aber so habe ich noch Kapazitäten frei für zusätzliche ‚Spielereien‘ wie ein Web-Interface, Firmware Updates Over-The-Air usw.
Die Hardware löte ich mehr oder weniger fliegend auf einer Platine zusammen:

Den Quellcode und weitere Details zur Verdrahtung habe ich auf Github bereitgestellt:
A USB HID to PS/2 computer adapter
https://github.com/mortara/PS2USB
0 forks.
1 stars.
0 open issues.
Recent commits:
- Improve PS2 mouse timing and clicks, Patrick Mortara
- Merge pull request #1 from mortara/claude/clever-bohr-9yrrmfParse HID report descriptors to extract mouse layout dynamically, GitHub
- Fix four issues flagged in code review- extractBitsSigned: return 0 for truncated reports instead of reading partial bytes and sign-extending them into bogus values; guard checks the entire field fits before touching any data.- parseHIDMouseLayout: expand bitOffsets[] from 32 to 256 entries so every valid report ID (0-255) maps to its own slot; eliminates the aliasing that corrupted the no-ID case when IDs >= 32 were seen.- parseHIDMouseLayout: enforce that X, Y, and Wheel all belong to the same report ID. When a new X is found under a different ID than a previously recorded X, Y/Wheel state is reset to avoid mixing field offsets from two distinct report formats.- onMouse: mask buttons to 0x07 before change detection and before storing prevButtons. Mice with more than 3 buttons can set bits 3+ which the PS/2 change-handling code never processes, leading to spurious btnsChanged events and inconsistent prevButtons state.https://claude.ai/code/session_01Cv5Fd2nocxngaKsX5Jsjn8, Claude
- Document the HID descriptor-based mouse detection system in READMEhttps://claude.ai/code/session_01Cv5Fd2nocxngaKsX5Jsjn8, Claude
- Parse HID report descriptor to support any USB mouse layoutReplace the hardcoded 12-bit report parser with a generic descriptor-drivenapproach. On device connect, parseHIDMouseLayout() walks the raw HID descriptor(Global/Local/Main items) to find the bit offsets, bit widths, and logicalranges of X, Y, Wheel, and buttons. The onMouse callback then extracts allfields via extractBitsSigned() instead of assuming a fixed byte layout.Falls back to library-provided values (evt.x/y/wheel/buttons) when no mouselayout can be parsed from the descriptor, so devices that don't expose adescriptor still work. mouseLayout is reset on disconnect so the next deviceis parsed fresh.https://claude.ai/code/session_01Cv5Fd2nocxngaKsX5Jsjn8, Claude