inputevent.pas 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. {
  2. This file is part of the Free Pascal run time library.
  3. A file in Amiga system run time library.
  4. Copyright (c) 1998 by Nils Sjoholm
  5. member of the Amiga RTL development team.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. {$PACKRECORDS 2}
  13. {$IFNDEF FPC_DOTTEDUNITS}
  14. unit inputevent;
  15. {$ENDIF FPC_DOTTEDUNITS}
  16. INTERFACE
  17. {$IFDEF FPC_DOTTEDUNITS}
  18. uses Amiga.Core.Exec, Amiga.Core.Utility, Amiga.Core.Timer;
  19. {$ELSE FPC_DOTTEDUNITS}
  20. uses exec, utility, timer;
  21. {$ENDIF FPC_DOTTEDUNITS}
  22. const
  23. //------ constants
  24. //--- InputEvent.ie_Class
  25. IECLASS_NULL = $00; // A NOP input event
  26. IECLASS_RAWKEY = $01; // A raw keycode from the keyboard device
  27. IECLASS_RAWMOUSE = $02; // The raw mouse report from the game port device
  28. IECLASS_EVENT = $03; // A private console event
  29. IECLASS_POINTERPOS = $04; // A Pointer Position report
  30. IECLASS_TIMER = $06; // A timer event
  31. IECLASS_GADGETDOWN = $07; // select button pressed down over a Gadget (address in ie_EventAddress)
  32. IECLASS_GADGETUP = $08; // select button released over the same Gadget (address in ie_EventAddress)
  33. IECLASS_REQUESTER = $09; // some Requester activity has taken place. See Codes REQCLEAR and REQSET
  34. IECLASS_MENULIST = $0A; // this is a Menu Number transmission (Menu number is in ie_Code)
  35. IECLASS_CLOSEWINDOW = $0B; // User has selected the active Window's Close Gadget
  36. IECLASS_SIZEWINDOW = $0C; // this Window has a new size
  37. IECLASS_REFRESHWINDOW = $0D; // the Window pointed to by ie_EventAddress needs to be refreshed
  38. IECLASS_NEWPREFS = $0E; // new preferences are available
  39. IECLASS_DISKREMOVED = $0F; // the disk has been removed
  40. IECLASS_DISKINSERTED = $10; // the disk has been inserted
  41. IECLASS_ACTIVEWINDOW = $11; // the window is about to be been made active
  42. IECLASS_INACTIVEWINDOW = $12; // the window is about to be made inactive
  43. IECLASS_NEWPOINTERPOS = $13; // extended-function pointer position report (V36)
  44. IECLASS_MENUHELP = $14; // Help key report during Menu session (V36)
  45. IECLASS_CHANGEWINDOW = $15; // the Window has been modified with move, size, zoom, or change (V36)
  46. IECLASS_RESERVED = $16; // reserved
  47. IECLASS_MOUSEWHEEL = $17; // the mousewheel report from the gameport (V51)
  48. IECLASS_EXTENDEDRAWKEY = $18; // A 16bit raw keycode from the keyboard device (V51), see below for subclasses.
  49. IECLASS_MAX = $18; //the last class
  50. // --- InputEvent.ie_SubClass ---
  51. // IECLASS_NEWPOINTERPOS
  52. // like IECLASS_POINTERPOS
  53. IESUBCLASS_COMPATIBLE = $00;
  54. IESUBCLASS_PIXEL = $01; // ie_EventAddress points to struct IEPointerPixel
  55. IESUBCLASS_TABLET = $02; // ie_EventAddress points to struct IEPointerTablet
  56. // IECLASS_EXTENDED_RAWKEY
  57. IESUBCLASS_AMIGA_RAWKEY = $00;
  58. IESUBCLASS_SET1_RAWKEY = $01;
  59. IESUBCLASS_HID_CONSUMER_DOWN_RAWKEY = $02;
  60. IESUBCLASS_HID_CONSUMER_UP_RAWKEY = $03;
  61. type
  62. // pointed to by ie_EventAddress for IECLASS_NEWPOINTERPOS and IESUBCLASS_PIXEL.
  63. // You specify a screen and pixel coordinates in that screen at which you'd like the mouse to be positioned.
  64. // Intuition will try to oblige, but there will be restrictions to positioning the pointer over offscreen pixels.
  65. //
  66. // IEQUALIFIER_RELATIVEMOUSE is supported for IESUBCLASS_PIXEL.
  67. PIEPointerPixel = ^TIEPointerPixel;
  68. TIEPointerPixel = record
  69. iepp_Screen: Pointer; // (PScreen) pointer to an open screen
  70. iepp_Position : record
  71. x, y: SmallInt;
  72. end;
  73. end;
  74. // pointed to by ie_EventAddress for IECLASS_NEWPOINTERPOS and IESUBCLASS_TABLET.
  75. //
  76. // You specify a range of values and a value within the range independently for each of X and Y (the minimum value of the ranges is always normalized to 0).
  77. //
  78. // Intuition will position the mouse proportionally within its natural mouse position rectangle limits.
  79. //
  80. // IEQUALIFIER_RELATIVEMOUSE is not supported for IESUBCLASS_TABLET.
  81. PIEPointerTablet = ^TIEPointerTablet;
  82. TIEPointerTablet = record
  83. iept_Range: record // 0 is min, these are max
  84. x, y: Word;
  85. end;
  86. iept_Value: record // between 0 AND iept_Range
  87. x, y: Word;
  88. end;
  89. iept_Pressure: Word; // -128 to 127 (unused, set to 0)
  90. end;
  91. // The ie_EventAddress of an IECLASS_NEWPOINTERPOS event of subclass IESUBCLASS_NEWTABLET points at an IENewTablet structure.
  92. // IEQUALIFIER_RELATIVEMOUSE is not supported for IESUBCLASS_NEWTABLET.
  93. PIENewTablet = ^TIENewTablet;
  94. TIENewTablet = record
  95. { Pointer to a hook you wish to be called back through, in order to handle scaling. You will be provided with the
  96. width and height you are expected to scale your tablet to, perhaps based on some user preferences.
  97. If nil, the tablet's specified range will be mapped directly to that width and height for you, and you will not be called back.}
  98. ient_CallBack : pHook;
  99. { Post-scaling coordinates and fractional coordinates. DO NOT FILL THESE IN AT THE TIME THE EVENT IS WRITTEN!
  100. Your driver will be called back and provided information about the width and height of the area to scale the
  101. tablet into. It should scale the tablet coordinates (perhaps based on some preferences controlling aspect
  102. ratio, etc.) and place the scaled result into these fields. The ient_ScaledX and ient_ScaledY fields are
  103. in screen-pixel resolution, but the origin ([0,0]-point) is not defined. The ient_ScaledXFraction and
  104. ient_ScaledYFraction fields represent sub-pixel position information, and should be scaled to fill a Word fraction.}
  105. ient_ScaledX,
  106. ient_ScaledY,
  107. ient_ScaledXFraction,
  108. ient_ScaledYFraction: Word;
  109. // Current tablet coordinates along each axis:
  110. ient_TabletX, ient_TabletY: LongWord;
  111. // Tablet range along each axis. For example, if ient_TabletX can take values 0-999, ient_RangeX should be 1000.
  112. ient_RangeX, ient_RangeY: LongWord;
  113. // Pointer to tag-list of additional tablet attributes. See intuition for the tag values.
  114. ient_TagList: PTagItem;
  115. end;
  116. const
  117. //--- InputEvent.ie_Code
  118. // IECLASS_RAWKEY
  119. IECODE_UP_PREFIX = $80;
  120. IECODE_KEY_CODE_FIRST = $00;
  121. IECODE_KEY_CODE_LAST = $77;
  122. IECODE_COMM_CODE_FIRST = $78;
  123. IECODE_COMM_CODE_LAST = $7F;
  124. // IECLASS_ANSI
  125. IECODE_C0_FIRST = $00;
  126. IECODE_C0_LAST = $1F;
  127. IECODE_ASCII_FIRST = $20;
  128. IECODE_ASCII_LAST = $7E;
  129. IECODE_ASCII_DEL = $7F;
  130. IECODE_C1_FIRST = $80;
  131. IECODE_C1_LAST = $9F;
  132. IECODE_LATIN1_FIRST = $A0;
  133. IECODE_LATIN1_LAST = $FF;
  134. // IECLASS_RAWMOUSE
  135. IECODE_LBUTTON = $68; // also uses IECODE_UP_PREFIX
  136. IECODE_RBUTTON = $69;
  137. IECODE_MBUTTON = $6A;
  138. IECODE_4TH_BUTTON = $7E; // also called 'side'
  139. IECODE_5TH_BUTTON = $78; // also called 'extra'
  140. IECODE_NOBUTTON = $FF;
  141. // IECLASS_EVENT (V36)
  142. IECODE_NEWACTIVE = $01; // new active input window
  143. IECODE_NEWSIZE = $02; // resize of window
  144. IECODE_REFRESH = $03; // refresh of window
  145. // IECLASS_REQUESTER Codes
  146. IECODE_REQSET = $01; // broadcast when the first Requester (not subsequent ones) opens in the Window
  147. IECODE_REQCLEAR = $00; // broadcast when the last Requester clears out of the Window
  148. //--- InputEvent.ie_Qualifier
  149. IEQUALIFIER_LSHIFT = $0001;
  150. IEQUALIFIER_RSHIFT = $0002;
  151. IEQUALIFIER_CAPSLOCK = $0004;
  152. IEQUALIFIER_CONTROL = $0008;
  153. IEQUALIFIER_LALT = $0010;
  154. IEQUALIFIER_RALT = $0020;
  155. IEQUALIFIER_LCOMMAND = $0040;
  156. IEQUALIFIER_RCOMMAND = $0080;
  157. IEQUALIFIER_NUMERICPAD = $0100;
  158. IEQUALIFIER_REPEAT = $0200;
  159. IEQUALIFIER_INTERRUPT = $0400;
  160. IEQUALIFIER_MULTIBROADCAST = $0800;
  161. IEQUALIFIER_MIDBUTTON = $1000;
  162. IEQUALIFIER_RBUTTON = $2000;
  163. IEQUALIFIER_LEFTBUTTON = $4000;
  164. IEQUALIFIER_RELATIVEMOUSE = $8000;
  165. IEQUALIFIERB_LSHIFT = 0;
  166. IEQUALIFIERB_RSHIFT = 1;
  167. IEQUALIFIERB_CAPSLOCK = 2;
  168. IEQUALIFIERB_CONTROL = 3;
  169. IEQUALIFIERB_LALT = 4;
  170. IEQUALIFIERB_RALT = 5;
  171. IEQUALIFIERB_LCOMMAND = 6;
  172. IEQUALIFIERB_RCOMMAND = 7;
  173. IEQUALIFIERB_NUMERICPAD = 8;
  174. IEQUALIFIERB_REPEAT = 9;
  175. IEQUALIFIERB_INTERRUPT = 10;
  176. IEQUALIFIERB_MULTIBROADCAST = 11;
  177. IEQUALIFIERB_MIDBUTTON = 12;
  178. IEQUALIFIERB_RBUTTON = 13;
  179. IEQUALIFIERB_LEFTBUTTON = 14;
  180. IEQUALIFIERB_RELATIVEMOUSE = 15;
  181. //------ InputEvent
  182. type
  183. PInputEvent = ^TInputEvent;
  184. TInputEvent = record
  185. ie_NextEvent: PInputEvent;
  186. ie_Class: Byte;
  187. ie_SubClass: Byte;
  188. ie_Code: Word;
  189. ie_Qualifier: Word;
  190. ie_position: record
  191. case longint of
  192. 0:(ie_xy: record
  193. ie_x: SmallInt;
  194. ie_y: SmallInt;
  195. end);
  196. 1:(ie_addr: APTR);
  197. 2:(ie_dead: record
  198. ie_prev1DownCode : Byte;
  199. ie_prev1DownQual : Byte;
  200. ie_prev2DownCode : Byte;
  201. ie_prev2DownQual : Byte;
  202. end);
  203. end;
  204. ie_TimeStamp: TTimeVal;
  205. end;
  206. //----- ExtendedDeadKey
  207. PExtendedDeadKey = ^TExtendedDeadKey;
  208. TExtendedDeadKey = record
  209. Reserved: LongWord;
  210. Prev1DownClass: Word;
  211. Prev1DownCode: Word;
  212. Prev1DownQual: Word;
  213. Prev2DownClass: Word;
  214. Prev2DownCode: Word;
  215. Prev2DownQual: Word;
  216. end;
  217. implementation
  218. end.