delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/09/29/19:15:51

Message-ID: <34303603.5224@nf.sympatico.ca>
Date: Mon, 29 Sep 1997 20:43:07 -0230
From: Colin Walsh <cwalsh AT nf DOT sympatico DOT ca>
Reply-To: cwalsh AT nf DOT sympatico DOT ca
Organization: Colossal Software
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
CC: djgpp AT delorie DOT com
Subject: How to keep the mouse pointer from jumping!

I've been seeing some posts about how if someone starts up the mouse
in... say
640x480x256, the pointer doesnt move smoothly. Anyways, I was faced with
this problem
a few weeks ago in implimenting my own GUI thingy. I read that VESA
modes
don't set properly, so I thought to myself that if I could fool the
mouse driver into another,
similar mode, it should move without jumping. So, I first set GRX into
640x480x16, initialized
the mouse, called 256 color mode, and it worked! If the resolution is
changed you can change
the mouse's bounding box to reflect this change (see source).

mouse.h
=======
typedef struct mouse{
        long x,y,button;
};
mouse testmouse();
void mouseon();
void mouseoff();

mouse.cpp
=========
#include <dos.h>
typedef struct mouse{
        long x,y,button;
};
mouse testmouse()
{
        union REGS bar;
        mouse out;
        bar.x.ax=3;
        int386(0x33,&bar,&bar);
        out.x=bar.x.cx; // x position of the mouse
        out.y=bar.x.dx; // y position of the mouse
        out.button=bar.x.bx; // button state of the mouse
        return(out);
}
void mouseon()
{
        union REGS bar;
        mouse out;
        bar.x.ax=1;
        int386(0x33,&bar,&bar);
        bar.x.ax=7;
        bar.x.cx=0;    // this is the minimum x
        bar.x.dx=640;  // this is the maximum x
        int386(0x33,&bar,&bar);
        bar.x.ax=8;
        bar.x.cx=0;    // this is the minimum y
        bar.x.dx=480;  // this is the maximum y
        int386(0x33,&bar,&bar);
}
void mouseoff()
{
        union REGS bar;
        mouse out;
        bar.x.ax=2;
        int386(0x33,&bar,&bar);
}

Hope this helps with some of your projects!
Colin Walsh
cwalsh AT nf DOT sympatico DOT ca

BTW - You need to keep polling testmouse to get button and position
status.
BTW2 - If you want to find all of the mouse interrupt calls, you should
       get Ralf Brown's Interrupt List.

- Raw text -


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