www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/01/05/22:16:55

From: Matthew Mastracci <mmastrac AT acs DOT ucalgary DOT ca>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Writting a mouse driver... looking for help (this isn't a FAQ)
Date: Mon, 5 Jan 1998 19:40:43 -0700
Organization: The University of Calgary
Lines: 35
Message-ID: <68s5js$obe@ds2.acs.ucalgary.ca>
References: <34B18B58 DOT B961BDB3 AT execulink DOT com>
NNTP-Posting-Host: mmastrac AT acs2 DOT acs DOT ucalgary DOT ca
Mime-Version: 1.0
In-Reply-To: <34B18B58.B961BDB3@execulink.com>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

On Mon, 5 Jan 1998, Jeff Weeks wrote:

> What I'm wondering, though, is what my best (ie: fastest, and/or
> easiest) method would be.  I have a fair bit of mouse programming docs
> around here and I seem to remember that the mouse can be accessed from
> port 3F8.  Can anybody confirm that?  If so, can I read from ports
> without switching to real mode (never did figure that out... my guess is
> yes, but I need confirmation).

You *can* read the mouse directly, but unlike Linux (I believe), DOS
supports the bus and PS/2 mouse designs (almost the same thing).  You
should use the mouse interrupts, as they give you a common interface to
all three types.  Reading the mouse directly from the serial port
automatically kills the large section of the population who use the other
two styles, which is pretty significant.

You can, however, write an active-style mouse callback that gets called by
the installed mouse driver.  This requires about five minutes of work and
about ten lines of code.  See the Allegro source (to stick with pure C) or
my NASM tutoral (for Intel-syntax assembler) for examples.  You can keep
an internal counter for the mouse location/button status and have a
function that just reads these two values, making the entire process nice
and clean.

To answer your last question, yes, you can read the mouse directly from
the serial port in protected mode.  Using inport() doesn't require a
switch to real mode. 

Hope this helps!  :)

/\/\att /\/\astracci                  mmastrac AT acs DOT ucalgary DOT ca

"Tout choses sont dites deja, mais comme personne n'ecoute, il faut
toujours recommencer."

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019