TEST.CPP 24 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037
  1. /*
  2. ** Command & Conquer Red Alert(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Keyboard Test Program *
  23. * *
  24. * File Name : TEST.CPP *
  25. * *
  26. * Programmer : Phil Gorrow *
  27. * *
  28. * Start Date : October 10, 1995 *
  29. * *
  30. * Last Update : October 16, 1995 [PWG] *
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * WndProc -- Callback procedure for main window *
  35. * WinMain -- Program entry point *
  36. * Init_Keyboard_Remap_Table -- initializes the keyboard remap table *
  37. * WWKeyboardClass::WWKeyBoardClass -- Construction for Westwood Keyboard*
  38. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  39. #include <misc.h>
  40. #include <stdio.h>
  41. #include "keyboard.h"
  42. #define NAME "DRAWBUFF test"
  43. #define TITLE "DRAWBUFF library test"
  44. BOOL Running = TRUE;
  45. HANDLE ThreadHandle;
  46. BOOL MessageLoopThread = FALSE;
  47. #define MODE_WIDTH 640 // Width in pixels of required video mode
  48. #define MODE_HEIGHT 400 // Height in pixels of required video mode
  49. void Message_Loop(void);
  50. HANDLE ActiveEvent;
  51. WWKeyboardClass Kbd;
  52. #if(0)
  53. #define VK_NONE_00 0x00
  54. #define VK_LBUTTON 0x01
  55. #define VK_RBUTTON 0x02
  56. #define VK_CANCEL 0x03
  57. #define VK_MBUTTON 0x04
  58. #define VK_NONE_05 0x05
  59. #define VK_NONE_06 0x06
  60. #define VK_NONE_07 0x07
  61. #define VK_BACK 0x08
  62. #define VK_TAB 0x09
  63. #define VK_NONE_0A 0x0A
  64. #define VK_NONE_0B 0x0B
  65. #define VK_CLEAR 0x0C
  66. #define VK_RETURN 0x0D
  67. #define VK_NONE_0E 0x0E
  68. #define VK_NONE_0F 0x0F
  69. #define VK_SHIFT 0x10
  70. #define VK_CONTROL 0x11
  71. #define VK_MENU 0x12
  72. #define VK_PAUSE 0x13
  73. #define VK_CAPITAL 0x14
  74. #define VK_NONE_15 0x15
  75. #define VK_NONE_16 0x16
  76. #define VK_NONE_17 0x17
  77. #define VK_NONE_18 0x18
  78. #define VK_NONE_19 0x19
  79. #define VK_NONE_1A 0x1A
  80. #define VK_ESCAPE 0x1B
  81. #define VK_NONE_1C 0x1C
  82. #define VK_NONE_1D 0x1D
  83. #define VK_NONE_1E 0x1E
  84. #define VK_NONE_1F 0x1F
  85. #define VK_SPACE 0x20
  86. #define VK_PRIOR 0x21
  87. #define VK_NEXT 0x22
  88. #define VK_END 0x23
  89. #define VK_HOME 0x24
  90. #define VK_LEFT 0x25
  91. #define VK_UP 0x26
  92. #define VK_RIGHT 0x27
  93. #define VK_DOWN 0x28
  94. #define VK_SELECT 0x29
  95. #define VK_PRINT 0x2A
  96. #define VK_EXECUTE 0x2B
  97. #define VK_SNAPSHOT 0x2C
  98. #define VK_INSERT 0x2D
  99. #define VK_DELETE 0x2E
  100. #define VK_HELP 0x2F
  101. #define VK_0 0x30
  102. #define VK_1 0x31
  103. #define VK_2 0x32
  104. #define VK_3 0x33
  105. #define VK_4 0x34
  106. #define VK_5 0x35
  107. #define VK_6 0x36
  108. #define VK_7 0x37
  109. #define VK_8 0x38
  110. #define VK_9 0x39
  111. #define VK_0 0x3A
  112. #define VK_NONE_3B 0x3B
  113. #define VK_NONE_3C 0x3C
  114. #define VK_NONE_3D 0x3D
  115. #define VK_NONE_3E 0x3E
  116. #define VK_NONE_3F 0x3F
  117. #define VK_NONE_40 0x40
  118. #define VK_A 0x41
  119. #define VK_B 0x42
  120. #define VK_C 0x43
  121. #define VK_D 0x44
  122. #define VK_E 0x45
  123. #define VK_F 0x46
  124. #define VK_G 0x47
  125. #define VK_H 0x48
  126. #define VK_I 0x49
  127. #define VK_J 0x4A
  128. #define VK_K 0x4B
  129. #define VK_L 0x4C
  130. #define VK_M 0x4D
  131. #define VK_N 0x4E
  132. #define VK_O 0x4F
  133. #define VK_P 0x50
  134. #define VK_Q 0x51
  135. #define VK_R 0x52
  136. #define VK_S 0x53
  137. #define VK_T 0x54
  138. #define VK_U 0x55
  139. #define VK_V 0x56
  140. #define VK_W 0x57
  141. #define VK_X 0x58
  142. #define VK_Y 0x59
  143. #define VK_Z 0x5A
  144. #define VK_NONE_5B 0x5B
  145. #define VK_NONE_5C 0x5C
  146. #define VK_NONE_5D 0x5D
  147. #define VK_NONE_5E 0x5E
  148. #define VK_NONE_5F 0x5F
  149. #define VK_NUMPAD0 0x60
  150. #define VK_NUMPAD1 0x61
  151. #define VK_NUMPAD2 0x62
  152. #define VK_NUMPAD3 0x63
  153. #define VK_NUMPAD4 0x64
  154. #define VK_NUMPAD5 0x65
  155. #define VK_NUMPAD6 0x66
  156. #define VK_NUMPAD7 0x67
  157. #define VK_NUMPAD8 0x68
  158. #define VK_NUMPAD9 0x69
  159. #define VK_MULTIPLY 0x6A
  160. #define VK_ADD 0x6B
  161. #define VK_SEPARATOR 0x6C
  162. #define VK_SUBTRACT 0x6D
  163. #define VK_DECIMAL 0x6E
  164. #define VK_DIVIDE 0x6F
  165. #define VK_F1 0x70
  166. #define VK_F2 0x71
  167. #define VK_F3 0x72
  168. #define VK_F4 0x73
  169. #define VK_F5 0x74
  170. #define VK_F6 0x75
  171. #define VK_F7 0x76
  172. #define VK_F8 0x77
  173. #define VK_F9 0x78
  174. #define VK_F10 0x79
  175. #define VK_F11 0x7A
  176. #define VK_F12 0x7B
  177. #define VK_F13 0x7C
  178. #define VK_F14 0x7D
  179. #define VK_F15 0x7E
  180. #define VK_F16 0x7F
  181. #define VK_F17 0x80
  182. #define VK_F18 0x81
  183. #define VK_F19 0x82
  184. #define VK_F20 0x83
  185. #define VK_F21 0x84
  186. #define VK_F22 0x85
  187. #define VK_F23 0x86
  188. #define VK_F24 0x87
  189. #define VK_NONE_88 0x88
  190. #define VK_NONE_89 0x89
  191. #define VK_NONE_8A 0x8A
  192. #define VK_NONE_8B 0x8B
  193. #define VK_NONE_8C 0x8C
  194. #define VK_NONE_8D 0x8D
  195. #define VK_NONE_8E 0x8E
  196. #define VK_NONE_8F 0x8F
  197. #define VK_NUMLOCK 0x90
  198. #define VK_SCROLL 0x91
  199. #define VK_NONE_92 0x92
  200. #define VK_NONE_93 0x93
  201. #define VK_NONE_94 0x94
  202. #define VK_NONE_95 0x95
  203. #define VK_NONE_96 0x96
  204. #define VK_NONE_97 0x97
  205. #define VK_NONE_98 0x98
  206. #define VK_NONE_99 0x99
  207. #define VK_NONE_9A 0x9A
  208. #define VK_NONE_9B 0x9B
  209. #define VK_NONE_9C 0x9C
  210. #define VK_NONE_9D 0x9D
  211. #define VK_NONE_9E 0x9E
  212. #define VK_NONE_9F 0x9F
  213. #define VK_NONE_A0 0xA0
  214. #define VK_NONE_A1 0xA1
  215. #define VK_NONE_A2 0xA2
  216. #define VK_NONE_A3 0xA3
  217. #define VK_NONE_A4 0xA4
  218. #define VK_NONE_A5 0xA5
  219. #define VK_NONE_A6 0xA6
  220. #define VK_NONE_A7 0xA7
  221. #define VK_NONE_A8 0xA8
  222. #define VK_NONE_A9 0xA9
  223. #define VK_NONE_AA 0xAA
  224. #define VK_NONE_AB 0xAB
  225. #define VK_NONE_AC 0xAC
  226. #define VK_NONE_AD 0xAD
  227. #define VK_NONE_AE 0xAE
  228. #define VK_NONE_AF 0xAF
  229. #define VK_NONE_B0 0xB0
  230. #define VK_NONE_B1 0xB1
  231. #define VK_NONE_B2 0xB2
  232. #define VK_NONE_B3 0xB3
  233. #define VK_NONE_B4 0xB4
  234. #define VK_NONE_B5 0xB5
  235. #define VK_NONE_B6 0xB6
  236. #define VK_NONE_B7 0xB7
  237. #define VK_NONE_B8 0xB8
  238. #define VK_NONE_B9 0xB9
  239. #define VK_NONE_BA 0xBA
  240. #define VK_NONE_BB 0xBB
  241. #define VK_NONE_BC 0xBC
  242. #define VK_NONE_BD 0xBD
  243. #define VK_NONE_BE 0xBE
  244. #define VK_NONE_BF 0xBF
  245. #define VK_NONE_C0 0xC0
  246. #define VK_NONE_C1 0xC1
  247. #define VK_NONE_C2 0xC2
  248. #define VK_NONE_C3 0xC3
  249. #define VK_NONE_C4 0xC4
  250. #define VK_NONE_C5 0xC5
  251. #define VK_NONE_C6 0xC6
  252. #define VK_NONE_C7 0xC7
  253. #define VK_NONE_C8 0xC8
  254. #define VK_NONE_C9 0xC9
  255. #define VK_NONE_CA 0xCA
  256. #define VK_NONE_CB 0xCB
  257. #define VK_NONE_CC 0xCC
  258. #define VK_NONE_CD 0xCD
  259. #define VK_NONE_CE 0xCE
  260. #define VK_NONE_CF 0xCF
  261. #define VK_NONE_D0 0xD0
  262. #define VK_NONE_D1 0xD1
  263. #define VK_NONE_D2 0xD2
  264. #define VK_NONE_D3 0xD3
  265. #define VK_NONE_D4 0xD4
  266. #define VK_NONE_D5 0xD5
  267. #define VK_NONE_D6 0xD6
  268. #define VK_NONE_D7 0xD7
  269. #define VK_NONE_D8 0xD8
  270. #define VK_NONE_D9 0xD9
  271. #define VK_NONE_DA 0xDA
  272. #define VK_NONE_DB 0xDB
  273. #define VK_NONE_DC 0xDC
  274. #define VK_NONE_DD 0xDD
  275. #define VK_NONE_DE 0xDE
  276. #define VK_NONE_DF 0xDF
  277. #define VK_NONE_E0 0xE0
  278. #define VK_NONE_E1 0xE1
  279. #define VK_NONE_E2 0xE2
  280. #define VK_NONE_E3 0xE3
  281. #define VK_NONE_E4 0xE4
  282. #define VK_NONE_E5 0xE5
  283. #define VK_NONE_E6 0xE6
  284. #define VK_NONE_E7 0xE7
  285. #define VK_NONE_E8 0xE8
  286. #define VK_NONE_E9 0xE9
  287. #define VK_NONE_EA 0xEA
  288. #define VK_NONE_EB 0xEB
  289. #define VK_NONE_EC 0xEC
  290. #define VK_NONE_ED 0xED
  291. #define VK_NONE_EE 0xEE
  292. #define VK_NONE_EF 0xEF
  293. #define VK_NONE_F0 0xF0
  294. #define VK_NONE_F1 0xF1
  295. #define VK_NONE_F2 0xF2
  296. #define VK_NONE_F3 0xF3
  297. #define VK_NONE_F4 0xF4
  298. #define VK_NONE_F5 0xF5
  299. #define VK_NONE_F6 0xF6
  300. #define VK_NONE_F7 0xF7
  301. #define VK_NONE_F8 0xF8
  302. #define VK_NONE_F9 0xF9
  303. #define VK_NONE_FA 0xFA
  304. #define VK_NONE_FB 0xFB
  305. #define VK_NONE_FC 0xFC
  306. #define VK_NONE_FD 0xFD
  307. #define VK_NONE_FE 0xFE
  308. #define VK_NONE_FF 0xFF
  309. #endif
  310. char *VK_Name[] = {
  311. "VK_NONE_00",
  312. "VK_LBUTTON",
  313. "VK_RBUTTON",
  314. "VK_CANCEL",
  315. "VK_MBUTTON",
  316. "VK_NONE_05",
  317. "VK_NONE_06",
  318. "VK_NONE_07",
  319. "VK_BACK",
  320. "VK_TAB",
  321. "VK_NONE_0A",
  322. "VK_NONE_0B",
  323. "VK_CLEAR",
  324. "VK_RETURN",
  325. "VK_NONE_0E",
  326. "VK_NONE_0F",
  327. "VK_SHIFT",
  328. "VK_CONTROL",
  329. "VK_MENU",
  330. "VK_PAUSE",
  331. "VK_CAPITAL",
  332. "VK_NONE_15",
  333. "VK_NONE_16",
  334. "VK_NONE_17",
  335. "VK_NONE_18",
  336. "VK_NONE_19",
  337. "VK_NONE_1A",
  338. "VK_ESCAPE",
  339. "VK_NONE_1C",
  340. "VK_NONE_1D",
  341. "VK_NONE_1E",
  342. "VK_NONE_1F",
  343. "VK_SPACE",
  344. "VK_PRIOR",
  345. "VK_NEXT",
  346. "VK_END",
  347. "VK_HOME",
  348. "VK_LEFT",
  349. "VK_UP",
  350. "VK_RIGHT",
  351. "VK_DOWN",
  352. "VK_SELECT",
  353. "VK_PRINT",
  354. "VK_EXECUTE",
  355. "VK_SNAPSHOT",
  356. "VK_INSERT",
  357. "VK_DELETE",
  358. "VK_HELP",
  359. "VK_0",
  360. "VK_1",
  361. "VK_2",
  362. "VK_3",
  363. "VK_4",
  364. "VK_5",
  365. "VK_6",
  366. "VK_7",
  367. "VK_8",
  368. "VK_9",
  369. "VK_0",
  370. "VK_NONE_3B",
  371. "VK_NONE_3C",
  372. "VK_NONE_3D",
  373. "VK_NONE_3E",
  374. "VK_NONE_3F",
  375. "VK_NONE_40",
  376. "VK_A",
  377. "VK_B",
  378. "VK_C",
  379. "VK_D",
  380. "VK_E",
  381. "VK_F",
  382. "VK_G",
  383. "VK_H",
  384. "VK_I",
  385. "VK_J",
  386. "VK_K",
  387. "VK_L",
  388. "VK_M",
  389. "VK_N",
  390. "VK_O",
  391. "VK_P",
  392. "VK_Q",
  393. "VK_R",
  394. "VK_S",
  395. "VK_T",
  396. "VK_U",
  397. "VK_V",
  398. "VK_W",
  399. "VK_X",
  400. "VK_Y",
  401. "VK_Z",
  402. "VK_NONE_5B",
  403. "VK_NONE_5C",
  404. "VK_NONE_5D",
  405. "VK_NONE_5E",
  406. "VK_NONE_5F",
  407. "VK_NUMPAD0",
  408. "VK_NUMPAD1",
  409. "VK_NUMPAD2",
  410. "VK_NUMPAD3",
  411. "VK_NUMPAD4",
  412. "VK_NUMPAD5",
  413. "VK_NUMPAD6",
  414. "VK_NUMPAD7",
  415. "VK_NUMPAD8",
  416. "VK_NUMPAD9",
  417. "VK_MULTIPLY",
  418. "VK_ADD",
  419. "VK_SEPARATOR",
  420. "VK_SUBTRACT",
  421. "VK_DECIMAL",
  422. "VK_DIVIDE",
  423. "VK_F1",
  424. "VK_F2",
  425. "VK_F3",
  426. "VK_F4",
  427. "VK_F5",
  428. "VK_F6",
  429. "VK_F7",
  430. "VK_F8",
  431. "VK_F9",
  432. "VK_F10",
  433. "VK_F11",
  434. "VK_F12",
  435. "VK_F13",
  436. "VK_F14",
  437. "VK_F15",
  438. "VK_F16",
  439. "VK_F17",
  440. "VK_F18",
  441. "VK_F19",
  442. "VK_F20",
  443. "VK_F21",
  444. "VK_F22",
  445. "VK_F23",
  446. "VK_F24",
  447. "VK_NONE_88",
  448. "VK_NONE_89",
  449. "VK_NONE_8A",
  450. "VK_NONE_8B",
  451. "VK_NONE_8C",
  452. "VK_NONE_8D",
  453. "VK_NONE_8E",
  454. "VK_NONE_8F",
  455. "VK_NUMLOCK",
  456. "VK_SCROLL",
  457. "VK_NONE_92",
  458. "VK_NONE_93",
  459. "VK_NONE_94",
  460. "VK_NONE_95",
  461. "VK_NONE_96",
  462. "VK_NONE_97",
  463. "VK_NONE_98",
  464. "VK_NONE_99",
  465. "VK_NONE_9A",
  466. "VK_NONE_9B",
  467. "VK_NONE_9C",
  468. "VK_NONE_9D",
  469. "VK_NONE_9E",
  470. "VK_NONE_9F",
  471. "VK_NONE_A0",
  472. "VK_NONE_A1",
  473. "VK_NONE_A2",
  474. "VK_NONE_A3",
  475. "VK_NONE_A4",
  476. "VK_NONE_A5",
  477. "VK_NONE_A6",
  478. "VK_NONE_A7",
  479. "VK_NONE_A8",
  480. "VK_NONE_A9",
  481. "VK_NONE_AA",
  482. "VK_NONE_AB",
  483. "VK_NONE_AC",
  484. "VK_NONE_AD",
  485. "VK_NONE_AE",
  486. "VK_NONE_AF",
  487. "VK_NONE_B0",
  488. "VK_NONE_B1",
  489. "VK_NONE_B2",
  490. "VK_NONE_B3",
  491. "VK_NONE_B4",
  492. "VK_NONE_B5",
  493. "VK_NONE_B6",
  494. "VK_NONE_B7",
  495. "VK_NONE_B8",
  496. "VK_NONE_B9",
  497. "VK_NONE_BA",
  498. "VK_NONE_BB",
  499. "VK_NONE_BC",
  500. "VK_NONE_BD",
  501. "VK_NONE_BE",
  502. "VK_NONE_BF",
  503. "VK_NONE_C0",
  504. "VK_NONE_C1",
  505. "VK_NONE_C2",
  506. "VK_NONE_C3",
  507. "VK_NONE_C4",
  508. "VK_NONE_C5",
  509. "VK_NONE_C6",
  510. "VK_NONE_C7",
  511. "VK_NONE_C8",
  512. "VK_NONE_C9",
  513. "VK_NONE_CA",
  514. "VK_NONE_CB",
  515. "VK_NONE_CC",
  516. "VK_NONE_CD",
  517. "VK_NONE_CE",
  518. "VK_NONE_CF",
  519. "VK_NONE_D0",
  520. "VK_NONE_D1",
  521. "VK_NONE_D2",
  522. "VK_NONE_D3",
  523. "VK_NONE_D4",
  524. "VK_NONE_D5",
  525. "VK_NONE_D6",
  526. "VK_NONE_D7",
  527. "VK_NONE_D8",
  528. "VK_NONE_D9",
  529. "VK_NONE_DA",
  530. "VK_NONE_DB",
  531. "VK_NONE_DC",
  532. "VK_NONE_DD",
  533. "VK_NONE_DE",
  534. "VK_NONE_DF",
  535. "VK_NONE_E0",
  536. "VK_NONE_E1",
  537. "VK_NONE_E2",
  538. "VK_NONE_E3",
  539. "VK_NONE_E4",
  540. "VK_NONE_E5",
  541. "VK_NONE_E6",
  542. "VK_NONE_E7",
  543. "VK_NONE_E8",
  544. "VK_NONE_E9",
  545. "VK_NONE_EA",
  546. "VK_NONE_EB",
  547. "VK_NONE_EC",
  548. "VK_NONE_ED",
  549. "VK_NONE_EE",
  550. "VK_NONE_EF",
  551. "VK_NONE_F0",
  552. "VK_NONE_F1",
  553. "VK_NONE_F2",
  554. "VK_NONE_F3",
  555. "VK_NONE_F4",
  556. "VK_NONE_F5",
  557. "VK_NONE_F6",
  558. "VK_NONE_F7",
  559. "VK_NONE_F8",
  560. "VK_NONE_F9",
  561. "VK_NONE_FA",
  562. "VK_NONE_FB",
  563. "VK_NONE_FC",
  564. "VK_NONE_FD",
  565. "VK_NONE_FE",
  566. "VK_NONE_FF",
  567. };
  568. char *_keyname[] = {
  569. "KN_NONE",
  570. "KN_GRAVE",
  571. "KN_1",
  572. "KN_2",
  573. "KN_3",
  574. "KN_4",
  575. "KN_5",
  576. "KN_6",
  577. "KN_7",
  578. "KN_8",
  579. "KN_9",
  580. "KN_0",
  581. "KN_MINUS",
  582. "KN_EQUAL",
  583. "KN_RESERVED1",
  584. "KN_BACKSPACE",
  585. "KN_TAB",
  586. "KN_Q",
  587. "KN_W",
  588. "KN_E",
  589. "KN_R",
  590. "KN_T",
  591. "KN_Y",
  592. "KN_U",
  593. "KN_I",
  594. "KN_O",
  595. "KN_P",
  596. "KN_LBRACKET",
  597. "KN_RBRACKET",
  598. "KN_BACKSLASH",
  599. "KN_CAPSLOCK",
  600. "KN_A",
  601. "KN_S",
  602. "KN_D",
  603. "KN_F",
  604. "KN_G",
  605. "KN_H",
  606. "KN_J",
  607. "KN_K",
  608. "KN_L",
  609. "KN_SEMICOLON",
  610. "KN_SQUOTE",
  611. "KN_BACKSLASH2",
  612. "KN_RETURN",
  613. "KN_LSHIFT",
  614. "KN_MOUSE_MOVE",
  615. "KN_Z",
  616. "KN_X",
  617. "KN_C",
  618. "KN_V",
  619. "KN_B",
  620. "KN_N",
  621. "KN_M",
  622. "KN_COMMA",
  623. "KN_PERIOD",
  624. "KN_SLASH",
  625. "KN_RESERVED3",
  626. "KN_RSHIFT",
  627. "KN_LCTRL",
  628. "KN_LCOMM",
  629. "KN_LALT",
  630. "KN_SPACE",
  631. "KN_RALT",
  632. "KN_RCOMM",
  633. "KN_RCTRL",
  634. "KN_LMOUSE",
  635. "KN_RMOUSE",
  636. "KN_JBUTTON1",
  637. "KN_JBUTTON2",
  638. "KN_J_UP",
  639. "KN_J_RIGHT",
  640. "KN_J_DOWN",
  641. "KN_J_LEFT",
  642. "KN_SPECIAL9",
  643. "KN_SPECIAL10",
  644. "KN_E_INSERT",
  645. "KN_E_DELETE",
  646. "KN_RESERVED4",
  647. "KN_RESERVED5",
  648. "KN_E_LEFT",
  649. "KN_E_HOME",
  650. "KN_E_END",
  651. "KN_RESERVED6",
  652. "KN_E_UP",
  653. "KN_E_DOWN",
  654. "KN_E_PGUP",
  655. "KN_E_PGDN",
  656. "KN_K_LPAREN",
  657. "KN_K_RPAREN",
  658. "KN_E_RIGHT",
  659. "KN_NUMLOCK",
  660. "KN_HOME",
  661. "KN_UPLEFT/KN_HOME",
  662. "KN_LEFT",
  663. "KN_END",
  664. "KN_DOWNLEFT/KN_END",
  665. "KN_RESERVED7",
  666. "KN_KEYPAD_SLASH",
  667. "KN_UP",
  668. "KN_CENTER",
  669. "KN_DOWN",
  670. "KN_INSERT",
  671. "KN_KEYPAD_ASTERISK",
  672. "KN_PGUP",
  673. "KN_UPRIGHT/KN_PGUP",
  674. "KN_RIGHT",
  675. "KN_PGDN",
  676. "KN_DOWNRIGHT/KN_PGDN",
  677. "KN_DELETE",
  678. "KN_KEYPAD_MINUS",
  679. "KN_KEYPAD_PLUS",
  680. "KN_RESERVED8",
  681. "KN_KEYPAD_RETURN",
  682. "KN_RESERVED9",
  683. "KN_ESC",
  684. "KN_HELP",
  685. "KN_F1",
  686. "KN_F2",
  687. "KN_F3",
  688. "KN_F4",
  689. "KN_F5",
  690. "KN_F6",
  691. "KN_F7",
  692. "KN_F8",
  693. "KN_F9",
  694. "KN_F10",
  695. "KN_F11",
  696. "KN_F12",
  697. "KN_PRNTSCRN",
  698. "KN_SCROLLLOCK",
  699. "KN_PAUSE"
  700. };
  701. char *_steve_translate[]={
  702. "?",
  703. "ESC-27",
  704. "1",
  705. "2",
  706. "3",
  707. "4",
  708. "5",
  709. "6",
  710. "7",
  711. "8",
  712. "9",
  713. "0",
  714. "-",
  715. "=",
  716. "BACKSPACE",
  717. "TAB",
  718. "q",
  719. "w",
  720. "e",
  721. "r",
  722. "t",
  723. "y",
  724. "u",
  725. "i",
  726. "o",
  727. "p",
  728. "[",
  729. "]",
  730. "return",
  731. "?",
  732. "a",
  733. "s",
  734. "d",
  735. "f",
  736. "g",
  737. "h",
  738. "j",
  739. "k",
  740. "l",
  741. ";",
  742. "'",
  743. "ESC-27",
  744. "?",
  745. "\\",
  746. "z",
  747. "x",
  748. "c",
  749. "v",
  750. "b",
  751. "n",
  752. "m",
  753. ",",
  754. ".",
  755. "/",
  756. "?",
  757. "*",
  758. "?",
  759. " ",
  760. "?",
  761. "f1-127",
  762. "127",
  763. "?",
  764. "?",
  765. "?",
  766. "?",
  767. "?",
  768. "?",
  769. "?",
  770. "?",
  771. "?",
  772. "?",
  773. "7",
  774. "8",
  775. "9",
  776. "-",
  777. "4",
  778. "5",
  779. "6",
  780. "+",
  781. "1",
  782. "2",
  783. "3",
  784. "?",
  785. "?",
  786. "?",
  787. "?",
  788. "?",
  789. "?",
  790. "F12",
  791. };
  792. static short cxChar, cxCaps, cyChar;
  793. /***********************************************************************************************
  794. * WndProc -- windows message callback *
  795. * *
  796. * Pilfered from a windows example program - HELLOWIN.C *
  797. * *
  798. * *
  799. * INPUT: Standard Windoze callback parameters *
  800. * *
  801. * OUTPUT: long *
  802. * *
  803. * WARNINGS: None *
  804. * *
  805. * HISTORY: *
  806. * 9/27/95 1:39PM ST : Pilfered *
  807. *=============================================================================================*/
  808. long FAR PASCAL _export WndProc (HWND hwnd, UINT message, UINT wParam, LONG lParam)
  809. {
  810. HDC hdc;
  811. PAINTSTRUCT ps;
  812. static int line = 1;
  813. char buffer[100];
  814. TEXTMETRIC tm;
  815. RECT rect;
  816. int transition;
  817. int previous;
  818. int context;
  819. int extended;
  820. int oem;
  821. int rep;
  822. int shift,ctrl,alt,caps,nums;
  823. int vk_key;
  824. BYTE remaptbl[256];
  825. WORD key;
  826. char srcstr[2];
  827. char dststr[2];
  828. switch (message) {
  829. case WM_SYSKEYDOWN:
  830. case WM_SYSKEYUP:
  831. Kbd.Message_Handler(hwnd, message, wParam, lParam);
  832. break;
  833. case WM_KEYDOWN:
  834. case WM_KEYUP:
  835. case WM_LBUTTONDOWN:
  836. case WM_LBUTTONUP:
  837. case WM_LBUTTONDBLCLK:
  838. case WM_MBUTTONDOWN:
  839. case WM_MBUTTONUP:
  840. case WM_MBUTTONDBLCLK:
  841. case WM_RBUTTONDOWN:
  842. case WM_RBUTTONUP:
  843. case WM_RBUTTONDBLCLK:
  844. Kbd.Message_Handler(hwnd, message, wParam, lParam);
  845. // Message_Loop();
  846. return(0);
  847. case WM_CREATE:
  848. hdc = GetDC(hwnd);
  849. GetTextMetrics(hdc, &tm);
  850. cxChar = tm.tmAveCharWidth;
  851. cxCaps = (tm.tmPitchAndFamily & 1 ? 3 : 2) * cxChar / 2;
  852. cyChar = tm.tmHeight + tm.tmExternalLeading;
  853. ReleaseDC(hwnd, hdc);
  854. return(0);
  855. case WM_PAINT:
  856. hdc = BeginPaint(hwnd, &ps);
  857. GetTextMetrics(hdc, &tm);
  858. EndPaint(hwnd, &ps);
  859. return(0);
  860. // case WM_CLOSE:
  861. case WM_DESTROY:
  862. Running = FALSE;
  863. WaitForSingleObject(ThreadHandle, INFINITE);
  864. PostQuitMessage (0);
  865. Reset_Video_Mode();
  866. return(0);
  867. case WM_ACTIVATEAPP:
  868. if ((BOOL)wParam) {
  869. SetEvent(ActiveEvent);
  870. } else {
  871. ResetEvent(ActiveEvent);
  872. }
  873. break;
  874. }
  875. if (line == 23) {
  876. InvalidateRect(hwnd, NULL, TRUE);
  877. line = 1;
  878. }
  879. return DefWindowProc (hwnd, message, wParam, lParam) ;
  880. }
  881. void Message_Loop(void)
  882. {
  883. int key,shift,ctrl,alt,rls,dbl;
  884. char buffer[255];
  885. HDC hdc;
  886. static int line=0;
  887. while (Running) {
  888. WaitForSingleObject(ActiveEvent, INFINITE);
  889. if (Kbd.Check()) {
  890. int key = Kbd.Get();
  891. if (key & WWKEY_VK_BIT) {
  892. Kbd.Split(key, shift, ctrl, alt,rls,dbl);
  893. if (!Kbd.Is_Mouse_Key(key)) {
  894. sprintf(buffer, "Key (VK) = %d (%s) shift = %d control = %d menu = %d rls = %d dbl = %d", key, VK_Name[key], shift, ctrl, alt, rls, dbl);
  895. if (key == 27) {
  896. PostMessage (MainWindow, WM_DESTROY,0,0);
  897. }
  898. } else {
  899. sprintf(buffer, "Mouse = %d @ (%d,%d) shift = %d control = %d menu = %d", key, Kbd.MouseQX, Kbd.MouseQY, shift, ctrl, alt);
  900. }
  901. } else {
  902. Kbd.Split(key, shift, ctrl, alt, rls, dbl);
  903. sprintf(buffer, "Key (ACSII) = %d (%c) shift = %d control = %d menu = %d rls = %d dbl = %d", key, key, shift, ctrl, alt, rls, dbl);
  904. }
  905. hdc = GetDC(MainWindow);
  906. TextOut(hdc, cxChar, cyChar * (line + 1), buffer, lstrlen(buffer));
  907. sprintf(buffer, "Mouses current status: x = %3d, y = %3d", Kbd.Get_Mouse_X(), Kbd.Get_Mouse_Y());
  908. TextOut(hdc, cxChar, cyChar * (1), buffer, lstrlen(buffer));
  909. line++;
  910. if (line == 23) {
  911. InvalidateRect(MainWindow, NULL, TRUE);
  912. line = 1;
  913. }
  914. ReleaseDC(MainWindow, hdc);
  915. }
  916. }
  917. }
  918. /***********************************************************************************************
  919. * WinMain -- Program entry point *
  920. * *
  921. * *
  922. * *
  923. * INPUT: Standard Windows startup parameters *
  924. * *
  925. * OUTPUT: msg.wParam *
  926. * *
  927. * WARNINGS: None *
  928. * *
  929. * HISTORY: *
  930. * 9/27/95 1:28PM ST : Created *
  931. *=============================================================================================*/
  932. int PASCAL WinMain (HANDLE hInstance, HANDLE hPrevInstance,
  933. LPSTR /*lpszCmdParam*/, int nCmdShow)
  934. {
  935. HWND hwnd ;
  936. WNDCLASS wndclass ;
  937. MSG msg ;
  938. int i,j,k;
  939. int key,shift,ctrl,alt,rls,dbl;
  940. char buffer[255];
  941. HDC hdc;
  942. //
  943. // Register the window class
  944. //
  945. if (!hPrevInstance)
  946. {
  947. wndclass.style = CS_HREDRAW | CS_VREDRAW ;
  948. wndclass.lpfnWndProc = WndProc ;
  949. wndclass.cbClsExtra = 0 ;
  950. wndclass.cbWndExtra = 0 ;
  951. wndclass.hInstance = hInstance ;
  952. wndclass.hIcon = LoadIcon (hInstance, IDI_APPLICATION) ;
  953. wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
  954. wndclass.hbrBackground = GetStockObject(WHITE_BRUSH);
  955. wndclass.lpszMenuName = NULL;
  956. wndclass.lpszClassName = NAME;
  957. RegisterClass (&wndclass) ;
  958. }
  959. //
  960. // Create our main window
  961. //
  962. hwnd = MainWindow = CreateWindowEx (
  963. WS_EX_TOPMOST,
  964. NAME,
  965. TITLE,
  966. WS_POPUP | WS_MAXIMIZE,
  967. 0,
  968. 0,
  969. MODE_WIDTH,
  970. MODE_HEIGHT,
  971. NULL,
  972. NULL,
  973. hInstance,
  974. NULL );
  975. ShowWindow (hwnd, nCmdShow) ;
  976. UpdateWindow (hwnd) ;
  977. SetFocus (hwnd);
  978. Set_Video_Mode( MainWindow , MODE_WIDTH , MODE_HEIGHT , 8 );
  979. // ShowWindow (hwnd, nCmdShow) ;
  980. // UpdateWindow (hwnd) ;
  981. // SetFocus (hwnd);
  982. // (Dangerous if Windoze can change the handle)
  983. // Set_Video_Mode( MainWindow , MODE_WIDTH , MODE_HEIGHT , 8 );
  984. #if(TRUE)
  985. DWORD threadid;
  986. ActiveEvent = CreateEvent(NULL, TRUE, TRUE, "Active Event");
  987. ThreadHandle = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Message_Loop, NULL, 0, &threadid);
  988. if (!ThreadHandle) {
  989. DWORD error = GetLastError();
  990. sprintf(buffer, "Last Error was equal to %d", error);
  991. MessageBox(hwnd, buffer,"Error",MB_ICONEXCLAMATION|MB_OK);
  992. return(0);
  993. }
  994. #endif
  995. while (1) {
  996. if (!GetMessage(&msg, NULL, 0, 0)) {
  997. break;
  998. }
  999. TranslateMessage(&msg);
  1000. DispatchMessage(&msg);
  1001. }
  1002. return(0);
  1003. // return msg.wParam;
  1004. }