🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #3601

Re: How can I check which COM port a mouse is attached to ?

#3601
From: Lee Hollingworth
Date: Wed, 11 Nov 1992 19:42
64 lines
2217 bytes
meikel@marie.physik.tu-berlin.de (Michael Feig) writes:

>I'm writing kind of a terminal program with mouse support.

>In order to prevent the initialisation of the COM port, where the mouse
>is attached to, which wouldn't be a good idea, because I couldn't use
>the mouse anymore afterwards, I need to find out, either if a COM port is
>used by a mouse or which COM port the mouse is attached to, if any.

>Has anybody an idea how to perform this ?

You could use Int 33h functions 00h - initialise mouse 24h - get version in
some inline assembly or via the int86 function.
Use the IRQ number returned from the call to function 24h and work out which
COM port is being used from that...

/* MSC 6.0 code */
#include <stdio.h>

#define M_SERIAL            2
#define M_INSTALLED        -1
#define M_NOT_INSTALLED     0

typedef unsigned char byte;

int check_mouse(void)
{
    int m_inst;
    byte m_type;
    byte m_irq;
    byte port = 0;

    _asm {
        xor     ax, ax
        int     33h
        mov     m_inst, ax
    }

    if (m_inst == M_NOT_INSTALLED)
        return 0;

    _asm {
        mov     ax, 24h
        int     33h
        mov     m_type, ch
        mov     m_irq, cl
    }

    if (m_type == M_SERIAL) {
        if (m_irq != 0) {           /* 0 == PS/2  */
            /* do stuff here to match IRQ and COM port -- if possible */
            switch (m_irq) {
                /* IRQ 2, 3, 4, 5, or 7 set port to COM number if applicable */
                ...
                ...
            }
        }
    }

    return port;
}

Lee Hollingworth
s1110238@giaeb.cc.monash.edu.au
Technical Details
Message-ID: <s1110238.721510946@giaeb>
Path: arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!goanna!escargot!monu6!giaeb!s1110238
References: <1dlqllINNhqn@mailgzrz.TU-Berlin.DE>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!goanna!escargot!monu6!giaeb!s1110238
From: s1110238@giaeb.cc.monash.edu.au (Lee Hollingworth)
Newsgroups: comp.os.msdos.programmer,alt.msdos.programmer,comp.sys.ibm.pc.programmer
Subject: Re: How can I check which COM port a mouse is attached to ?
Keywords: mouse, com-port
Message-ID: <s1110238.721510946@giaeb>
Date: 11 Nov 92 19:42:26 GMT
References: <1dlqllINNhqn@mailgzrz.TU-Berlin.DE>
Sender: news@monu6.cc.monash.edu.au (Usenet system)
Organization: Monash University, Melb., Australia.
Lines: 64