[comp.lang.pascal] Where's my mouse?

Adams@J (jma@gnu.ai.mit.edu) (11/05/90)

I'm trying to find out the proper call to see if a microsoft mouse is
connected to a system or not (And , if the driver is loaded or not.)
Microsoft doesn't seem to be of any help in this , just telling me to
buy their book on programming their mouse.. (No sense to spend money for
one call, right?) I'm currently using the following routine, which doesn't
seem to work:

function MsMouse : boolean;
var
  mseg, m  : integer;
Begin
  mseg := 256 * mem[$0000:0207] + mem[$0000:0206];
  m    := 256 * mem[$0000:0205] + mem[$0000:0206];
  if (mseg <> 0) and (m <> 2) then
    Msmouse := true
  else
    msmouse := false;
end;  { MsMouse }

Any ideas will be appreciated! Email me... Thanks.



-+-+-+-                                                                 -+-+-+-
John Adams                                       INTERNET -> jma@gnu.ai.mit.edu

 "What you get is all real; I can't put on an act, it takes brains to do
  that anyway..." -- XTC
-=-=-=-                                                                 -=-=-=-

abcscnuk@Twg-S5.uucp (Naoto Kimura (ACM)) (11/05/90)

function MouseInstalled : Boolean;
    var
	Regs	: Registers;
    begin
	Regs.AX = 0;	(* Init Mouse *)
	Intr($33,Regs);
	MouseInstalled := (Regs.AX <> 0);
    end.

Of course, a better solution would be to make a unit that would have in
its initialization code a call to the initialize procedure, which then
sets a boolean variable.  In your program, all you would need to do is
to read that boolean variable.  There was a posting a while ago that
contained such a unit (from of an article in the short-lived Borland's
Turbo Technix).

                //-n-\\			 Naoto Kimura
        _____---=======---_____		 (abcscnuk@csuna.csun.edu)
    ====____\   /.. ..\   /____====
  //         ---\__O__/---         \\	Enterprise... Surrender or we'll
  \_\                             /_/	send back your *&^$% tribbles !!

mead@uxh.cso.uiuc.edu (11/07/90)

This is a good solution, but (at least on my machine) it takes about
a second (ie literally ~1000 miliseconds).

I was hoping someone (brighter than I) would know how to (where to)
directly access the mouse driver (and thus determine it's existance).

-alan mead : mead@uxh.cso.uiuc.edu

bobb@vice.ICO.TEK.COM (Bob Beauchaine) (11/08/90)

In article <13000017@uxh.cso.uiuc.edu> mead@uxh.cso.uiuc.edu writes:
>
>I was hoping someone (brighter than I) would know how to (where to)
>directly access the mouse driver (and thus determine it's existance).

  I thought there would be a multitude of appropriate answers to this
  post by now, but this is the method I use.

  (I've lost the original post, so I assume you're using Turbo Pascal).

  The easiest way to determine the existence of a mouse is to check
  interrupt vector $33 (33 hex).  *All* Microsoft compatible mouse
  drivers intercept this vector for compatibility.  

  There are three possibilities for this interrupt vector.  

  1.  The vector itself (i.e., the byte at memory location 0000:0033 
       hex is 0).  Conclusion : no mouse present.

  2.  The byte pointed to by vector $33 is an interrupt return 
      instruction, $CF.  I.e, byte(ptr(0,$33)^) = CF.  
      Conclusion : no mouse present.

  3.  Neither of the above.  Conclusion : a mouse driver is present.

  I have never seen this method fail.

  Bob Beauchaine
  bobb@vice.ICO.TEK.COM