home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Extras / Development / RKM_Companion_v2.04 / Input / Inputhandler.a < prev    next >
Encoding:
Text File  |  1999-10-27  |  5.6 KB  |  138 lines

  1. *
  2. * Copyright (c) 1992-1999 Amiga, Inc.
  3. *
  4. * This example is provided in electronic form by Amiga, Inc. for
  5. * use with the "Amiga ROM Kernel Reference Manual: Devices", 3rd Edition,
  6. * published by Addison-Wesley (ISBN 0-201-56775-X).
  7. *
  8. * The "Amiga ROM Kernel Reference Manual: Devices" contains additional
  9. * information on the correct usage of the techniques and operating system
  10. * functions presented in these examples.  The source and executable code
  11. * of these examples may only be distributed in free electronic form, via
  12. * bulletin board or as part of a fully non-commercial and freely
  13. * redistributable diskette.  Both the source and executable code (including
  14. * comments) must be included, without modification, in any copy.  This
  15. * example may not be published in printed form or distributed with any
  16. * commercial product.  However, the programming techniques and support
  17. * routines set forth in these examples may be used in the development
  18. * of original executable software products for Amiga computers.
  19. *
  20. * All other rights reserved.
  21. *
  22. * This example is provided "as-is" and is subject to change; no
  23. * warranties are made.  All use is at your own risk. No liability or
  24. * responsibility is assumed.
  25. *
  26. ****************************************************************************
  27. *
  28. *       InputHandler.a
  29. *
  30. * InputHandler that does a Left/Right mouse button swap...
  31. *
  32. *
  33. * See Swap_Buttons.c for details on how to compile/assemble/link...
  34. *
  35. ************************************************************************
  36. *
  37. * Required includes...
  38. *
  39. *       CSECT   InputHandler             ;SAS/Lattice ASM command requires this
  40. *
  41. *       INCDIR  "include:"               ;HX68 requires this
  42.  
  43.     section    text,code
  44.  
  45.         INCLUDE "exec/types.i"
  46.         INCLUDE "exec/io.i"
  47.         INCLUDE "devices/inputevent.i"
  48. *
  49. ************************************************************************
  50. *
  51. * Make the entry point external...
  52. *
  53.         xdef    _ButtonSwap
  54. *
  55. ************************************************************************
  56. *
  57. * This is the input handler that will swap the
  58. * mouse buttons for left handed use.
  59. *
  60. * The event list gets passed to you in  a0.
  61. * The is_Data field is passed to you in a1.
  62. * This example does not use the is_Data field...
  63. *
  64. * On exit you must return the event list in d0.  In this way
  65. * you could add or remove items from the event list.
  66. *
  67. ************************************************************************
  68. *
  69. * The handler gets called here...
  70. *
  71. _ButtonSwap:    move.l  a0,-(sp)        ; Save the event list
  72. *
  73. * Since the event list could be a linked list, we start a loop
  74. * here to handle all of the events passed to us.
  75. *
  76. CheckLoop:      move.w  ie_Qualifier(a0),d1             ; Get qualifiers...
  77.                 move.w  d1,d0                           ; Two places...
  78. *
  79. * Since we are changing left and right mouse buttons, we need to make
  80. * sure that we change the qualifiers on all of the messages.  The
  81. * left and right mouse buttons are tracked in the message qualifiers
  82. * for use in such things as dragging.  To make sure that we continue
  83. * to drag correctly, we change the qualifiers.
  84. *
  85. CheckRight:     btst    #IEQUALIFIERB_RBUTTON,d1        ; Check for right
  86.                 beq.s   NoRight
  87.                 bset    #IEQUALIFIERB_LEFTBUTTON,d0     ; Set the left...
  88.                 beq.s   CheckLeft
  89. NoRight:        bclr    #IEQUALIFIERB_LEFTBUTTON,d0     ; Clear the left...
  90. *
  91. CheckLeft:      btst    #IEQUALIFIERB_LEFTBUTTON,d1     ; Check for left
  92.                 beq.s   NoLeft
  93.                 bset    #IEQUALIFIERB_RBUTTON,d0        ; Set the right...
  94.                 beq.s   SaveQual
  95. NoLeft:         bclr    #IEQUALIFIERB_RBUTTON,d0        ; Clear the right...
  96. *
  97. SaveQual:       move.w  d0,ie_Qualifier(a0)             ; Save back...
  98. *
  99. * The actual button up/down events are transmitted as the
  100. * code field in RAWMOUSE events.  The code field must the be
  101. * checked and modified when needed on RAWMOUSE events.  If the
  102. * event is not a RAWMOUSE, we are done with it.
  103. *
  104.                 cmp.b   #IECLASS_RAWMOUSE,ie_Class(a0)  ; Check for mouse
  105.                 bne.s   NextEvent                       ; If not, next...
  106. *
  107.                 move.w  ie_Code(a0),d0                  ; Get code...
  108.                 move.w  d0,d1                           ; Save...
  109.                 and.w   #$7F,d0                         ; Mask UP_PREFIX
  110.                 cmp.w   #IECODE_LBUTTON,d0              ; Check for Left...
  111.                 beq.s   SwapThem                        ; If so, swap...
  112.                 cmp.w   #IECODE_RBUTTON,d0              ; Check for Right...
  113.                 bne.s   NextEvent                       ; If not, next...
  114. *
  115. SwapThem:       eor.w   #1,d1                           ; Flip bottom bit
  116.                 move.w  d1,ie_Code(a0)                  ; Save it...
  117. *
  118. * The event list is linked via a pointer to the next event
  119. * in the first element of the structure.  That is why it is not
  120. * nessesary to use:  move.l ie_NextEvent(a0),d0
  121. *
  122. * The reason I move to d0 first is that this also checks for zero.
  123. * The last event in the list will have a NULL ie_NextEvent field.
  124. * This is NOT as standard EXEC list where the node after the last
  125. * node is NULL.  Input events are single-linked for performance.
  126. *
  127. NextEvent:      move.l  (a0),d0                         ; Get next event
  128.                 move.l  d0,a0                           ; into a0...
  129.                 bne.s   CheckLoop                       ; Do some more.
  130. *
  131. * All done, just return the event list...  (in d0)
  132. *
  133.                 move.l  (sp)+,d0        ; Get event list back...
  134.                 rts                     ; return from handler...
  135. *
  136. *                                       ; SAS/Lattice ASM command requires this
  137.                 END
  138.