event.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696
  1. /****************************************************************************
  2. *
  3. * SciTech OS Portability Manager Library
  4. *
  5. * ========================================================================
  6. *
  7. * The contents of this file are subject to the SciTech MGL Public
  8. * License Version 1.0 (the "License"); you may not use this file
  9. * except in compliance with the License. You may obtain a copy of
  10. * the License at http://www.scitechsoft.com/mgl-license.txt
  11. *
  12. * Software distributed under the License is distributed on an
  13. * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  14. * implied. See the License for the specific language governing
  15. * rights and limitations under the License.
  16. *
  17. * The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc.
  18. *
  19. * The Initial Developer of the Original Code is SciTech Software, Inc.
  20. * All Rights Reserved.
  21. *
  22. * ========================================================================
  23. *
  24. * Language: ANSI C
  25. * Environment: Any
  26. *
  27. * Description: Header file for the SciTech cross platform event library
  28. *
  29. ****************************************************************************/
  30. #ifndef __EVENT_H
  31. #define __EVENT_H
  32. #include "scitech.h"
  33. /*---------------------- Macros and type definitions ----------------------*/
  34. #pragma pack(1)
  35. /* 'C' calling conventions always */
  36. #define EVTAPI _ASMAPI
  37. #define EVTAPIP _ASMAPIP
  38. /* Event message masks for keyDown events */
  39. #define EVT_ASCIIMASK 0x00FF /* ASCII code of key pressed */
  40. #define EVT_SCANMASK 0xFF00 /* Scan code of key pressed */
  41. #define EVT_COUNTMASK 0x7FFF0000L /* Count for KEYREPEAT's */
  42. /* Macros to extract values from the message fields */
  43. #define EVT_asciiCode(m) ( (uchar) (m & EVT_ASCIIMASK) )
  44. #define EVT_scanCode(m) ( (uchar) ( (m & EVT_SCANMASK) >> 8 ) )
  45. #define EVT_repeatCount(m) ( (short) ( (m & EVT_COUNTMASK) >> 16 ) )
  46. /****************************************************************************
  47. REMARKS:
  48. Defines the set of ASCII codes reported by the event library functions
  49. in the message field. Use the EVT_asciiCode macro to extract the code
  50. from the event structure.
  51. HEADER:
  52. event.h
  53. ****************************************************************************/
  54. typedef enum {
  55. ASCII_ctrlA = 0x01,
  56. ASCII_ctrlB = 0x02,
  57. ASCII_ctrlC = 0x03,
  58. ASCII_ctrlD = 0x04,
  59. ASCII_ctrlE = 0x05,
  60. ASCII_ctrlF = 0x06,
  61. ASCII_ctrlG = 0x07,
  62. ASCII_backspace = 0x08,
  63. ASCII_ctrlH = 0x08,
  64. ASCII_tab = 0x09,
  65. ASCII_ctrlI = 0x09,
  66. ASCII_ctrlJ = 0x0A,
  67. ASCII_ctrlK = 0x0B,
  68. ASCII_ctrlL = 0x0C,
  69. ASCII_enter = 0x0D,
  70. ASCII_ctrlM = 0x0D,
  71. ASCII_ctrlN = 0x0E,
  72. ASCII_ctrlO = 0x0F,
  73. ASCII_ctrlP = 0x10,
  74. ASCII_ctrlQ = 0x11,
  75. ASCII_ctrlR = 0x12,
  76. ASCII_ctrlS = 0x13,
  77. ASCII_ctrlT = 0x14,
  78. ASCII_ctrlU = 0x15,
  79. ASCII_ctrlV = 0x16,
  80. ASCII_ctrlW = 0x17,
  81. ASCII_ctrlX = 0x18,
  82. ASCII_ctrlY = 0x19,
  83. ASCII_ctrlZ = 0x1A,
  84. ASCII_esc = 0x1B,
  85. ASCII_space = 0x20,
  86. ASCII_exclamation = 0x21, /* ! */
  87. ASCII_quote = 0x22, /* " */
  88. ASCII_pound = 0x23, /* # */
  89. ASCII_dollar = 0x24, /* $ */
  90. ASCII_percent = 0x25, /* % */
  91. ASCII_ampersand = 0x26, /* & */
  92. ASCII_apostrophe = 0x27, /* ' */
  93. ASCII_leftBrace = 0x28, /* ( */
  94. ASCII_rightBrace = 0x29, /* ) */
  95. ASCII_times = 0x2A, /* * */
  96. ASCII_plus = 0x2B, /* + */
  97. ASCII_comma = 0x2C, /* , */
  98. ASCII_minus = 0x2D, /* - */
  99. ASCII_period = 0x2E, /* . */
  100. ASCII_divide = 0x2F, /* / */
  101. ASCII_0 = 0x30,
  102. ASCII_1 = 0x31,
  103. ASCII_2 = 0x32,
  104. ASCII_3 = 0x33,
  105. ASCII_4 = 0x34,
  106. ASCII_5 = 0x35,
  107. ASCII_6 = 0x36,
  108. ASCII_7 = 0x37,
  109. ASCII_8 = 0x38,
  110. ASCII_9 = 0x39,
  111. ASCII_colon = 0x3A, /* : */
  112. ASCII_semicolon = 0x3B, /* ; */
  113. ASCII_lessThan = 0x3C, /* < */
  114. ASCII_equals = 0x3D, /* = */
  115. ASCII_greaterThan = 0x3E, /* > */
  116. ASCII_question = 0x3F, /* ? */
  117. ASCII_at = 0x40, /* @ */
  118. ASCII_A = 0x41,
  119. ASCII_B = 0x42,
  120. ASCII_C = 0x43,
  121. ASCII_D = 0x44,
  122. ASCII_E = 0x45,
  123. ASCII_F = 0x46,
  124. ASCII_G = 0x47,
  125. ASCII_H = 0x48,
  126. ASCII_I = 0x49,
  127. ASCII_J = 0x4A,
  128. ASCII_K = 0x4B,
  129. ASCII_L = 0x4C,
  130. ASCII_M = 0x4D,
  131. ASCII_N = 0x4E,
  132. ASCII_O = 0x4F,
  133. ASCII_P = 0x50,
  134. ASCII_Q = 0x51,
  135. ASCII_R = 0x52,
  136. ASCII_S = 0x53,
  137. ASCII_T = 0x54,
  138. ASCII_U = 0x55,
  139. ASCII_V = 0x56,
  140. ASCII_W = 0x57,
  141. ASCII_X = 0x58,
  142. ASCII_Y = 0x59,
  143. ASCII_Z = 0x5A,
  144. ASCII_leftSquareBrace = 0x5B, /* [ */
  145. ASCII_backSlash = 0x5C, /* \ */
  146. ASCII_rightSquareBrace = 0x5D, /* ] */
  147. ASCII_caret = 0x5E, /* ^ */
  148. ASCII_underscore = 0x5F, /* _ */
  149. ASCII_leftApostrophe = 0x60, /* ` */
  150. ASCII_a = 0x61,
  151. ASCII_b = 0x62,
  152. ASCII_c = 0x63,
  153. ASCII_d = 0x64,
  154. ASCII_e = 0x65,
  155. ASCII_f = 0x66,
  156. ASCII_g = 0x67,
  157. ASCII_h = 0x68,
  158. ASCII_i = 0x69,
  159. ASCII_j = 0x6A,
  160. ASCII_k = 0x6B,
  161. ASCII_l = 0x6C,
  162. ASCII_m = 0x6D,
  163. ASCII_n = 0x6E,
  164. ASCII_o = 0x6F,
  165. ASCII_p = 0x70,
  166. ASCII_q = 0x71,
  167. ASCII_r = 0x72,
  168. ASCII_s = 0x73,
  169. ASCII_t = 0x74,
  170. ASCII_u = 0x75,
  171. ASCII_v = 0x76,
  172. ASCII_w = 0x77,
  173. ASCII_x = 0x78,
  174. ASCII_y = 0x79,
  175. ASCII_z = 0x7A,
  176. ASCII_leftCurlyBrace = 0x7B, /* { */
  177. ASCII_verticalBar = 0x7C, /* | */
  178. ASCII_rightCurlyBrace = 0x7D, /* } */
  179. ASCII_tilde = 0x7E /* ~ */
  180. } EVT_asciiCodesType;
  181. /****************************************************************************
  182. REMARKS:
  183. Defines the set of scan codes reported by the event library functions
  184. in the message field. Use the EVT_scanCode macro to extract the code
  185. from the event structure. Note that the scan codes reported will be the
  186. same across all keyboards (assuming the placement of keys on a 101 key US
  187. keyboard), but the translated ASCII values may be different depending on
  188. the country code pages in use.
  189. NOTE: Scan codes in the event library are not really hardware scan codes,
  190. but rather virtual scan codes as generated by a low level keyboard
  191. interface driver. All virtual codes begin with scan code 0x60 and
  192. range up from there.
  193. HEADER:
  194. event.h
  195. ****************************************************************************/
  196. typedef enum {
  197. KB_padEnter = 0x60, /* Keypad keys */
  198. KB_padMinus = 0x4A,
  199. KB_padPlus = 0x4E,
  200. KB_padTimes = 0x37,
  201. KB_padDivide = 0x61,
  202. KB_padLeft = 0x62,
  203. KB_padRight = 0x63,
  204. KB_padUp = 0x64,
  205. KB_padDown = 0x65,
  206. KB_padInsert = 0x66,
  207. KB_padDelete = 0x67,
  208. KB_padHome = 0x68,
  209. KB_padEnd = 0x69,
  210. KB_padPageUp = 0x6A,
  211. KB_padPageDown = 0x6B,
  212. KB_padCenter = 0x4C,
  213. KB_F1 = 0x3B, /* Function keys */
  214. KB_F2 = 0x3C,
  215. KB_F3 = 0x3D,
  216. KB_F4 = 0x3E,
  217. KB_F5 = 0x3F,
  218. KB_F6 = 0x40,
  219. KB_F7 = 0x41,
  220. KB_F8 = 0x42,
  221. KB_F9 = 0x43,
  222. KB_F10 = 0x44,
  223. KB_F11 = 0x57,
  224. KB_F12 = 0x58,
  225. KB_left = 0x4B, /* Cursor control keys */
  226. KB_right = 0x4D,
  227. KB_up = 0x48,
  228. KB_down = 0x50,
  229. KB_insert = 0x52,
  230. KB_delete = 0x53,
  231. KB_home = 0x47,
  232. KB_end = 0x4F,
  233. KB_pageUp = 0x49,
  234. KB_pageDown = 0x51,
  235. KB_capsLock = 0x3A,
  236. KB_numLock = 0x45,
  237. KB_scrollLock = 0x46,
  238. KB_leftShift = 0x2A,
  239. KB_rightShift = 0x36,
  240. KB_leftCtrl = 0x1D,
  241. KB_rightCtrl = 0x6C,
  242. KB_leftAlt = 0x38,
  243. KB_rightAlt = 0x6D,
  244. KB_leftWindows = 0x5B,
  245. KB_rightWindows = 0x5C,
  246. KB_menu = 0x5D,
  247. KB_sysReq = 0x54,
  248. KB_esc = 0x01, /* Normal keyboard keys */
  249. KB_1 = 0x02,
  250. KB_2 = 0x03,
  251. KB_3 = 0x04,
  252. KB_4 = 0x05,
  253. KB_5 = 0x06,
  254. KB_6 = 0x07,
  255. KB_7 = 0x08,
  256. KB_8 = 0x09,
  257. KB_9 = 0x0A,
  258. KB_0 = 0x0B,
  259. KB_minus = 0x0C,
  260. KB_equals = 0x0D,
  261. KB_backSlash = 0x2B,
  262. KB_backspace = 0x0E,
  263. KB_tab = 0x0F,
  264. KB_Q = 0x10,
  265. KB_W = 0x11,
  266. KB_E = 0x12,
  267. KB_R = 0x13,
  268. KB_T = 0x14,
  269. KB_Y = 0x15,
  270. KB_U = 0x16,
  271. KB_I = 0x17,
  272. KB_O = 0x18,
  273. KB_P = 0x19,
  274. KB_leftSquareBrace = 0x1A,
  275. KB_rightSquareBrace = 0x1B,
  276. KB_enter = 0x1C,
  277. KB_A = 0x1E,
  278. KB_S = 0x1F,
  279. KB_D = 0x20,
  280. KB_F = 0x21,
  281. KB_G = 0x22,
  282. KB_H = 0x23,
  283. KB_J = 0x24,
  284. KB_K = 0x25,
  285. KB_L = 0x26,
  286. KB_semicolon = 0x27,
  287. KB_apostrophe = 0x28,
  288. KB_Z = 0x2C,
  289. KB_X = 0x2D,
  290. KB_C = 0x2E,
  291. KB_V = 0x2F,
  292. KB_B = 0x30,
  293. KB_N = 0x31,
  294. KB_M = 0x32,
  295. KB_comma = 0x33,
  296. KB_period = 0x34,
  297. KB_divide = 0x35,
  298. KB_space = 0x39,
  299. KB_tilde = 0x29
  300. } EVT_scanCodesType;
  301. /****************************************************************************
  302. REMARKS:
  303. Defines the mask for the joystick axes that are present
  304. HEADER:
  305. event.h
  306. MEMBERS:
  307. EVT_JOY_AXIS_X1 - Joystick 1, X axis is present
  308. EVT_JOY_AXIS_Y1 - Joystick 1, Y axis is present
  309. EVT_JOY_AXIS_X2 - Joystick 2, X axis is present
  310. EVT_JOY_AXIS_Y2 - Joystick 2, Y axis is present
  311. EVT_JOY_AXIS_ALL - Mask for all axes
  312. ****************************************************************************/
  313. typedef enum {
  314. EVT_JOY_AXIS_X1 = 0x00000001,
  315. EVT_JOY_AXIS_Y1 = 0x00000002,
  316. EVT_JOY_AXIS_X2 = 0x00000004,
  317. EVT_JOY_AXIS_Y2 = 0x00000008,
  318. EVT_JOY_AXIS_ALL = 0x0000000F
  319. } EVT_eventJoyAxisType;
  320. /****************************************************************************
  321. REMARKS:
  322. Defines the event message masks for joystick events
  323. HEADER:
  324. event.h
  325. MEMBERS:
  326. EVT_JOY1_BUTTONA - Joystick 1, button A is down
  327. EVT_JOY1_BUTTONB - Joystick 1, button B is down
  328. EVT_JOY2_BUTTONA - Joystick 2, button A is down
  329. EVT_JOY2_BUTTONB - Joystick 2, button B is down
  330. ****************************************************************************/
  331. typedef enum {
  332. EVT_JOY1_BUTTONA = 0x00000001,
  333. EVT_JOY1_BUTTONB = 0x00000002,
  334. EVT_JOY2_BUTTONA = 0x00000004,
  335. EVT_JOY2_BUTTONB = 0x00000008
  336. } EVT_eventJoyMaskType;
  337. /****************************************************************************
  338. REMARKS:
  339. Defines the event message masks for mouse events
  340. HEADER:
  341. event.h
  342. MEMBERS:
  343. EVT_LEFTBMASK - Left button is held down
  344. EVT_RIGHTBMASK - Right button is held down
  345. EVT_MIDDLEBMASK - Middle button is held down
  346. EVT_BOTHBMASK - Both left and right held down together
  347. EVT_ALLBMASK - All buttons pressed
  348. EVT_DBLCLICK - Set if mouse down event was a double click
  349. ****************************************************************************/
  350. typedef enum {
  351. EVT_LEFTBMASK = 0x00000001,
  352. EVT_RIGHTBMASK = 0x00000002,
  353. EVT_MIDDLEBMASK = 0x00000004,
  354. EVT_BOTHBMASK = 0x00000007,
  355. EVT_ALLBMASK = 0x00000007,
  356. EVT_DBLCLICK = 0x00010000
  357. } EVT_eventMouseMaskType;
  358. /****************************************************************************
  359. REMARKS:
  360. Defines the event modifier masks. These are the masks used to extract
  361. the modifier information from the modifiers field of the event_t structure.
  362. Note that the values in the modifiers field represent the values of these
  363. modifier keys at the time the event occurred, not the time you decided
  364. to process the event.
  365. HEADER:
  366. event.h
  367. MEMBERS:
  368. EVT_LEFTBUT - Set if left mouse button was down
  369. EVT_RIGHTBUT - Set if right mouse button was down
  370. EVT_MIDDLEBUT - Set if the middle button was down
  371. EVT_RIGHTSHIFT - Set if right shift was down
  372. EVT_LEFTSHIFT - Set if left shift was down
  373. EVT_RIGHTCTRL - Set if right ctrl key was down
  374. EVT_RIGHTALT - Set if right alt key was down
  375. EVT_LEFTCTRL - Set if left ctrl key was down
  376. EVT_LEFTALT - Set if left alt key was down
  377. EVT_SHIFTKEY - Mask for any shift key down
  378. EVT_CTRLSTATE - Set if ctrl key was down
  379. EVT_ALTSTATE - Set if alt key was down
  380. EVT_CAPSLOCK - Caps lock is active
  381. EVT_NUMLOCK - Num lock is active
  382. EVT_SCROLLLOCK - Scroll lock is active
  383. ****************************************************************************/
  384. typedef enum {
  385. EVT_LEFTBUT = 0x00000001,
  386. EVT_RIGHTBUT = 0x00000002,
  387. EVT_MIDDLEBUT = 0x00000004,
  388. EVT_RIGHTSHIFT = 0x00000008,
  389. EVT_LEFTSHIFT = 0x00000010,
  390. EVT_RIGHTCTRL = 0x00000020,
  391. EVT_RIGHTALT = 0x00000040,
  392. EVT_LEFTCTRL = 0x00000080,
  393. EVT_LEFTALT = 0x00000100,
  394. EVT_SHIFTKEY = 0x00000018,
  395. EVT_CTRLSTATE = 0x000000A0,
  396. EVT_ALTSTATE = 0x00000140,
  397. EVT_SCROLLLOCK = 0x00000200,
  398. EVT_NUMLOCK = 0x00000400,
  399. EVT_CAPSLOCK = 0x00000800
  400. } EVT_eventModMaskType;
  401. /****************************************************************************
  402. REMARKS:
  403. Defines the event codes returned in the event_t structures what field. Note
  404. that these are defined as a set of mutually exlusive bit fields, so you
  405. can test for multiple event types using the combined event masks defined
  406. in the EVT_eventMaskType enumeration.
  407. HEADER:
  408. event.h
  409. MEMBERS:
  410. EVT_NULLEVT - A null event
  411. EVT_KEYDOWN - Key down event
  412. EVT_KEYREPEAT - Key repeat event
  413. EVT_KEYUP - Key up event
  414. EVT_MOUSEDOWN - Mouse down event
  415. EVT_MOUSEAUTO - Mouse down autorepeat event
  416. EVT_MOUSEUP - Mouse up event
  417. EVT_MOUSEMOVE - Mouse movement event
  418. EVT_JOYCLICK - Joystick button state change event
  419. EVT_JOYMOVE - Joystick movement event
  420. EVT_USEREVT - First user event
  421. ****************************************************************************/
  422. typedef enum {
  423. EVT_NULLEVT = 0x00000000,
  424. EVT_KEYDOWN = 0x00000001,
  425. EVT_KEYREPEAT = 0x00000002,
  426. EVT_KEYUP = 0x00000004,
  427. EVT_MOUSEDOWN = 0x00000008,
  428. EVT_MOUSEAUTO = 0x00000010,
  429. EVT_MOUSEUP = 0x00000020,
  430. EVT_MOUSEMOVE = 0x00000040,
  431. EVT_JOYCLICK = 0x00000080,
  432. EVT_JOYMOVE = 0x00000100,
  433. EVT_USEREVT = 0x00000200
  434. } EVT_eventType;
  435. /****************************************************************************
  436. REMARKS:
  437. Defines the event code masks you can use to test for multiple types of
  438. events, since the event codes are mutually exlusive bit fields.
  439. HEADER:
  440. event.h
  441. MEMBERS:
  442. EVT_KEYEVT - Mask for any key event
  443. EVT_MOUSEEVT - Mask for any mouse event
  444. EVT_MOUSECLICK - Mask for any mouse click event
  445. EVT_JOYEVT - Mask for any joystick event
  446. EVT_EVERYEVT - Mask for any event
  447. ****************************************************************************/
  448. typedef enum {
  449. EVT_KEYEVT = (EVT_KEYDOWN | EVT_KEYREPEAT | EVT_KEYUP),
  450. EVT_MOUSEEVT = (EVT_MOUSEDOWN | EVT_MOUSEAUTO | EVT_MOUSEUP | EVT_MOUSEMOVE),
  451. EVT_MOUSECLICK = (EVT_MOUSEDOWN | EVT_MOUSEUP),
  452. EVT_JOYEVT = (EVT_JOYCLICK | EVT_JOYMOVE),
  453. EVT_EVERYEVT = 0x7FFFFFFF
  454. } EVT_eventMaskType;
  455. /****************************************************************************
  456. REMARKS:
  457. Structure describing the information contained in an event extracted from
  458. the event queue.
  459. HEADER:
  460. event.h
  461. MEMBERS:
  462. which - Window identifier for message for use by high level window manager
  463. code (i.e. MegaVision GUI or Windows API).
  464. what - Type of event that occurred. Will be one of the values defined by
  465. the EVT_eventType enumeration.
  466. when - Time that the event occurred in milliseconds since startup
  467. where_x - X coordinate of the mouse cursor location at the time of the event
  468. (in screen coordinates). For joystick events this represents
  469. the position of the first joystick X axis.
  470. where_y - Y coordinate of the mouse cursor location at the time of the event
  471. (in screen coordinates). For joystick events this represents
  472. the position of the first joystick Y axis.
  473. relative_x - Relative movement of the mouse cursor in the X direction (in
  474. units of mickeys, or 1/200th of an inch). For joystick events
  475. this represents the position of the second joystick X axis.
  476. relative_y - Relative movement of the mouse cursor in the Y direction (in
  477. units of mickeys, or 1/200th of an inch). For joystick events
  478. this represents the position of the second joystick Y axis.
  479. message - Event specific message for the event. For use events this can be
  480. any user specific information. For keyboard events this contains
  481. the ASCII code in bits 0-7, the keyboard scan code in bits 8-15 and
  482. the character repeat count in bits 16-30. You can use the
  483. EVT_asciiCode, EVT_scanCode and EVT_repeatCount macros to extract
  484. this information from the message field. For mouse events this
  485. contains information about which button was pressed, and will be a
  486. combination of the flags defined by the EVT_eventMouseMaskType
  487. enumeration. For joystick events, this conatins information
  488. about which buttons were pressed, and will be a combination of
  489. the flags defined by the EVT_eventJoyMaskType enumeration.
  490. modifiers - Contains additional information about the state of the keyboard
  491. shift modifiers (Ctrl, Alt and Shift keys) when the event
  492. occurred. For mouse events it will also contain the state of
  493. the mouse buttons. Will be a combination of the values defined
  494. by the EVT_eventModMaskType enumeration.
  495. next - Internal use; do not use.
  496. prev - Internal use; do not use.
  497. ****************************************************************************/
  498. typedef struct {
  499. ulong which;
  500. ulong what;
  501. ulong when;
  502. int where_x;
  503. int where_y;
  504. int relative_x;
  505. int relative_y;
  506. ulong message;
  507. ulong modifiers;
  508. int next;
  509. int prev;
  510. } event_t;
  511. /****************************************************************************
  512. REMARKS:
  513. Structure describing an entry in the code page table. A table of translation
  514. codes for scan codes to ASCII codes is provided in this table to be used
  515. by the keyboard event libraries. On some OS'es the keyboard translation is
  516. handled by the OS, but for DOS and embedded systems you must register a
  517. different code page translation table if you want to support keyboards
  518. other than the US English keyboard (the default).
  519. NOTE: Entries in code page tables *must* be in ascending order for the
  520. scan codes as we do a binary search on the tables for the ASCII
  521. code equivalents.
  522. HEADER:
  523. event.h
  524. MEMBERS:
  525. scanCode - Scan code to translate (really the virtual scan code).
  526. asciiCode - ASCII code for this scan code.
  527. ****************************************************************************/
  528. typedef struct {
  529. uchar scanCode;
  530. uchar asciiCode;
  531. } codepage_entry_t;
  532. /****************************************************************************
  533. REMARKS:
  534. Structure describing a complete code page translation table. The table
  535. contains translation tables for normal keys, shifted keys and ctrl keys.
  536. The Ctrl key always has precedence over the shift table, and the shift
  537. table is used when the shift key is down or the CAPSLOCK key is down.
  538. HEADER:
  539. event.h
  540. MEMBERS:
  541. name - Name of the code page table (ie: "US English")
  542. normal - Code page for translating normal keys
  543. normalLen - Length of normal translation table
  544. caps - Code page for translating keys when CAPSLOCK is down
  545. capsLen - Length of CAPSLOCK translation table
  546. shift - Code page for shifted keys (ie: shift key is held down)
  547. shiftLen - Length of shifted translation table
  548. shiftCaps - Code page for shifted keys when CAPSLOCK is down
  549. shiftCapsLen - Length of shifted CAPSLOCK translation table
  550. ctrl - Code page for ctrl'ed keys (ie: ctrl key is held down)
  551. ctrlLen - Length of ctrl'ed translation table
  552. numPad - Code page for NUMLOCK'ed keypad keys
  553. numPadLen - Length of NUMLOCK'ed translation table
  554. ****************************************************************************/
  555. typedef struct {
  556. char name[20];
  557. codepage_entry_t *normal;
  558. int normalLen;
  559. codepage_entry_t *caps;
  560. int capsLen;
  561. codepage_entry_t *shift;
  562. int shiftLen;
  563. codepage_entry_t *shiftCaps;
  564. int shiftCapsLen;
  565. codepage_entry_t *ctrl;
  566. int ctrlLen;
  567. codepage_entry_t *numPad;
  568. int numPadLen;
  569. } codepage_t;
  570. /* {secret} */
  571. typedef ibool (EVTAPIP _EVT_userEventFilter)(event_t *evt);
  572. /* {secret} */
  573. typedef void (EVTAPIP _EVT_mouseMoveHandler)(int x,int y);
  574. /* {secret} */
  575. typedef void (EVTAPIP _EVT_heartBeatCallback)(void *params);
  576. /* Macro to find the size of a static array */
  577. #define EVT_ARR_SIZE(a) (sizeof(a)/sizeof((a)[0]))
  578. #pragma pack()
  579. /*--------------------------- Global variables ----------------------------*/
  580. #ifdef __cplusplus
  581. extern "C" { /* Use "C" linkage when in C++ mode */
  582. #endif
  583. /* Standard code page tables */
  584. extern codepage_t _CP_US_English;
  585. /*------------------------- Function Prototypes ---------------------------*/
  586. /* Public API functions for user applications */
  587. ibool EVTAPI EVT_getNext(event_t *evt,ulong mask);
  588. ibool EVTAPI EVT_peekNext(event_t *evt,ulong mask);
  589. ibool EVTAPI EVT_post(ulong which,ulong what,ulong message,ulong modifiers);
  590. void EVTAPI EVT_flush(ulong mask);
  591. void EVTAPI EVT_halt(event_t *evt,ulong mask);
  592. ibool EVTAPI EVT_isKeyDown(uchar scanCode);
  593. void EVTAPI EVT_setMousePos(int x,int y);
  594. void EVTAPI EVT_getMousePos(int *x,int *y);
  595. /* Function to enable/disable updating of keyboard LED status indicators */
  596. void EVTAPI EVT_allowLEDS(ibool enable);
  597. /* Function to install a custom keyboard code page. Default is US English */
  598. codepage_t *EVTAPI EVT_getCodePage(void);
  599. void EVTAPI EVT_setCodePage(codepage_t *page);
  600. /* Functions for fine grained joystick calibration */
  601. void EVTAPI EVT_pollJoystick(void);
  602. int EVTAPI EVT_joyIsPresent(void);
  603. void EVTAPI EVT_joySetUpperLeft(void);
  604. void EVTAPI EVT_joySetLowerRight(void);
  605. void EVTAPI EVT_joySetCenter(void);
  606. /* Install user supplied event filter callback */
  607. void EVTAPI EVT_setUserEventFilter(_EVT_userEventFilter filter);
  608. /* Install user supplied event heartbeat callback function */
  609. void EVTAPI EVT_setHeartBeatCallback(_EVT_heartBeatCallback callback,void *params);
  610. void EVTAPI EVT_getHeartBeatCallback(_EVT_heartBeatCallback *callback,void **params);
  611. /* Internal functions to initialise and kill the event manager. MGL
  612. * applications should never call these functions directly as the MGL
  613. * libraries do it for you.
  614. */
  615. /* {secret} */
  616. void EVTAPI EVT_init(_EVT_mouseMoveHandler mouseMove);
  617. /* {secret} */
  618. void EVTAPI EVT_setMouseRange(int xRes,int yRes);
  619. /* {secret} */
  620. void EVTAPI EVT_suspend(void);
  621. /* {secret} */
  622. void EVTAPI EVT_resume(void);
  623. /* {secret} */
  624. void EVTAPI EVT_exit(void);
  625. #ifdef __cplusplus
  626. } /* End of "C" linkage for C++ */
  627. #endif /* __cplusplus */
  628. #endif /* __EVENT_H */