KEYPAD.C 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. /*
  2. THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
  3. SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
  4. END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
  5. ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
  6. IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
  7. SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
  8. FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
  9. CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
  10. AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
  11. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
  12. */
  13. #include <stdlib.h>
  14. #include <stdio.h>
  15. #include <conio.h>
  16. #include <math.h>
  17. #include <dos.h>
  18. #include <string.h>
  19. #include <direct.h>
  20. #include "fix.h"
  21. #include "types.h"
  22. #include "gr.h"
  23. #include "key.h"
  24. #include "mono.h"
  25. #include "ui.h"
  26. #include "mem.h"
  27. #include "cflib.h"
  28. #include "func.h"
  29. #include "error.h"
  30. #define MAX_NUM_PADS 20
  31. static UI_GADGET_BUTTON * Pad[17];
  32. static UI_KEYPAD * KeyPad[MAX_NUM_PADS];
  33. static int active_pad;
  34. static int desc_x, desc_y;
  35. static int HotKey[17];
  36. static int HotKey1[17];
  37. #define REMOVE_EOL(s) (*(strstr( (s), "\n" ))='\0')
  38. int ui_pad_get_current()
  39. {
  40. return active_pad;
  41. }
  42. void ui_pad_init()
  43. {
  44. int i;
  45. for (i=0; i< MAX_NUM_PADS; i++ )
  46. KeyPad[i] = NULL;
  47. active_pad = -1;
  48. }
  49. void ui_pad_close()
  50. {
  51. int i, j;
  52. for (i=0; i< MAX_NUM_PADS; i++ )
  53. if (KeyPad[i])
  54. {
  55. for (j=0; j<17; j++ )
  56. free(KeyPad[i]->buttontext[j]);
  57. free( KeyPad[i] );
  58. KeyPad[i] = NULL;
  59. }
  60. }
  61. void LineParse( int n, char * dest, char * source )
  62. {
  63. int i = 0, j=0, cn = 0;
  64. // Go to the n'th line
  65. while (cn < n )
  66. if (source[i++] == 179 )
  67. cn++;
  68. // Read up until the next comma
  69. while ( source[i] != 179 )
  70. {
  71. dest[j] = source[i++];
  72. j++;
  73. }
  74. // Null-terminate
  75. dest[j++] = 0;
  76. }
  77. void ui_pad_activate( UI_WINDOW * wnd, int x, int y )
  78. {
  79. int w,h,row,col, n;
  80. int bh, bw;
  81. bw = 56; bh = 30;
  82. gr_set_current_canvas( wnd->canvas );
  83. ui_draw_box_in( x, y, x+(bw*4)+10 + 200, y+(bh*5)+45 );
  84. x += 5;
  85. y += 20;
  86. desc_x = x+2;
  87. desc_y = y-17;
  88. n=0; row = 0; col = 0; w = 1; h = 1;
  89. Pad[n] = ui_add_gadget_button( wnd, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
  90. Pad[n]->canvas->cv_font = ui_small_font;
  91. n=1; row = 0; col = 1; w = 1; h = 1;
  92. Pad[n] = ui_add_gadget_button( wnd, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
  93. Pad[n]->canvas->cv_font = ui_small_font;
  94. n=2; row = 0; col = 2; w = 1; h = 1;
  95. Pad[n] = ui_add_gadget_button( wnd, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
  96. Pad[n]->canvas->cv_font = ui_small_font;
  97. n=3; row = 0; col = 3; w = 1; h = 1;
  98. Pad[n] = ui_add_gadget_button( wnd, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
  99. Pad[n]->canvas->cv_font = ui_small_font;
  100. n=4; row = 1; col = 0; w = 1; h = 1;
  101. Pad[n] = ui_add_gadget_button( wnd, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
  102. Pad[n]->canvas->cv_font = ui_small_font;
  103. n=5; row = 1; col = 1; w = 1; h = 1;
  104. Pad[n] = ui_add_gadget_button( wnd, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
  105. Pad[n]->canvas->cv_font = ui_small_font;
  106. n=6; row = 1; col = 2; w = 1; h = 1;
  107. Pad[n] = ui_add_gadget_button( wnd, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
  108. Pad[n]->canvas->cv_font = ui_small_font;
  109. n=7; row = 1; col = 3; w = 1; h = 2;
  110. Pad[n] = ui_add_gadget_button( wnd, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
  111. Pad[n]->canvas->cv_font = ui_small_font;
  112. n=8; row = 2; col = 0; w = 1; h = 1;
  113. Pad[n] = ui_add_gadget_button( wnd, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
  114. Pad[n]->canvas->cv_font = ui_small_font;
  115. n=9; row = 2; col = 1; w = 1; h = 1;
  116. Pad[n] = ui_add_gadget_button( wnd, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
  117. Pad[n]->canvas->cv_font = ui_small_font;
  118. n=10; row = 2; col = 2; w = 1; h = 1;
  119. Pad[n] = ui_add_gadget_button( wnd, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
  120. Pad[n]->canvas->cv_font = ui_small_font;
  121. n=11; row = 3; col = 0; w = 1; h = 1;
  122. Pad[n] = ui_add_gadget_button( wnd, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
  123. Pad[n]->canvas->cv_font = ui_small_font;
  124. n=12; row = 3; col = 1; w = 1; h = 1;
  125. Pad[n] = ui_add_gadget_button( wnd, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
  126. Pad[n]->canvas->cv_font = ui_small_font;
  127. n=13; row = 3; col = 2; w = 1; h = 1;
  128. Pad[n] = ui_add_gadget_button( wnd, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
  129. Pad[n]->canvas->cv_font = ui_small_font;
  130. n=14; row = 3; col = 3; w = 1; h = 2;
  131. Pad[n] = ui_add_gadget_button( wnd, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
  132. Pad[n]->canvas->cv_font = ui_small_font;
  133. n=15; row = 4; col = 0; w = 2; h = 1;
  134. Pad[n] = ui_add_gadget_button( wnd, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
  135. Pad[n]->canvas->cv_font = ui_small_font;
  136. n=16; row = 4; col = 2; w = 1; h = 1;
  137. Pad[n] = ui_add_gadget_button( wnd, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
  138. Pad[n]->canvas->cv_font = ui_small_font;
  139. HotKey[0] = KEY_CTRLED + KEY_NUMLOCK;
  140. HotKey[1] = KEY_CTRLED + KEY_PADDIVIDE;
  141. HotKey[2] = KEY_CTRLED + KEY_PADMULTIPLY;
  142. HotKey[3] = KEY_CTRLED + KEY_PADMINUS;
  143. HotKey[4] = KEY_CTRLED + KEY_PAD7;
  144. HotKey[5] = KEY_CTRLED + KEY_PAD8;
  145. HotKey[6] = KEY_CTRLED + KEY_PAD9;
  146. HotKey[7] = KEY_CTRLED + KEY_PADPLUS;
  147. HotKey[8] = KEY_CTRLED + KEY_PAD4;
  148. HotKey[9] = KEY_CTRLED + KEY_PAD5;
  149. HotKey[10] = KEY_CTRLED + KEY_PAD6;
  150. HotKey[11] = KEY_CTRLED + KEY_PAD1;
  151. HotKey[12] = KEY_CTRLED + KEY_PAD2;
  152. HotKey[13] = KEY_CTRLED + KEY_PAD3;
  153. HotKey[14] = KEY_CTRLED + KEY_PADENTER;
  154. HotKey[15] = KEY_CTRLED + KEY_PAD0;
  155. HotKey[16] = KEY_CTRLED + KEY_PADPERIOD;
  156. HotKey1[0] = KEY_SHIFTED + KEY_CTRLED + KEY_NUMLOCK;
  157. HotKey1[1] = KEY_SHIFTED + KEY_CTRLED + KEY_PADDIVIDE;
  158. HotKey1[2] = KEY_SHIFTED + KEY_CTRLED + KEY_PADMULTIPLY;
  159. HotKey1[3] = KEY_SHIFTED + KEY_CTRLED + KEY_PADMINUS;
  160. HotKey1[4] = KEY_SHIFTED + KEY_CTRLED + KEY_PAD7;
  161. HotKey1[5] = KEY_SHIFTED + KEY_CTRLED + KEY_PAD8;
  162. HotKey1[6] = KEY_SHIFTED + KEY_CTRLED + KEY_PAD9;
  163. HotKey1[7] = KEY_SHIFTED + KEY_CTRLED + KEY_PADPLUS;
  164. HotKey1[8] = KEY_SHIFTED + KEY_CTRLED + KEY_PAD4;
  165. HotKey1[9] = KEY_SHIFTED + KEY_CTRLED + KEY_PAD5;
  166. HotKey1[10] = KEY_SHIFTED + KEY_CTRLED + KEY_PAD6;
  167. HotKey1[11] = KEY_SHIFTED + KEY_CTRLED + KEY_PAD1;
  168. HotKey1[12] = KEY_SHIFTED + KEY_CTRLED + KEY_PAD2;
  169. HotKey1[13] = KEY_SHIFTED + KEY_CTRLED + KEY_PAD3;
  170. HotKey1[14] = KEY_SHIFTED + KEY_CTRLED + KEY_PADENTER;
  171. HotKey1[15] = KEY_SHIFTED + KEY_CTRLED + KEY_PAD0;
  172. HotKey1[16] = KEY_SHIFTED + KEY_CTRLED + KEY_PADPERIOD;
  173. active_pad = -1;
  174. }
  175. void ui_pad_deactivate()
  176. {
  177. int i;
  178. for (i=0; i<17; i++ )
  179. {
  180. Pad[i]->text = NULL;
  181. }
  182. }
  183. static void ui_pad_set_active( int n )
  184. {
  185. int np;
  186. char * name;
  187. int i, j;
  188. gr_set_current_canvas( NULL );
  189. gr_setcolor( CWHITE );
  190. gr_urect( desc_x, desc_y, desc_x+ 56*4-1, desc_y+15 );
  191. gr_set_fontcolor( CBLACK, CWHITE );
  192. gr_ustring( desc_x, desc_y, KeyPad[n]->description );
  193. for (i=0; i<17; i++ )
  194. {
  195. Pad[i]->text = KeyPad[n]->buttontext[i];
  196. Pad[i]->status = 1;
  197. Pad[i]->user_function = NULL;
  198. Pad[i]->dim_if_no_function = 1;
  199. Pad[i]->hotkey = -1;
  200. for (j=0; j< KeyPad[n]->numkeys; j++ )
  201. {
  202. if (HotKey[i] == KeyPad[n]->keycode[j] )
  203. {
  204. Pad[i]->hotkey = HotKey[i];
  205. Pad[i]->user_function = func_nget( KeyPad[n]->function_number[j], &np, &name );
  206. }
  207. if (HotKey1[i] == KeyPad[n]->keycode[j] )
  208. {
  209. Pad[i]->hotkey1 = HotKey1[i];
  210. Pad[i]->user_function1 = func_nget( KeyPad[n]->function_number[j], &np, &name ); }
  211. }
  212. }
  213. active_pad = n;
  214. }
  215. void ui_pad_goto(int n)
  216. {
  217. if ( KeyPad[n] != NULL )
  218. ui_pad_set_active(n);
  219. }
  220. void ui_pad_goto_next()
  221. {
  222. int i, si;
  223. i = active_pad + 1;
  224. si = i;
  225. while( KeyPad[i]==NULL )
  226. {
  227. i++;
  228. if (i >= MAX_NUM_PADS)
  229. i = 0;
  230. if (i == si )
  231. break;
  232. }
  233. ui_pad_set_active(i);
  234. }
  235. void ui_pad_goto_prev()
  236. {
  237. int i, si;
  238. if (active_pad == -1 )
  239. active_pad = MAX_NUM_PADS;
  240. i = active_pad - 1;
  241. if (i<0) i= MAX_NUM_PADS - 1;
  242. si = i;
  243. while( KeyPad[i]==NULL )
  244. {
  245. i--;
  246. if (i < 0)
  247. i = MAX_NUM_PADS-1;
  248. if (i == active_pad )
  249. break;
  250. }
  251. ui_pad_set_active(i);
  252. }
  253. void ui_pad_read( int n, char * filename )
  254. {
  255. char * ptr;
  256. char buffer[100];
  257. char text[100];
  258. FILE * infile;
  259. int linenumber = 0;
  260. int i;
  261. int keycode, functionnumber;
  262. infile = fopen( filename, "rt" );
  263. if (!infile) {
  264. Warning( "Couldn't find %s", filename );
  265. return;
  266. }
  267. //MALLOC( KeyPad[n], UI_KEYPAD, 1 );//Hack by KRB
  268. KeyPad[n]=(UI_KEYPAD *)malloc(1*sizeof(UI_KEYPAD));
  269. for (i=0; i < 17; i++ ) {
  270. //MALLOC( KeyPad[n]->buttontext[i], char, 100 );//Hack by KRB
  271. KeyPad[n]->buttontext[i]=(char *)malloc(100*sizeof(char));
  272. }
  273. KeyPad[n]->numkeys = 0;
  274. for (i=0; i<100; i++ )
  275. {
  276. KeyPad[n]->keycode[i] = -1;
  277. KeyPad[n]->function_number[i] = 0;
  278. }
  279. while ( linenumber < 22)
  280. {
  281. fgets( buffer, 100, infile );
  282. REMOVE_EOL( buffer );
  283. switch( linenumber+1 )
  284. {
  285. case 1:
  286. strncpy( KeyPad[n]->description, buffer, 100 );
  287. break;
  288. //===================== ROW 0 ==============================
  289. case 3:
  290. LineParse( 1, text, buffer );
  291. sprintf( KeyPad[n]->buttontext[0], "%s\n", text );
  292. LineParse( 2, text, buffer );
  293. sprintf( KeyPad[n]->buttontext[1], "%s\n", text );
  294. LineParse( 3, text, buffer );
  295. sprintf( KeyPad[n]->buttontext[2], "%s\n", text );
  296. LineParse( 4, text, buffer );
  297. sprintf( KeyPad[n]->buttontext[3], "%s\n", text );
  298. break;
  299. case 4:
  300. LineParse( 1, text, buffer );
  301. sprintf( KeyPad[n]->buttontext[0], "%s%s\n", KeyPad[n]->buttontext[0],text );
  302. LineParse( 2, text, buffer );
  303. sprintf( KeyPad[n]->buttontext[1], "%s%s\n", KeyPad[n]->buttontext[1],text );
  304. LineParse( 3, text, buffer );
  305. sprintf( KeyPad[n]->buttontext[2], "%s%s\n", KeyPad[n]->buttontext[2],text );
  306. LineParse( 4, text, buffer );
  307. sprintf( KeyPad[n]->buttontext[3], "%s%s\n", KeyPad[n]->buttontext[3],text );
  308. break;
  309. case 5:
  310. LineParse( 1, text, buffer );
  311. sprintf( KeyPad[n]->buttontext[0], "%s%s", KeyPad[n]->buttontext[0],text );
  312. LineParse( 2, text, buffer );
  313. sprintf( KeyPad[n]->buttontext[1], "%s%s", KeyPad[n]->buttontext[1],text );
  314. LineParse( 3, text, buffer );
  315. sprintf( KeyPad[n]->buttontext[2], "%s%s", KeyPad[n]->buttontext[2],text );
  316. LineParse( 4, text, buffer );
  317. sprintf( KeyPad[n]->buttontext[3], "%s%s", KeyPad[n]->buttontext[3],text );
  318. break;
  319. //===================== ROW 1 ==============================
  320. case 7:
  321. LineParse( 1, text, buffer );
  322. sprintf( KeyPad[n]->buttontext[4], "%s\n", text );
  323. LineParse( 2, text, buffer );
  324. sprintf( KeyPad[n]->buttontext[5], "%s\n", text );
  325. LineParse( 3, text, buffer);
  326. sprintf( KeyPad[n]->buttontext[6], "%s\n", text );
  327. LineParse( 4, text, buffer );
  328. sprintf( KeyPad[n]->buttontext[7], "%s\n", text );
  329. break;
  330. case 8:
  331. LineParse( 1, text, buffer );
  332. sprintf( KeyPad[n]->buttontext[4], "%s%s\n", KeyPad[n]->buttontext[4],text );
  333. LineParse( 2, text, buffer );
  334. sprintf( KeyPad[n]->buttontext[5], "%s%s\n", KeyPad[n]->buttontext[5],text );
  335. LineParse( 3, text, buffer );
  336. sprintf( KeyPad[n]->buttontext[6], "%s%s\n", KeyPad[n]->buttontext[6],text );
  337. LineParse( 4, text, buffer );
  338. sprintf( KeyPad[n]->buttontext[7], "%s%s\n", KeyPad[n]->buttontext[7],text );
  339. break;
  340. case 9:
  341. LineParse( 1, text, buffer );
  342. sprintf( KeyPad[n]->buttontext[4], "%s%s", KeyPad[n]->buttontext[4],text );
  343. LineParse( 2, text, buffer );
  344. sprintf( KeyPad[n]->buttontext[5], "%s%s", KeyPad[n]->buttontext[5],text );
  345. LineParse( 3, text, buffer );
  346. sprintf( KeyPad[n]->buttontext[6], "%s%s", KeyPad[n]->buttontext[6],text );
  347. LineParse( 4, text, buffer );
  348. sprintf( KeyPad[n]->buttontext[7], "%s%s\n", KeyPad[n]->buttontext[7],text );
  349. break;
  350. case 10:
  351. ptr = strrchr( buffer, 179 );
  352. *ptr = 0;
  353. ptr = strrchr( buffer, 180 ); ptr++;
  354. sprintf( KeyPad[n]->buttontext[7], "%s%s\n", KeyPad[n]->buttontext[7],ptr );
  355. break;
  356. //======================= ROW 2 ==============================
  357. case 11:
  358. LineParse( 1, text, buffer );
  359. sprintf( KeyPad[n]->buttontext[8], "%s\n", text );
  360. LineParse( 2, text, buffer );
  361. sprintf( KeyPad[n]->buttontext[9], "%s\n", text );
  362. LineParse( 3, text, buffer);
  363. sprintf( KeyPad[n]->buttontext[10], "%s\n", text );
  364. LineParse( 4, text, buffer );
  365. sprintf( KeyPad[n]->buttontext[7], "%s%s\n", KeyPad[n]->buttontext[7],text );
  366. break;
  367. case 12:
  368. LineParse( 1, text, buffer );
  369. sprintf( KeyPad[n]->buttontext[8], "%s%s\n", KeyPad[n]->buttontext[8],text );
  370. LineParse( 2, text, buffer );
  371. sprintf( KeyPad[n]->buttontext[9], "%s%s\n", KeyPad[n]->buttontext[9],text );
  372. LineParse( 3, text, buffer );
  373. sprintf( KeyPad[n]->buttontext[10], "%s%s\n", KeyPad[n]->buttontext[10],text );
  374. LineParse( 4, text, buffer );
  375. sprintf( KeyPad[n]->buttontext[7], "%s%s\n", KeyPad[n]->buttontext[7],text );
  376. break;
  377. case 13:
  378. LineParse( 1, text, buffer );
  379. sprintf( KeyPad[n]->buttontext[8], "%s%s", KeyPad[n]->buttontext[8],text );
  380. LineParse( 2, text, buffer );
  381. sprintf( KeyPad[n]->buttontext[9], "%s%s", KeyPad[n]->buttontext[9],text );
  382. LineParse( 3, text, buffer );
  383. sprintf( KeyPad[n]->buttontext[10], "%s%s", KeyPad[n]->buttontext[10],text );
  384. LineParse( 4, text, buffer );
  385. sprintf( KeyPad[n]->buttontext[7], "%s%s", KeyPad[n]->buttontext[7],text );
  386. break;
  387. // ====================== ROW 3 =========================
  388. case 15:
  389. LineParse( 1, text, buffer );
  390. sprintf( KeyPad[n]->buttontext[11], "%s\n", text );
  391. LineParse( 2, text, buffer );
  392. sprintf( KeyPad[n]->buttontext[12], "%s\n", text );
  393. LineParse( 3, text, buffer);
  394. sprintf( KeyPad[n]->buttontext[13], "%s\n", text );
  395. LineParse( 4, text, buffer );
  396. sprintf( KeyPad[n]->buttontext[14], "%s\n", text );
  397. break;
  398. case 16:
  399. LineParse( 1, text, buffer );
  400. sprintf( KeyPad[n]->buttontext[11], "%s%s\n", KeyPad[n]->buttontext[11],text );
  401. LineParse( 2, text, buffer );
  402. sprintf( KeyPad[n]->buttontext[12], "%s%s\n", KeyPad[n]->buttontext[12],text );
  403. LineParse( 3, text, buffer );
  404. sprintf( KeyPad[n]->buttontext[13], "%s%s\n", KeyPad[n]->buttontext[13],text );
  405. LineParse( 4, text, buffer );
  406. sprintf( KeyPad[n]->buttontext[14], "%s%s\n", KeyPad[n]->buttontext[14],text );
  407. break;
  408. case 17:
  409. LineParse( 1, text, buffer );
  410. sprintf( KeyPad[n]->buttontext[11], "%s%s", KeyPad[n]->buttontext[11],text );
  411. LineParse( 2, text, buffer );
  412. sprintf( KeyPad[n]->buttontext[12], "%s%s", KeyPad[n]->buttontext[12],text );
  413. LineParse( 3, text, buffer );
  414. sprintf( KeyPad[n]->buttontext[13], "%s%s", KeyPad[n]->buttontext[13],text );
  415. LineParse( 4, text, buffer );
  416. sprintf( KeyPad[n]->buttontext[14], "%s%s\n", KeyPad[n]->buttontext[14],text );
  417. break;
  418. case 18:
  419. ptr = strrchr( buffer, 179 );
  420. *ptr = 0;
  421. ptr = strrchr( buffer, 180 ); ptr++;
  422. sprintf( KeyPad[n]->buttontext[14], "%s%s\n", KeyPad[n]->buttontext[14], ptr );
  423. break;
  424. //======================= ROW 4 =========================
  425. case 19:
  426. LineParse( 1, text, buffer );
  427. sprintf( KeyPad[n]->buttontext[15], "%s\n", text );
  428. LineParse( 2, text, buffer );
  429. sprintf( KeyPad[n]->buttontext[16], "%s\n", text );
  430. LineParse( 3, text, buffer );
  431. sprintf( KeyPad[n]->buttontext[14], "%s%s\n", KeyPad[n]->buttontext[14],text );
  432. break;
  433. case 20:
  434. LineParse( 1, text, buffer );
  435. sprintf( KeyPad[n]->buttontext[15], "%s%s\n", KeyPad[n]->buttontext[15],text );
  436. LineParse( 2, text, buffer );
  437. sprintf( KeyPad[n]->buttontext[16], "%s%s\n", KeyPad[n]->buttontext[16],text );
  438. LineParse( 3, text, buffer );
  439. sprintf( KeyPad[n]->buttontext[14], "%s%s\n", KeyPad[n]->buttontext[14],text );
  440. break;
  441. case 21:
  442. LineParse( 1, text, buffer );
  443. sprintf( KeyPad[n]->buttontext[15], "%s%s", KeyPad[n]->buttontext[15],text );
  444. LineParse( 2, text, buffer );
  445. sprintf( KeyPad[n]->buttontext[16], "%s%s", KeyPad[n]->buttontext[16],text );
  446. LineParse( 3, text, buffer );
  447. sprintf( KeyPad[n]->buttontext[14], "%s%s", KeyPad[n]->buttontext[14],text );
  448. break;
  449. }
  450. linenumber++;
  451. }
  452. // Get the keycodes...
  453. while (fscanf( infile, " %s %s ", text, buffer )!=EOF)
  454. {
  455. keycode = DecodeKeyText(text);
  456. functionnumber = func_get_index(buffer);
  457. if (functionnumber==-1)
  458. {
  459. Error( "Unknown function, %s, in %s\n", buffer, filename );
  460. } else if (keycode==-1)
  461. {
  462. Error( "Unknown keystroke, %s, in %s\n", text, filename );
  463. //MessageBox( -2, -2, 1, buffer, "Ok" );
  464. } else {
  465. KeyPad[n]->keycode[KeyPad[n]->numkeys] = keycode;
  466. KeyPad[n]->function_number[KeyPad[n]->numkeys] = functionnumber;
  467. KeyPad[n]->numkeys++;
  468. }
  469. }
  470. fclose(infile);
  471. }
  472. /*
  473. ui_pad_init(2);
  474. ui_pad_read( 0, "curve.pad" );
  475. ui_pad_read( 1, "segmove.pad" );
  476. //open window
  477. ui_pad_activate();
  478. ui_pad_goto( n );
  479. ui_pad_goto_next( n );
  480. ui_pad_goto_previous( n );
  481. ui_pad_deactivate();
  482. //close window
  483. ui_pad_close();
  484. exit();
  485. */