diff options
author | Javier <dev.git@javispedro.com> | 2022-03-13 00:43:23 +0100 |
---|---|---|
committer | Javier <dev.git@javispedro.com> | 2022-03-13 00:43:23 +0100 |
commit | 0ebcd2c1c9148e8647a5b2f89654949435403058 (patch) | |
tree | 76c7f68dabfa08734cd1f13b3532bf86d6d7c6d5 | |
parent | 22ceecd84d84594fb1a87e0b2448d8cf4e60e4b9 (diff) | |
download | vbmouse-0ebcd2c1c9148e8647a5b2f89654949435403058.tar.gz vbmouse-0ebcd2c1c9148e8647a5b2f89654949435403058.zip |
let VMD know the mouse type
-rw-r--r-- | int2fwin.h | 48 | ||||
-rw-r--r-- | makefile | 2 | ||||
-rw-r--r-- | mousew16.c | 11 | ||||
-rw-r--r-- | ps2.h | 5 |
4 files changed, 64 insertions, 2 deletions
@@ -32,6 +32,11 @@ enum int2f_functions INT2F_NOTIFY_FOREGROUND_SWITCH = 0x4002 }; +enum vxd_device_ids +{ + VMD_DEVICE_ID = 0xC +}; + static bool windows_386_enhanced_mode(void); #pragma aux windows_386_enhanced_mode = \ "mov ax, 0x1600" \ @@ -41,6 +46,49 @@ static bool windows_386_enhanced_mode(void); __value [al] \ __modify [ax] +static LPFN win_get_vxd_api_entry(uint16_t devid); +#pragma aux win_get_vxd_api_entry = \ + "mov ax, 0x1684" /* Get Device Entry Point Address */ \ + "int 0x2F" \ + __parm [bx] \ + __value [es di] \ + __modify [ax] + +/* VMD (Virtual Mouse Device) API */ + +enum vmd_apis { + VMD_GET_VERSION = 0x0, + VMD_SET_MOUSE_TYPE = 0x100, +}; + +enum vmd_mouse_type { + VMD_TYPE_UNDEFINED = 0, + VMD_TYPE_BUS = 1, + VMD_TYPE_SERIAL = 2, + VMD_TYPE_INPORT = 3, + VMD_TYPE_PS2 = 4, + VMD_TYPE_HP = 5 +}; + +static inline int vmd_get_version(LPFN *vmd_entry); +#pragma aux vmd_get_version = \ + "mov ax, 0x000" \ + "call dword ptr es:[di]" \ + __parm [es di] \ + __value [ax] + +static inline bool vmd_set_mouse_type(LPFN *vmd_entry, uint8_t mousetype, int8_t interrupt, int8_t com_port); +#pragma aux vmd_set_mouse_type = \ + "stc" /* If nothing happens, assume failure */ \ + "mov ax, 0x100" \ + "call dword ptr es:[di]" \ + "setnc al" \ + __parm [es di] [bl] [bh] [cl] \ + __value [al] \ + __modify [ax] + +/* Miscelaneous helpers. */ + static inline void hook_int2f(LPFN *prev, LPFN new) { *prev = _dos_getvect(0x2F); @@ -6,7 +6,7 @@ set include=$(%watcom)/h/win;$(%watcom)/h # The main driver file -vbmouse.drv: mousew16.c mousew16.h vbox.c vbox.h vboxdev.h ps2.h pci.h vds.h +vbmouse.drv: mousew16.c mousew16.h vbox.c vbox.h vboxdev.h ps2.h pci.h vds.h int2fwin.h # -bd to build DLL # -mc to use compact memory model (far data pointers, since ss != ds) # -zu for DLL calling convention (ss != ds) @@ -212,6 +212,15 @@ BOOL FAR PASCAL LibMain(HINSTANCE hInstance, WORD wDataSegment, } #endif + // When running under protected mode Windows, let's tell VMD (the mouse virtualizer) + // what type of mouse we are going to be using + if (mouseflags & MOUSEFLAGS_HAS_WIN386) { + LPFN vmd_entry = win_get_vxd_api_entry(VMD_DEVICE_ID); + if (vmd_entry) { + vmd_set_mouse_type(&vmd_entry, VMD_TYPE_PS2, PS2_MOUSE_INT_VECTOR, 0); + } + } + return 1; } @@ -317,6 +326,6 @@ VOID FAR PASCAL Disable(VOID) /** Called by Window to retrieve the interrupt vector number used by this driver, or -1. */ int FAR PASCAL MouseGetIntVect(VOID) { - return 0x74; /* This corresponds to IRQ12, the PS/2 IRQ. At least in VirtualBox. */ + return PS2_MOUSE_INT_VECTOR; } @@ -23,6 +23,11 @@ #include <stdbool.h> #include <stdint.h> +/** Standard PS/2 mouse IRQ. At least on VirtualBox. */ +#define PS2_MOUSE_IRQ 12 +/** The corresponding interrupt vector for IRQ 12. */ +#define PS2_MOUSE_INT_VECTOR 0x74 + enum { PS2M_STATUS_BUTTON_1 = 1 << 0, PS2M_STATUS_BUTTON_2 = 1 << 1, |