home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.os.msdos.programmer:10523 alt.msdos.programmer:2714 comp.sys.ibm.pc.programmer:569
- Path: 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
-
- 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
-