home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
607.lha
/
PopUpMenu_v4.3
/
Source.LZH
/
Source
/
inputhandler.a
< prev
next >
Wrap
Text File
|
1991-10-23
|
6KB
|
220 lines
opt l+,c+,d+,y+
opt ow1+,ow2+,ow3+,ow4+,ow5+,ow6+
INCDIR ":Pspråk/asm/include/"
INCLUDE "exec/types.i"
INCLUDE "PopUpMenu.i"
QUALIFIERS EQU IEQUALIFIER_LSHIFT+IEQUALIFIER_RSHIFT+IEQUALIFIER_CONTROL+IEQUALIFIER_LALT+IEQUALIFIER_RALT+IEQUALIFIER_LCOMMAND+IEQUALIFIER_RCOMMAND
HOTKEYQUAL EQU IEQUALIFIER_CONTROL+IEQUALIFIER_LALT
xref _IBase * Intuitionbase in BSS segent
xdef @PopUpHandler
section text,code
@PopUpHandler: MOVEM.L D2/A2-A6,-(SP)
MOVEA.L A0,A3 * A3 = Events
MOVEA.L A1,A2 * A2 = MySignals
MOVEA.L A3,A4 * A4 = Event
SUB.L A5,A5 * A5 = LastEvent
MOVEA.L (AbsExecBase).W,A6
* ------------ Be sure that data does not change while we are processing inputs
LEA sd_Semaphore(A2),A0
JSR _LVOObtainSemaphore(A6)
MOVE.W sd_Down(A2),D2
BEQ.B NoMoveSignal
* ------------ Tell the task we are living.
MOVEA.L (A2),A1 * sd_PopUpMenuTask
MOVE.L sd_MouseMovedSig(A2),D0
JSR _LVOSignal(A6)
* ------------ No more events ?
NoMoveSignal:
MoreEvents: MOVE.L A4,D0
BEQ.W Done
* ------------ Mouseevent ?
MOVEQ.L #IECLASS_RAWMOUSE,D0
CMP.B ie_Class(A4),D0
BNE.W CheckHotKey
MOVE.W ie_Code(A4),D1
* ------------ Is menubutton already pressed.
TST.W D2
BNE.W MouseIsDown * Yes
* ------------ Menubutton pressed ?
CMPI.W #MENUDOWN,D1
BNE.W KeepEvent * No
* ------------ Is any other mousebutton pressed
MOVE.W ie_Qualifier(A4),D1
MOVE.W #IEQUALIFIER_MIDBUTTON+IEQUALIFIER_LEFTBUTTON,D0
AND.W D1,D0
BNE.W KeepEvent * Yes
* ------------ Qualifier pressed ?
MOVE.W #QUALIFIERS,D0
AND.W D1,D0
BEQ.B 1$ * No
* ------------ pop-up the menues with qualifier ?
BTST #POPUPWITHQUAL,sd_Options(A2)
BEQ.W KeepEvent * No
BRA.B MenuButtonOk
* ------------ Pop-up the menues without qualifier
1$ BTST #POPUPNOQUAL,sd_Options(A2)
BEQ.W KeepEvent * No
* ------------ Is any screen active ?
MenuButtonOk: MOVEA.L _IBase,A1
MOVEA.L ib_ActiveScreen(A1),A0
MOVE.L A0,D0
BEQ.W KeepEvent * No
* ------------ Is the mouse in the titlebar ?
MOVE.B sc_BarHeight(A0),D0
EXT.W D0
CMP.W sc_MouseY(A0),D0
BGT.W KeepEvent * Yes
* ------------ Is any window active ?
MOVEA.L ib_ActiveWindow(A1),A0
MOVE.L A0,D0
BEQ.W KeepEvent * No
* ------------ Is any requester blocking the window ?
TST.W wd_ReqCount(A0)
BNE.W KeepEvent * Yes
* ------------ Does the window have menues ?
TST.L wd_MenuStrip(A0)
BEQ.W KeepEvent * No
* ------------ Is the RMBTRAP flag set ?
MOVEQ.L #1,D0
AND.W wd_Flags(A0),D0
BNE.W KeepEvent * Yes
* ------------ Is a string gadget active ? [New 4.2]
MOVE.L wd_FirstGadget(A0),A0
02$ MOVE.L A0,D0
BEQ.B 08$
CMPI.W #STRGADGET,gg_GadgetType(A0)
BNE.B 05$
BTST #7,gg_Flags+1(A0)
BNE.W KeepEvent * A string gadget is active
05$ MOVE.L (A0),A0 * gg_NextGadget
BRA.B 02$
* ------------ Everything OK
08$ MOVEQ.L #1,D2
* ------------ ClickMenues ?
BTST #CLICKMENUES,sd_Options(A2)
BEQ.B 1$ * No
* ------------ Menubutton must be released twice
MOVEQ.L #3,D2
* ------------ Tell task to popup the menues.
1$ MOVE.L sd_MenuDownSig(A2),D0
BRA.B SigAndRemove
* ------------ Check out if the user has selected something.
* ------------ Is menubutton released ?
MouseIsDown: CMPI.W #MENUUP,D1
BNE.B 1$ * No
* ------------ (--Down) == 0 ?
05$ SUBQ.W #1,D2
BNE.B RemoveEvent * No
* ------------ Tell our task.
MOVE.L sd_MenuUpSig(A2),D0
BRA.B SigAndRemoveQ
* ------------ Is menubutton pressed again (Can only happen if CLICKMENUES)
1$ CMPI.W #MENUDOWN,D1
BEQ.B 05$
* ------------ Multiple select ?
CMPI.W #SELECTDOWN,D1
BNE.B CheckSelUp * No
MOVE.L sd_SelectDownSig(A2),D0
SigAndRemoveQ: MOVE.W ie_Qualifier(A4),sd_EndQualifier(A2) * Save qualifier
SigAndRemove: MOVEA.L (A2),A1 * sd_PopUpMenuTask(A2)
JSR _LVOSignal(A6)
BRA.B RemoveEvent
* ------------ SELECTUP isn't used but remove the event anyway
* ------------ Intuition may be confused since no SELECTDOWN is sent.
CheckSelUp: CMPI.W #SELECTUP,D1
BNE.B KeepEvent * No
* ------------ Remove the event from the list.
RemoveEvent: MOVE.L A5,D0 * First event in list ?
BNE.B 1$ * No
MOVEA.L (A4),A3 * ie_NextEvent(A4)
BRA.B NextEvent
1$: MOVE.L (A4),(A5) * ie_NextEvent(A4),ie_NextEvent(A5)
BRA.B NextEvent
* ------------ Hot-key while menu down ? [ not allowed ]
CheckHotKey: TST.W D2
BNE.B KeepEvent * Yes
* ------------ Key event ?
MOVEQ.L #IECLASS_RAWKEY,D0
CMP.B ie_Class(A4),D0
BNE.B KeepEvent * No
* ------------ Qualifiers pressed ?
MOVE.W #QUALIFIERS,D0
AND.W ie_Qualifier(A4),D0
CMP.W #HOTKEYQUAL,D0
BNE.B KeepEvent * No
* ------------ Hot-key ?
MOVE.W ie_Code(A4),D0
CMP.B sd_HotKey(A2),D0
BNE.B KeepEvent
* ------------ Tell task Hot-Key pressed
MOVE.L sd_HotKeySig(A2),D0
BRA.B SigAndRemove
* ------------ Keep this message.
KeepEvent: MOVE.L A4,A5
* ------------ Check out the next event.
NextEvent: MOVE.L (A4),A4 * ie_NextEvent(A4)
BRA.W MoreEvents
Done: MOVE.W D2,sd_Down(A2)
* ------------ Release semaphore
LEA sd_Semaphore(A2),A0
JSR _LVOReleaseSemaphore(A6)
* ------------ return Events
MOVE.L A3,D0
MOVEM.L (SP)+,D2/A2-A6
RTS
END