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 >
Text File  |  1991-10-23  |  6KB  |  220 lines

  1.            opt      l+,c+,d+,y+
  2.            opt      ow1+,ow2+,ow3+,ow4+,ow5+,ow6+
  3.         INCDIR           ":Pspråk/asm/include/"
  4.            INCLUDE      "exec/types.i"
  5.            INCLUDE      "PopUpMenu.i"
  6.  
  7. QUALIFIERS     EQU  IEQUALIFIER_LSHIFT+IEQUALIFIER_RSHIFT+IEQUALIFIER_CONTROL+IEQUALIFIER_LALT+IEQUALIFIER_RALT+IEQUALIFIER_LCOMMAND+IEQUALIFIER_RCOMMAND
  8. HOTKEYQUAL     EQU  IEQUALIFIER_CONTROL+IEQUALIFIER_LALT
  9.  
  10.            xref     _IBase       * Intuitionbase in BSS segent
  11.  
  12.            xdef     @PopUpHandler
  13.  
  14.            section     text,code
  15.  
  16. @PopUpHandler: MOVEM.L     D2/A2-A6,-(SP)
  17.            MOVEA.L     A0,A3          * A3 = Events
  18.            MOVEA.L     A1,A2          * A2 = MySignals
  19.            MOVEA.L     A3,A4          * A4 = Event
  20.            SUB.L     A5,A5          * A5 = LastEvent
  21.            MOVEA.L     (AbsExecBase).W,A6
  22.  
  23. * ------------ Be sure that data does not change while we are processing inputs
  24.            LEA     sd_Semaphore(A2),A0
  25.            JSR     _LVOObtainSemaphore(A6)
  26.  
  27.            MOVE.W     sd_Down(A2),D2
  28.            BEQ.B     NoMoveSignal
  29.  
  30. * ------------ Tell the task we are living.
  31.            MOVEA.L     (A2),A1          * sd_PopUpMenuTask
  32.            MOVE.L     sd_MouseMovedSig(A2),D0
  33.            JSR     _LVOSignal(A6)
  34.  
  35. * ------------ No more events ?
  36. NoMoveSignal:
  37. MoreEvents:    MOVE.L     A4,D0
  38.            BEQ.W     Done
  39.  
  40. * ------------ Mouseevent ?
  41.            MOVEQ.L     #IECLASS_RAWMOUSE,D0
  42.            CMP.B     ie_Class(A4),D0
  43.            BNE.W     CheckHotKey
  44.  
  45.            MOVE.W     ie_Code(A4),D1
  46.  
  47. * ------------ Is menubutton already pressed.
  48.            TST.W     D2
  49.            BNE.W     MouseIsDown      * Yes
  50.  
  51. * ------------ Menubutton pressed ?
  52.            CMPI.W     #MENUDOWN,D1
  53.            BNE.W     KeepEvent      * No
  54.  
  55. * ------------ Is any other mousebutton pressed
  56.            MOVE.W     ie_Qualifier(A4),D1
  57.            MOVE.W     #IEQUALIFIER_MIDBUTTON+IEQUALIFIER_LEFTBUTTON,D0
  58.            AND.W     D1,D0
  59.            BNE.W     KeepEvent      * Yes
  60.  
  61. * ------------ Qualifier pressed ?
  62.            MOVE.W     #QUALIFIERS,D0
  63.            AND.W     D1,D0
  64.            BEQ.B     1$          * No
  65.  
  66. * ------------ pop-up the menues with qualifier ?
  67.            BTST     #POPUPWITHQUAL,sd_Options(A2)
  68.            BEQ.W     KeepEvent      * No
  69.            BRA.B     MenuButtonOk
  70.  
  71. * ------------ Pop-up the menues without qualifier
  72. 1$           BTST     #POPUPNOQUAL,sd_Options(A2)
  73.            BEQ.W     KeepEvent      * No
  74.  
  75. * ------------ Is any screen active ?
  76. MenuButtonOk:  MOVEA.L     _IBase,A1
  77.            MOVEA.L     ib_ActiveScreen(A1),A0
  78.            MOVE.L     A0,D0
  79.            BEQ.W     KeepEvent      * No
  80.  
  81. * ------------ Is the mouse in the titlebar ?
  82.            MOVE.B     sc_BarHeight(A0),D0
  83.            EXT.W     D0
  84.            CMP.W     sc_MouseY(A0),D0
  85.            BGT.W     KeepEvent      * Yes
  86.  
  87. * ------------ Is any window active ?
  88.            MOVEA.L     ib_ActiveWindow(A1),A0
  89.            MOVE.L     A0,D0
  90.            BEQ.W     KeepEvent      * No
  91.  
  92. * ------------ Is any requester blocking the window ?
  93.            TST.W     wd_ReqCount(A0)
  94.            BNE.W     KeepEvent      * Yes
  95.  
  96. * ------------ Does the window have menues ?
  97.            TST.L     wd_MenuStrip(A0)
  98.            BEQ.W     KeepEvent      * No
  99.  
  100. * ------------ Is the RMBTRAP flag set ?
  101.            MOVEQ.L     #1,D0
  102.            AND.W     wd_Flags(A0),D0
  103.            BNE.W     KeepEvent      * Yes
  104.  
  105. * ------------ Is a string gadget active ? [New 4.2]
  106.            MOVE.L     wd_FirstGadget(A0),A0
  107.  
  108. 02$           MOVE.L     A0,D0
  109.            BEQ.B     08$
  110.  
  111.            CMPI.W     #STRGADGET,gg_GadgetType(A0)
  112.            BNE.B     05$
  113.  
  114.            BTST     #7,gg_Flags+1(A0)
  115.            BNE.W     KeepEvent      * A string gadget is active
  116.  
  117. 05$           MOVE.L     (A0),A0          * gg_NextGadget
  118.            BRA.B     02$
  119.  
  120. * ------------ Everything OK
  121. 08$           MOVEQ.L     #1,D2
  122.  
  123. * ------------ ClickMenues ?
  124.            BTST     #CLICKMENUES,sd_Options(A2)
  125.            BEQ.B     1$          * No
  126.  
  127. * ------------ Menubutton must be released twice
  128.            MOVEQ.L     #3,D2
  129.  
  130. * ------------ Tell task to popup the menues.
  131. 1$           MOVE.L     sd_MenuDownSig(A2),D0
  132.            BRA.B     SigAndRemove
  133.  
  134. * ------------ Check out if the user has selected something.
  135. * ------------ Is menubutton released ?
  136. MouseIsDown:   CMPI.W     #MENUUP,D1
  137.            BNE.B     1$          * No
  138.  
  139. * ------------ (--Down) == 0 ?
  140. 05$           SUBQ.W     #1,D2
  141.            BNE.B     RemoveEvent      * No
  142.  
  143. * ------------ Tell our task.
  144.            MOVE.L     sd_MenuUpSig(A2),D0
  145.            BRA.B     SigAndRemoveQ
  146.  
  147. * ------------ Is menubutton pressed again (Can only happen if CLICKMENUES)
  148. 1$           CMPI.W     #MENUDOWN,D1
  149.            BEQ.B     05$
  150.  
  151. * ------------ Multiple select ?
  152.            CMPI.W     #SELECTDOWN,D1
  153.            BNE.B     CheckSelUp      * No
  154.  
  155.            MOVE.L     sd_SelectDownSig(A2),D0
  156.  
  157. SigAndRemoveQ: MOVE.W     ie_Qualifier(A4),sd_EndQualifier(A2)   * Save qualifier
  158. SigAndRemove:  MOVEA.L     (A2),A1          * sd_PopUpMenuTask(A2)
  159.            JSR     _LVOSignal(A6)
  160.            BRA.B     RemoveEvent
  161.  
  162. * ------------ SELECTUP isn't used but remove the event anyway
  163. * ------------ Intuition may be confused since no SELECTDOWN is sent.
  164. CheckSelUp:    CMPI.W     #SELECTUP,D1
  165.            BNE.B     KeepEvent      * No
  166.  
  167. * ------------ Remove the event from the list.
  168. RemoveEvent:   MOVE.L     A5,D0          * First event in list ?
  169.            BNE.B     1$          * No
  170.            MOVEA.L     (A4),A3          * ie_NextEvent(A4)
  171.            BRA.B     NextEvent
  172. 1$:           MOVE.L     (A4),(A5)        * ie_NextEvent(A4),ie_NextEvent(A5)
  173.            BRA.B     NextEvent
  174.  
  175. * ------------ Hot-key while menu down ?   [ not allowed ]
  176. CheckHotKey:   TST.W     D2
  177.            BNE.B     KeepEvent      * Yes
  178.  
  179. * ------------ Key event ?
  180.            MOVEQ.L     #IECLASS_RAWKEY,D0
  181.            CMP.B     ie_Class(A4),D0
  182.            BNE.B     KeepEvent      * No
  183.  
  184. * ------------ Qualifiers pressed ?
  185.            MOVE.W     #QUALIFIERS,D0
  186.            AND.W     ie_Qualifier(A4),D0
  187.            CMP.W     #HOTKEYQUAL,D0
  188.            BNE.B     KeepEvent      * No
  189.  
  190. * ------------ Hot-key ?
  191.            MOVE.W     ie_Code(A4),D0
  192.            CMP.B     sd_HotKey(A2),D0
  193.            BNE.B     KeepEvent
  194.  
  195. * ------------ Tell task Hot-Key pressed
  196.            MOVE.L     sd_HotKeySig(A2),D0
  197.            BRA.B     SigAndRemove
  198.  
  199. * ------------ Keep this message.
  200. KeepEvent:     MOVE.L     A4,A5
  201.  
  202. * ------------ Check out the next event.
  203. NextEvent:     MOVE.L     (A4),A4          * ie_NextEvent(A4)
  204.            BRA.W     MoreEvents
  205.  
  206. Done:           MOVE.W     D2,sd_Down(A2)
  207.  
  208. * ------------ Release semaphore
  209.            LEA     sd_Semaphore(A2),A0
  210.            JSR     _LVOReleaseSemaphore(A6)
  211.  
  212. * ------------ return Events
  213.            MOVE.L     A3,D0
  214.  
  215.            MOVEM.L     (SP)+,D2/A2-A6
  216.            RTS
  217.  
  218.            END
  219.  
  220.