delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/01/12/06:01:43

From: Fabrice ILPONSE <fabrice AT trash DOT lip6 DOT fr>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: My mouse code returns a wierd button value
Date: Mon, 12 Jan 1998 11:57:10 +0100
Organization: Universites Paris VI/Paris VII - France
Lines: 39
Message-ID: <34B9F706.40F4@trash.lip6.fr>
References: <6992ta$og4 AT examiner DOT concentric DOT net>
NNTP-Posting-Host: asim.lip6.fr
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Andy Fung wrote:
> 
> Hi,
> I'm having trouble with a mouse class I wrote for Djgpp v2 C++. When I call
> the interrupt to get the status of the buttons, I get a value of 327680 in
> the button status. This only happens once in a while, but its getting pretty
> frustrating. Please see the codes at the bottom to see if there are any
> errors in it :)
> 
> int mouse::is_right (void) // checks if right button is pressed
> {
> update ();
> if (buttons == 2 || buttons == 3)

	to check buttons use masks:

	eg. if (buttons & 2) is equal to the previous test.
	for the left button: (buttons & 1)
	even if some bits of buttons have no meaning, you're test'll work.

> }
> void mouse::update (void) // updates the status of the mouse
> {
> union REGS regs;
> regs.x.ax = 0x03;
> int86 (0x33, &regs, &regs);
> buttons = regs.x.bx;

	if you define buttons as an int, try to define it as a short.


-- 
	^ ^ ^
	| | |
	+-+-+	Fabrice ILPONSE
	  |	<fabrice AT asim DOT lip6 DOT fr>
	  |
	  |
	  -

- Raw text -


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