home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / os / msdos / programm / 10523 < prev    next >
Encoding:
Text File  |  1992-11-11  |  2.2 KB  |  78 lines

  1. Xref: sparky comp.os.msdos.programmer:10523 alt.msdos.programmer:2714 comp.sys.ibm.pc.programmer:569
  2. Path: sparky!uunet!munnari.oz.au!goanna!escargot!monu6!giaeb!s1110238
  3. From: s1110238@giaeb.cc.monash.edu.au (Lee Hollingworth)
  4. Newsgroups: comp.os.msdos.programmer,alt.msdos.programmer,comp.sys.ibm.pc.programmer
  5. Subject: Re: How can I check which COM port a mouse is attached to ?
  6. Keywords: mouse, com-port
  7. Message-ID: <s1110238.721510946@giaeb>
  8. Date: 11 Nov 92 19:42:26 GMT
  9. References: <1dlqllINNhqn@mailgzrz.TU-Berlin.DE>
  10. Sender: news@monu6.cc.monash.edu.au (Usenet system)
  11. Organization: Monash University, Melb., Australia.
  12. Lines: 64
  13.  
  14. meikel@marie.physik.tu-berlin.de (Michael Feig) writes:
  15.  
  16. >I'm writing kind of a terminal program with mouse support.
  17.  
  18. >In order to prevent the initialisation of the COM port, where the mouse
  19. >is attached to, which wouldn't be a good idea, because I couldn't use
  20. >the mouse anymore afterwards, I need to find out, either if a COM port is
  21. >used by a mouse or which COM port the mouse is attached to, if any.
  22.  
  23. >Has anybody an idea how to perform this ?
  24.  
  25. You could use Int 33h functions 00h - initialise mouse 24h - get version in
  26. some inline assembly or via the int86 function.
  27. Use the IRQ number returned from the call to function 24h and work out which
  28. COM port is being used from that...
  29.  
  30. /* MSC 6.0 code */
  31. #include <stdio.h>
  32.  
  33. #define M_SERIAL            2
  34. #define M_INSTALLED        -1
  35. #define M_NOT_INSTALLED     0
  36.  
  37. typedef unsigned char byte;
  38.  
  39. int check_mouse(void)
  40. {
  41.     int m_inst;
  42.     byte m_type;
  43.     byte m_irq;
  44.     byte port = 0;
  45.  
  46.     _asm {
  47.         xor     ax, ax
  48.         int     33h
  49.         mov     m_inst, ax
  50.     }
  51.  
  52.     if (m_inst == M_NOT_INSTALLED)
  53.         return 0;
  54.  
  55.     _asm {
  56.         mov     ax, 24h
  57.         int     33h
  58.         mov     m_type, ch
  59.         mov     m_irq, cl
  60.     }
  61.  
  62.     if (m_type == M_SERIAL) {
  63.         if (m_irq != 0) {           /* 0 == PS/2  */
  64.             /* do stuff here to match IRQ and COM port -- if possible */
  65.             switch (m_irq) {
  66.                 /* IRQ 2, 3, 4, 5, or 7 set port to COM number if applicable */
  67.                 ...
  68.                 ...
  69.             }
  70.         }
  71.     }
  72.  
  73.     return port;
  74. }
  75.  
  76. Lee Hollingworth
  77. s1110238@giaeb.cc.monash.edu.au
  78.