From: Fabrice ILPONSE 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 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk 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, ®s, ®s); > buttons = regs.x.bx; if you define buttons as an int, try to define it as a short. -- ^ ^ ^ | | | +-+-+ Fabrice ILPONSE | | | -