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