Mail Archives: djgpp/1998/01/05/22:16:55
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 -