For the PS/2 mouse port perhaps you could bypass some of the complexity by using the Interrupt 15h pointing device interface. I have no idea how practical this would be, because as far as I can see the attached device would need to more or less emulate a PS/2 mouse, or at least the packet interface.
I posted a test, coded in FreeBASIC,
here.I used to do a lot of coding in QB and PDS, sometimes combined with MASM modules, but for this sort of thing I now much prefer the DOS version of
FreeBASIC, 32-bit instructions and address space, inline assembly (GAS, but using Intel syntax), naked functions, macros, etc.