aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2022-03-13 00:43:23 +0100
committerJavier <dev.git@javispedro.com>2022-03-13 00:43:23 +0100
commit0ebcd2c1c9148e8647a5b2f89654949435403058 (patch)
tree76c7f68dabfa08734cd1f13b3532bf86d6d7c6d5
parent22ceecd84d84594fb1a87e0b2448d8cf4e60e4b9 (diff)
downloadvbados-0ebcd2c1c9148e8647a5b2f89654949435403058.tar.gz
vbados-0ebcd2c1c9148e8647a5b2f89654949435403058.zip
let VMD know the mouse type
-rw-r--r--int2fwin.h48
-rw-r--r--makefile2
-rw-r--r--mousew16.c11
-rw-r--r--ps2.h5
4 files changed, 64 insertions, 2 deletions
diff --git a/int2fwin.h b/int2fwin.h
index 8d79211..7845293 100644
--- a/int2fwin.h
+++ b/int2fwin.h
@@ -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);
diff --git a/makefile b/makefile
index 9cd59d6..c677d4d 100644
--- a/makefile
+++ b/makefile
@@ -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)
diff --git a/mousew16.c b/mousew16.c
index f2e22ab..45c0266 100644
--- a/mousew16.c
+++ b/mousew16.c
@@ -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;
}
diff --git a/ps2.h b/ps2.h
index 0ff154b..6fcb1ec 100644
--- a/ps2.h
+++ b/ps2.h
@@ -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,