Article View: comp.sys.amiga.tech
Article #7263Re: Mouse Buttons
From: Daryl Scott Cantrell
Date: Fri, 07 Dec 1990 22:37
Date: Fri, 07 Dec 1990 22:37
61 lines
3213 bytes
3213 bytes
In article <faheyr.660601986@silver> faheyr@silver.ucs.indiana.edu (Bob Fahey <NECR0SIS>) writes:
>lances@techbook.com (Lance Shorb) writes:
>> I'm interested in finding a method to determine the status of both mouse
>> buttons (ie. LeftDown, LeftUp, RightDown, RightUp) without having to
>> sort through a pile of IDCPM, or CONSOLE device messages.
>> There's got to be an easier way.
>
>Yes, indeed, there is an easier way: Check the registers.
>From what I remember, here's how it goes:
>
>mouse: btst #6,$bfe001 ;0 = lbutton up, 1 = lbutton down
> beq.s out
> btst #10,$dff016 ;0 = rbutton up, 1 = rbutton down
> bne.s mouse
>out: ...
>
>This will repeat the loop until either the l- or r-button is hit.
[...]
Amazing. You just broke two cardinal rules of Amiga programming in
but four lines. I guess assembly really is more powerful then C..
1) That's a dumb loop. Never never never on a multitasking system.
2) You're reading the hardware registers directly when there's no need
to. Intuition supports a perfectly valid way to do this.
3) From a pure functionality standpoint, I don't think that's what he
wanted to do. Your loop busy waits (never never) until one button
or the other is pushed (assuming the registers haven't been moved
elsewhere and you're not checking irrelavent data..). From the way
he phrased it, I believe he meant to simply have something like BOOL
LMB and BOOL RMB which he could check arbitrarily.
To the original poster:
I'll mail you the code to do it "the right way" if you'll tell me:
a) is this in your own custom screen?
b) will you be using menus?
c) will you need to be able to access both buttons or just the left?
To the query about 3rd mouse button (sorry, zapped it..):
Hmm, the only real way to do it is by looking at hardware registers.
The GOOD way to program this is to write a device driver which takes
this into account. For the BAD way, modify your own code from above..
>>Lance Shorb Voice: 1-503-230-7747
>>lances@techbook.COM ...!{tektronix!nosun,uunet}techbook!lances
>bob
>| ///| a.k.a. NECR0SIS faheyr@silver.ucs.indiana.edu -or- |
>| \\\///_| faheyr@rose.ucs.indiana.edu |
--
Programmer = (BypassesOpSys ? HAS_NO_TALENT : HAS_TALENT);
+---------------------------------------+----------------------------+
| // Daryl S. Cantrell | These opinions are |
| |\\\ milamber@caen.engin.umich.edu | shared by all of // |
| |// Evolution's over. We won. | Humanity. \X/ |
Technical Details
Message-ID:
<1990Dec7.223736.15332@engin.umich.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!sol.ctr.columbia.edu!caen!mr2.engin.umich.edu!milamberReferences:
<1990Dec7.041658.14294@techbook.com> <faheyr.660601986@silver>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!sol.ctr.columbia.edu!caen!mr2.engin.umich.edu!milamber From: milamber@caen.engin.umich.edu (Daryl Scott Cantrell) Newsgroups: comp.sys.amiga.tech Subject: Re: Mouse Buttons Message-ID: <1990Dec7.223736.15332@engin.umich.edu> Date: 7 Dec 90 22:37:36 GMT References: <1990Dec7.041658.14294@techbook.com> <faheyr.660601986@silver> Sender: news@engin.umich.edu (CAEN Netnews) Organization: University of Michigan Engineering, Ann Arbor Lines: 61