From 1b0344660de2832b472b0a413c50ff7f111a9293 Mon Sep 17 00:00:00 2001 From: Javier Date: Sun, 30 Aug 2026 02:21:09 +0200 Subject: first steps towards (optional) serial mouse support --- mousetsr.h | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) (limited to 'mousetsr.h') diff --git a/mousetsr.h b/mousetsr.h index f33dc11..704f670 100644 --- a/mousetsr.h +++ b/mousetsr.h @@ -38,6 +38,8 @@ #define USE_WHEEL 1 /** Enable Intellimouse Explorer protocol (two wheels and 5 buttons). */ #define USE_IMEX 1 +/** Enable support for serial mouse. */ +#define USE_SERIAL 1 /** Trace mouse events verbosily. */ #define TRACE_EVENTS 0 /** Trace (noisy) API calls. */ @@ -53,11 +55,14 @@ #define USE_INTEGRATION (USE_VIRTUALBOX || USE_VMWARE) -/** Max size of PS/2 packet that we support. */ -#define MAX_PS2_PACKET_SIZE 4 +/** Max size of PS/2/serial packet that we support. */ +#define MAX_PACKET_SIZE 4 -/** Maximum number of 55ms ticks that may pass between two bytes of the same PS/2 packet */ -#define MAX_PS2_PACKET_DELAY 2 +/** Maximum number of 55ms ticks that may pass between two bytes of the same packet */ +#define MAX_PACKET_DELAY 2 + +/** Maximum COMn port. */ +#define MAX_PORTS 4 /** Maximum number of buttons supported by this driver. */ #define MAX_BUTTONS 5 @@ -97,11 +102,15 @@ enum { typedef struct tsrdata { // TSR installation data + // Note that because of WatcomC limitations the offsets of these + // are hardcoded in the inline ASM, so do not change them. /** Previous int33 ISR, storing it for uninstall. */ void (__interrupt __far *prev_int33_handler)(); -#if USE_WIN386 + /** Previous ISR for IRQ 3 or 4, depending on the used serial port. */ + void (__interrupt __far *prev_irq3_4_handler)(); + /** Previous int2f ISR, may need to chain to it. */ void (__interrupt __far *prev_int2f_handler)(); -#endif + // Settings configured via the command line #if USE_WHEEL /** Whether to enable & use wheel mouse. */ @@ -126,24 +135,28 @@ typedef struct tsrdata { struct point screen_granularity; // Detected mouse hardware & status - /** Current negotiated PS/2 device_id */ + /** Current mouse's port. 0 = PS/2 , 1...N serial. */ + uint8_t port; + /** Current negotiated PS/2 device_id (or serial mouse type) */ uint8_t device_id; /** Number of buttons of current device. */ uint8_t num_buttons; -#if USE_WHEEL /** Number of wheels of current device. */ uint8_t num_wheels; -#endif - /** Packet size that the BIOS is currently using. Either 1 (streaming) or 3 (plain). */ + /** Packet size that the PS/2 BIOS is currently using. Either 1 (streaming) or 3 (plain). */ uint8_t bios_packet_size; /** Packet size that we are currently expecting internally. Usually 3 (plain) or 4 (with wheel). */ uint8_t packet_size; /** For streaming mode: number of bytes received so far (< packet_size). */ uint8_t cur_packet_bytes; - /** Stores the bytes received so far (cur_bytes). */ - uint8_t ps2_packet[MAX_PS2_PACKET_SIZE]; + /** Stores the bytes received so far (cur_packet_bytes). */ + uint8_t cur_packet[MAX_PACKET_SIZE]; /** Number of ticks at the point when we started to receive this packet. */ uint16_t cur_packet_ticks; + /** IO base for the current port. */ + uint16_t port_io; + /** IRQ for the current port. */ + uint8_t port_irq; // Current mouse settings /** Mouse sensitivity/speed. */ @@ -255,6 +268,8 @@ typedef TSRDATA __far * LPTSRDATA; extern void __declspec(naked) __far int33_isr(void); +extern void __declspec(naked) __far irq3_4_isr(void); + extern void __declspec(naked) __far int2f_isr(void); extern LPTSRDATA __far get_tsr_data(bool installed); -- cgit v1.2.3