www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/03/14/10:40:52

Xref: news2.mv.net comp.os.msdos.djgpp:1846
From: Shawn Hargreaves <slh100 AT york DOT ac DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: How do I correctly set a mouse interrupt handler?
Date: Thu, 14 Mar 1996 13:17:45 +0000
Organization: The University of York, UK
Lines: 36
Message-ID: <Pine.SGI.3.91.960314131228.21208D-100000@tower.york.ac.uk>
References: <199603112353 DOT SAA29338 AT delorie DOT com>
NNTP-Posting-Host: tower.york.ac.uk
Mime-Version: 1.0
In-Reply-To: <199603112353.SAA29338@delorie.com>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

On Mon, 11 Mar 1996, William Parsons Newhall, Jr. wrote:

> just joined their ranks.  When I move my mouse, Windows95 intervenes
> saying that an exception has just occurred...has anyone successfully
> written a djgpp handler? Could they tell me how they did it?

Your code looked more or less ok to me. A major issue which you aren't 
addressing, though, is memory locking, which is pretty important. You 
need to lock all the code and data used in your mouse callback. The 
easiest way to do this is just to set the _crt0_startup_flags with the 
lock all memory flag (sorry I can't remember the exact syntax, but it is 
in the libc docs and the FAQ).

If you want an example of a working mouse handler, take a look at my 
Allegro library, x2ftp.oulu.fi/pub/msdos/programming/djgpp2/alleg20b.zip.

> void do_something(void)
> {
> printf("the mouse is moving!\n");
> }

That is a very bad move... Your mouse callback executes inside an 
interrupt context, and you must _not_ make any DOS calls or call library 
functions like printf() inside them. About all you can reliably do inside 
a mouse handler is to alter a bunch of global variables. I even had problems 
drawing a mouse pointer inside the callback: in the end I just set a flag 
when the mouse moved and then checked this to display the pointer inside my 
timer handler.


..---------------------------------------------------------------.
|   Shawn Hargreaves   |   Why is 'phonetic' spelt with a ph?   |
|---------------------------------------------------------------|
|  Check out Allegro and FED on http://www.york.ac.uk/~slh100/  |
`---------------------------------------------------------------'

- Raw text -


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