1 /***********************************************************************
2 * ���٥�Ƚ��� (�����ƥ��¸)
3 *
4 * �ܺ٤ϡ� event.h ����
5 ************************************************************************/
6
7 #include "quasi88.h"
8 #include "device.h"
9
10 #include "event.h"
11 #include "keyboard.h"
12
13
14
15 static int now_charcode = FALSE;
16
17
18 /* ���ۥ����ȡ�KEY88 ���б� */
19 static int keysym2key88[ 256 ];
20
21 /* ���ۥ����ȡ�KEY88 ���б� (�ǥե����) */
22 static const int keysym2key88_default[256] =
23 {
24 0,
25 0, /* VK_LBUTTON 0x01 */
26 0, /* VK_RBUTTON 0x02 */
27 KEY88_STOP, /* VK_CANCEL 0x03 */
28 0, /* VK_MBUTTON 0x04 */
29 0,
30 0,
31 0,
32
33 KEY88_INS_DEL, /* VK_BACK 0x08 */
34 KEY88_TAB, /* VK_TAB 0x09 */
35 0,
36 0,
37 KEY88_KP_5, /* VK_CLEAR 0x0C */
38 KEY88_RETURNL, /* VK_RETURN 0x0D */
39 0,
40 0,
41
42 KEY88_SHIFTL, /* VK_SHIFT 0x10 */
43 KEY88_CTRL, /* VK_CONTROL 0x11 */
44 KEY88_GRAPH, /* VK_MENU 0x12 */
45 KEY88_STOP, /* VK_PAUSE 0x13 */
46 KEY88_CAPS, /* VK_CAPITAL 0x14 */
47 0, /* VK_KANA 0x15 */
48 0,
49 0, /* VK_JUNJA 0x17 */
50
51 0, /* VK_FINAL 0x18 */
52 0, /* VK_KANJI 0x19 */
53 0,
54 KEY88_ESC, /* VK_ESCAPE 0x1B */
55 0, /* VK_CONVERT 0x1C */ /* �Ѵ� */
56 0, /* VK_NONCONVERT 0x1D */ /* ̵�Ѵ� */
57 0, /* VK_ACCEPT 0x1E */
58 0, /* VK_MODECHANGE 0x1F */
59
60 KEY88_SPACE, /* VK_SPACE 0x20 */
61 KEY88_ROLLDOWN, /* VK_PRIOR 0x21 */
62 KEY88_ROLLUP, /* VK_NEXT 0x22 */
63 KEY88_HELP, /* VK_END 0x23 */
64 KEY88_HOME, /* VK_HOME 0x24 */
65 KEY88_LEFT, /* VK_LEFT 0x25 */
66 KEY88_UP, /* VK_UP 0x26 */
67 KEY88_RIGHT, /* VK_RIGHT 0x27 */
68
69 KEY88_DOWN, /* VK_DOWN 0x28 */
70 0, /* VK_SELECT 0x29 */
71 0, /* VK_PRINT 0x2A */
72 0, /* VK_EXECUTE 0x2B */
73 KEY88_COPY, /* VK_SNAPSHOT 0x2C */
74 KEY88_INS, /* VK_INSERT 0x2D */
75 KEY88_DEL, /* VK_DELETE 0x2E */
76 0, /* VK_HELP 0x2F */
77
78 /* VK_0 thru VK_9 are the same as ASCII '0' thru '9' (0x30 - 0x39) */
79 /* VK_A thru VK_Z are the same as ASCII 'A' thru 'Z' (0x41 - 0x5A) */
80
81 KEY88_0,
82 KEY88_1,
83 KEY88_2,
84 KEY88_3,
85 KEY88_4,
86 KEY88_5,
87 KEY88_6,
88 KEY88_7,
89
90 KEY88_8,
91 KEY88_9,
92 0,
93 0,
94 0,
95 0,
96 0,
97 0,
98
99 0,
100 KEY88_A,
101 KEY88_B,
102 KEY88_C,
103 KEY88_D,
104 KEY88_E,
105 KEY88_F,
106 KEY88_G,
107
108 KEY88_H,
109 KEY88_I,
110 KEY88_J,
111 KEY88_K,
112 KEY88_L,
113 KEY88_M,
114 KEY88_N,
115 KEY88_O,
116
117 KEY88_P,
118 KEY88_Q,
119 KEY88_R,
120 KEY88_S,
121 KEY88_T,
122 KEY88_U,
123 KEY88_V,
124 KEY88_W,
125
126 KEY88_X,
127 KEY88_Y,
128 KEY88_Z,
129 0, /* VK_LWIN 0x5B */
130 0, /* VK_RWIN 0x5C */
131 0, /* VK_APPS 0x5D */
132 0,
133 0,
134
135 KEY88_KP_0, /* VK_NUMPAD0 0x60 */
136 KEY88_KP_1, /* VK_NUMPAD1 0x61 */
137 KEY88_KP_2, /* VK_NUMPAD2 0x62 */
138 KEY88_KP_3, /* VK_NUMPAD3 0x63 */
139 KEY88_KP_4, /* VK_NUMPAD4 0x64 */
140 KEY88_KP_5, /* VK_NUMPAD5 0x65 */
141 KEY88_KP_6, /* VK_NUMPAD6 0x66 */
142 KEY88_KP_7, /* VK_NUMPAD7 0x67 */
143
144 KEY88_KP_8, /* VK_NUMPAD8 0x68 */
145 KEY88_KP_9, /* VK_NUMPAD9 0x69 */
146 KEY88_KP_MULTIPLY, /* VK_MULTIPLY 0x6A */
147 KEY88_KP_ADD, /* VK_ADD 0x6B */
148 0, /* VK_SEPARATOR 0x6C */
149 KEY88_KP_SUB, /* VK_SUBTRACT 0x6D */
150 KEY88_KP_PERIOD, /* VK_DECIMAL 0x6E */
151 KEY88_KP_DIVIDE, /* VK_DIVIDE 0x6F */
152
153 KEY88_F1, /* VK_F1 0x70 */
154 KEY88_F2, /* VK_F2 0x71 */
155 KEY88_F3, /* VK_F3 0x72 */
156 KEY88_F4, /* VK_F4 0x73 */
157 KEY88_F5, /* VK_F5 0x74 */
158 KEY88_F6, /* VK_F6 0x75 */
159 KEY88_F7, /* VK_F7 0x76 */
160 KEY88_F8, /* VK_F8 0x77 */
161
162 KEY88_F9, /* VK_F9 0x78 */
163 KEY88_F10, /* VK_F10 0x79 */
164 KEY88_F11, /* VK_F11 0x7A */
165 KEY88_F12, /* VK_F12 0x7B */
166 KEY88_F13, /* VK_F13 0x7C */
167 KEY88_F14, /* VK_F14 0x7D */
168 KEY88_F15, /* VK_F15 0x7E */
169 0, /* VK_F16 0x7F */
170
171 0, /* VK_F17 0x80 */
172 0, /* VK_F18 0x81 */
173 0, /* VK_F19 0x82 */
174 0, /* VK_F20 0x83 */
175 0, /* VK_F21 0x84 */
176 0, /* VK_F22 0x85 */
177 0, /* VK_F23 0x86 */
178 0, /* VK_F24 0x87 */
179
180 0,
181 0,
182 0,
183 0,
184 0,
185 0,
186 0,
187 0,
188
189 0, /* VK_NUMLOCK 0x90 */
190 KEY88_KANA, /* VK_SCROLL 0x91 */
191 0,
192 0,
193 0,
194 0,
195 0,
196 0,
197
198 0,
199 0,
200 0,
201 0,
202 0,
203 0,
204 0,
205 0,
206
207 /*
208 * VK_L* & VK_R* - left and right Alt, Ctrl and Shift virtual keys.
209 * Used only as parameters to GetAsyncKeyState() and GetKeyState().
210 * No other API or message will distinguish left and right keys in this way.
211 */
212
213 KEY88_SHIFTL, /* VK_LSHIFT 0xA0 */
214 KEY88_SHIFTR, /* VK_RSHIFT 0xA1 */
215 KEY88_CTRL, /* VK_LCONTROL 0xA2 */
216 KEY88_CTRL, /* VK_RCONTROL 0xA3 */
217 KEY88_GRAPH, /* VK_LMENU 0xA4 */
218 KEY88_GRAPH, /* VK_RMENU 0xA5 */
219 0,
220 0,
221
222 0,
223 0,
224 0,
225 0,
226 0,
227 0,
228 0,
229 0,
230
231 0,
232 0,
233 0,
234 0,
235 0,
236 0,
237 0,
238 0,
239
240 0,
241 0,
242 KEY88_COLON,
243 KEY88_SEMICOLON,
244 KEY88_COMMA,
245 KEY88_MINUS,
246 KEY88_PERIOD,
247 KEY88_SLASH,
248
249 KEY88_AT,
250 0,
251 0,
252 0,
253 0,
254 0,
255 0,
256 0,
257
258 0,
259 0,
260 0,
261 0,
262 0,
263 0,
264 0,
265 0,
266
267 0,
268 0,
269 0,
270 0,
271 0,
272 0,
273 0,
274 0,
275
276 0,
277 0,
278 0,
279 KEY88_BRACKETLEFT,
280 KEY88_YEN,
281 KEY88_BRACKETRIGHT,
282 KEY88_CARET,
283 0,
284
285 0,
286 0,
287 KEY88_UNDERSCORE,
288 0,
289 0,
290 0, /* VK_PROCESSKEY 0xE5 */
291 0,
292 0,
293
294 0,
295 0,
296 0,
297 0,
298 0,
299 0,
300 0,
301 0,
302
303 0,
304 0,
305 0,
306 0,
307 0,
308 0,
309 0, /* VK_ATTN 0xF6 */
310 0, /* VK_CRSEL 0xF7 */
311
312 0, /* VK_EXSEL 0xF8 */
313 0, /* VK_EREOF 0xF9 */
314 0, /* VK_PLAY 0xFA */
315 0, /* VK_ZOOM 0xFB */
316 0, /* VK_NONAME 0xFC */
317 0, /* VK_PA1 0xFD */
318 0, /* VK_OEM_CLEAR 0xFE */
319 0,
320 };
321
322
323 /******************************************************************************
324 * ������ɥ��ץ�������
325 *****************************************************************************/
326 static void key_event_debug(UINT msg, WPARAM wp, LPARAM lp);
327
WndProc(HWND hWnd,UINT msg,WPARAM wp,LPARAM lp)328 LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
329 {
330 int on, key88;
331 int x, y;
332
333 switch(msg) {
334
335 case WM_ERASEBKGND: /* WM_PAINT��ľ������롢���̥��ꥢ�� */
336 return 0;
337
338 case WM_PAINT: /* ���褹�٤������ߥ������Ƥ��� */
339 if (graph_update_WM_PAINT() == FALSE) {
340 /*
341 fprintf(debugfp, "Expose\n");
342 */
343 quasi88_expose();
344 }
345 return 0;
346
347
348 case WM_MOUSEMOVE: /* �ޥ������������ư */
349 x = LOWORD(lp);
350 y = HIWORD(lp);
351 /*
352 fprintf(debugfp, "Move %d %d\n",x,y);
353 */
354 quasi88_mouse_moved_abs(x, y);
355 return 0;
356
357
358 case WM_LBUTTONDOWN: /* �ޥ������ܥ��� */
359 case WM_LBUTTONUP: /* �ޥ������ܥ������ */
360 case WM_RBUTTONDOWN: /* �ޥ������ܥ��� */
361 case WM_RBUTTONUP: /* �ޥ������ܥ������ */
362
363 if (msg == WM_LBUTTONDOWN ||
364 msg == WM_LBUTTONUP) { key88 = KEY88_MOUSE_L; }
365 else { key88 = KEY88_MOUSE_R; }
366 if (msg == WM_LBUTTONDOWN ||
367 msg == WM_RBUTTONDOWN) { on = TRUE; SetCapture(hWnd); }
368 else { on = FALSE; ReleaseCapture(); }
369 /*
370 fprintf(debugfp, "%c:%s %d %d\n", (key88 == KEY88_MOUSE_L) ? 'L' : 'R',
371 (on ? "On " : "Off"), LOWORD(lp), HIWORD(lp));
372 */
373 quasi88_mouse(key88, on);
374 return 0;
375
376
377 case WM_KEYDOWN: /* �������� */
378 case WM_KEYUP: /* �������� */
379 case WM_SYSKEYDOWN: /* �����ƥ७������ (Alt, F10) */
380 case WM_SYSKEYUP: /* �����ƥ७������ (Alt, F10) */
381 case WM_CHAR: /* ʸ������ */
382
383 #if 0
384 key_event_debug(msg, wp, lp); /* �ǥХå��ѤΡ����������å� */
385 return 0;
386 #endif
387
388 if (now_charcode) { /* WM_CHAR �� (��˥塼��) */
389
390 if (msg == WM_CHAR) {
391
392 if (isprint(wp)) {
393 /* ɽ���Ǥ���ʸ���ϡ��������� */
394 } else {
395 /* ɽ���Ǥ��ʤ�ʸ���ϡ�̵�� */
396 return 0;
397 }
398
399 } else {
400 if (( wp == ' ') || /* ���� */
401 ('0' <= wp && wp <= '9') || /* ���� */
402 ('A' <= wp && wp <= 'Z') || /* �ѻ� */
403 (0x60 <= wp && wp <= 0x6f) || /* �ƥ� */
404 (0xb0 <= wp && wp <= 0xef)) { /* ���業�� */
405
406 /* �����Υ����� WM_CHAR ���Ԥ� */
407 return 0;
408 } else {
409 /* �ü쥭�������業���Ͻ������� */
410 }
411 }
412
413 } else { /* WM_CHAR ��ΤƤ� (���ߥ���) */
414
415 if (msg == WM_CHAR) {
416 /* ʸ�����٥�Ȥϡ�̵�� */
417 return 0;
418 } else {
419 /* ���������դϽ������� */
420 }
421 }
422
423 if (msg == WM_KEYUP || msg == WM_SYSKEYUP) { on = FALSE; }
424 else { on = TRUE; }
425
426
427 /* bit30 �ϡ�ľ���β��� (�Ĥޤ�Ϣ³����)��ɽ�� ��*/
428 if (on && (g_keyrepeat == FALSE) && (lp & 0x40000000UL)) {
429 /* ������ԡ��Ȥξ��ϡ����ˤ��̵�� */
430 return 0;
431 }
432
433
434 if (msg == WM_CHAR) {
435 key88 = wp;
436 } else {
437 /* bit24 �ϳ�ĥ�����ե饰����Alt����Ctrl��
438 �� �ƥ��ʳ������������������� 1 */
439 if (((lp & (1UL<<24)) == 0) && (now_charcode == FALSE)) {
440 /* NumLock �ʤ��ǥƥ������ʤ顢�������ɤ��ؤ��� */
441 if (wp == VK_INSERT) wp = VK_NUMPAD0;
442 else if (wp == VK_DELETE) wp = VK_DECIMAL;
443 else if (wp == VK_END) wp = VK_NUMPAD1;
444 else if (wp == VK_DOWN) wp = VK_NUMPAD2;
445 else if (wp == VK_NEXT) wp = VK_NUMPAD3;
446 else if (wp == VK_LEFT) wp = VK_NUMPAD4;
447 else if (wp == VK_CLEAR) wp = VK_NUMPAD5;
448 else if (wp == VK_RIGHT) wp = VK_NUMPAD6;
449 else if (wp == VK_HOME) wp = VK_NUMPAD7;
450 else if (wp == VK_UP) wp = VK_NUMPAD8;
451 else if (wp == VK_PRIOR) wp = VK_NUMPAD9;
452 }
453
454 if (wp == VK_CAPITAL ||
455 wp == VK_SCROLL) {
456 /* �Dz��̥ӥåȤϥȥ�����֤�ɽ�� �� */
457 int toggle = GetKeyState(wp) & 0x01;
458
459 if ((on && toggle) ||
460 (on == FALSE && toggle == FALSE)) {
461 /* ���������ȥȥ�����֤����פ��Ƥ��OK */
462 } else {
463 /* ���פ��Ƥʤ���С�������̵�뤹�� */
464 return 0;
465 }
466 }
467
468 key88 = keysym2key88[ wp ];
469 }
470 /*
471 fprintf(debugfp,
472 "%s <%s>\n", (on) ? "ON " : "OFF", keyboard_key882str(key88));
473 */
474 quasi88_key(key88, on);
475
476 /* WM_CHAR �ξ�硢�������ե��٥�Ȥ��ʤ����ɡĤޤ������� */
477 return 0;
478
479
480 case WM_SETFOCUS:
481 /*
482 fprintf(debugfp, "Focus In\n");
483 */
484 quasi88_focus_in();
485 return 0;
486
487 case WM_KILLFOCUS:
488 /*
489 fprintf(debugfp, "Focus Out\n");
490 */
491 quasi88_focus_out();
492 return 0;
493
494 #ifdef USE_SOUND
495 /* ������ɷϤΥ��٥�� */
496 case MM_WOM_OPEN:
497 wave_event_open((HWAVEOUT)wp);
498 return 0;
499
500 case MM_WOM_DONE:
501 wave_event_done((HWAVEOUT)wp, (LPWAVEHDR)lp);
502 return 0;
503
504 case MM_WOM_CLOSE:
505 wave_event_close((HWAVEOUT)wp);
506 return 0;
507 #endif
508
509 case WM_DROPFILES:
510 {
511 HDROP hDrop;
512 int i, file_num;
513 char filename[ OSD_MAX_FILENAME ];
514
515 hDrop = (HDROP)wp;
516 file_num = (int)DragQueryFile(hDrop, 0xffffffff, NULL, 0);
517 /*
518 for (i = 0; i < file_num; i++) {
519 DragQueryFile(hDrop, i, filename, sizeof(filename));
520 fprintf(debugfp, "%d %s\n", i, filename);
521 }
522 */
523 if (file_num > 0) {
524 DragQueryFile(hDrop, 0, filename, sizeof(filename));
525
526 if (quasi88_drag_and_drop(filename)) {
527 menubar_setup(TRUE); /* ��˥塼�С������ƹ��� */
528 }
529 }
530
531 DragFinish(hDrop);
532 }
533 return 0;
534
535 case WM_COMMAND:
536 if (menubar_event(LOWORD(wp))) {
537 return 0;
538 }
539 break;
540
541 case WM_CLOSE:
542 /* ������ɥ����Ĥ��褦�Ȥ�����硢��ǧ������ʤ餳���� */
543 /*
544 fprintf(debugfp, "Close\n");
545 */
546 /*return 0;*/
547 break;
548
549 case WM_DESTROY:
550 /*
551 fprintf(debugfp, "Destroy\n");
552 */
553 PostQuitMessage(0);
554 return 0;
555 }
556
557 return DefWindowProc(hWnd, msg, wp, lp);
558 }
559
560 /******************************************************************************
561 * ���٥�ȥϥ�ɥ��
562 *
563 * 1/60��˸ƤӽФ���롣
564 *****************************************************************************/
565
566 /*
567 * ����� ��ư����1������ƤФ��
568 */
event_init(void)569 void event_init(void)
570 {
571 memcpy(keysym2key88, keysym2key88_default, sizeof(keysym2key88_default));
572 }
573
574
575
576 /*
577 * �� 1/60 ��˸ƤФ��
578 */
event_update(void)579 void event_update(void)
580 {
581 MSG msg;
582
583 #if 0 /* ���ܷ� */
584 while (GetMessage(&msg, NULL, 0, 0)) { /* ����������� */
585 TranslateMessage(&msg); /* ���������ɤʤ��ľ�� */
586 DispatchMessage(&msg); /* �ץ������������ */
587 }
588 #elif 0
589
590 while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) {
591 if (GetMessage(&msg, NULL, 0, 0)) { /* ����������� */
592 TranslateMessage(&msg); /* ���������ɤʤ��ľ�� */
593 DispatchMessage(&msg); /* �ץ������������ */
594 }
595 }
596
597 #elif 1
598
599 while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) {
600 if (GetMessage(&msg, NULL, 0, 0)) { /* ����������� */
601
602 TranslateMessage(&msg); /* ���������ɤʤ��ľ�� */
603 DispatchMessage(&msg); /* �ץ������������ */
604
605 } else { /* �������� */
606 quasi88_quit();
607 break;
608 }
609 }
610
611
612 #elif 0 /* ��˥塼�������硩 */
613
614 HACCEL hAccel= LoadAccelerators(hAppModule, MAKEINTRESOURCE(IDR_ACCEL1));
615 while (GetMessage(&msg, NULL, 0, 0)) {
616 if (!TranslateAccelerator(hWnd, hAccel, &msg)) { /* ��˥塼���� */
617 TranslateMessage(&msg);
618 DispatchMessage(&msg);
619 }
620 }
621
622 #elif 0 /* ����ϡ� */
623 while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) {
624 if (GetMessage(&msg, NULL, 0, 0)) {
625
626 if (((msg.message == WM_SYSKEYDOWN) ||
627 (msg.message == WM_SYSKEYUP)) &&
628 (msg.wParam == VK_F10)) {
629 /* DO NOTHING */
630 } else
631 {
632 if (TranslateAccelerator(GetWndHandle(), m_haccel, &msg) == FALSE) {
633 TranslateMessage(&msg);
634 DispatchMessage(&msg);
635 }
636 }
637
638 } else { /* ���顼�� */
639 quasi88_quit();
640 break;
641 }
642 }
643 #endif
644 }
645
646 /*
647 * ����� ��λ����1������ƤФ��
648 */
event_exit(void)649 void event_exit(void)
650 {
651 }
652
653
654
655
656 /***********************************************************************
657 * ���ߤΥޥ�����ɸ�����ؿ�
658 *
659 ************************************************************************/
660
event_get_mouse_pos(int * x,int * y)661 void event_get_mouse_pos(int *x, int *y)
662 {
663 POINT pos;
664
665 GetCursorPos(&pos);
666
667 if (ScreenToClient(g_hWnd, &pos)) {
668 *x = pos.x;
669 *y = pos.y;
670 } else {
671 *x = 0;
672 *y = 0;
673 }
674 }
675
676
677 /******************************************************************************
678 * ���եȥ����� NumLock ͭ����̵��
679 *
680 *****************************************************************************/
681
event_numlock_on(void)682 int event_numlock_on (void)
683 {
684 /* ���եȥ����� NumLock ͭ���ʤ顢�ᥤ���ΰ�����ƥ��ˤ��� */
685
686 keysym2key88[ '5' ] = KEY88_HOME;
687 keysym2key88[ '6' ] = KEY88_HELP;
688 keysym2key88[ '7' ] = KEY88_KP_7;
689 keysym2key88[ '8' ] = KEY88_KP_8;
690 keysym2key88[ '9' ] = KEY88_KP_9;
691 keysym2key88[ '0' ] = KEY88_KP_MULTIPLY;
692 keysym2key88[ 0xbd ]/* - */ = KEY88_KP_SUB;
693 keysym2key88[ 0xde ]/* ^ */ = KEY88_KP_DIVIDE;
694 keysym2key88[ 'U' ] = KEY88_KP_4;
695 keysym2key88[ 'I' ] = KEY88_KP_5;
696 keysym2key88[ 'O' ] = KEY88_KP_6;
697 keysym2key88[ 'P' ] = KEY88_KP_ADD;
698 keysym2key88[ 'J' ] = KEY88_KP_1;
699 keysym2key88[ 'K' ] = KEY88_KP_2;
700 keysym2key88[ 'L' ] = KEY88_KP_3;
701 keysym2key88[ 0xbb ]/* ; */ = KEY88_KP_EQUAL;
702 keysym2key88[ 'M' ] = KEY88_KP_0;
703 keysym2key88[ 0xbc ]/* , */ = KEY88_KP_COMMA;
704 keysym2key88[ 0xbe ]/* . */ = KEY88_KP_PERIOD;
705 keysym2key88[ 0xbf ]/* / */ = KEY88_RETURNR;
706
707 return TRUE;
708 }
event_numlock_off(void)709 void event_numlock_off(void)
710 {
711 /* ���եȥ����� NumLock ̵���ʤ顢�ǥե���Ȥ��᤹ */
712
713 memcpy(keysym2key88, keysym2key88_default, sizeof(keysym2key88_default));
714 }
715
716
717
718 /******************************************************************************
719 * ���ߥ�졼�ȡ���˥塼���ݡ�������˥����⡼�� �� ���ϻ��ν���
720 *
721 *****************************************************************************/
722
event_switch(void)723 void event_switch(void)
724 {
725 if (quasi88_is_exec()) { /* ���ߥ�⡼�ɤʤ� */
726
727 now_charcode = FALSE; /* WM_CHAR ���٥��̵�� */
728
729 menubar_setup(TRUE); /* ��˥塼�С�ͭ�� */
730
731 } else { /* ��˥塼�⡼�ɤʤɤʤ� */
732
733 now_charcode = TRUE; /* WM_CHAR ���٥�Ƚ��� */
734
735 menubar_setup(FALSE); /* ��˥塼�С�̵�� */
736 }
737 }
738
739
740
741 /******************************************************************************
742 * ���祤���ƥ��å�
743 *
744 *****************************************************************************/
745
event_get_joystick_num(void)746 int event_get_joystick_num(void)
747 {
748 return 0;
749 }
750
751
752
753
754
755
756 /*---------------------------------------------------------------------------
757 *
758 * �ǥХå�
759 *
760 *---------------------------------------------------------------------------*/
761
762 static const char *vk_list[256] =
763 {
764 0,
765 "VK_LBUTTON", /* 0x01 */
766 "VK_RBUTTON", /* 0x02 */
767 "VK_CANCEL", /* 0x03 */ /* Ctrl + Pause, Ctrl + ScrollLock */
768 "VK_MBUTTON", /* 0x04 */
769 0,
770 0,
771 0,
772
773 "VK_BACK", /* 0x08 */ /* BackSpace */
774 "VK_TAB", /* 0x09 */
775 0,
776 0,
777 "VK_CLEAR", /* 0x0C */ /* �ƥ� 5 */
778 "VK_RETURN", /* 0x0D */ /* Enter */
779 0,
780 0,
781
782 "VK_SHIFT", /* 0x10 */
783 "VK_CONTROL", /* 0x11 */
784 "VK_MENU", /* 0x12 */ /* Alt */
785 "VK_PAUSE", /* 0x13 */
786 "VK_CAPITAL", /* 0x14 */ /* CapsLock */
787 "VK_KANA", /* 0x15 */
788 0,
789 "VK_JUNJA", /* 0x17 */
790
791 "VK_FINAL", /* 0x18 */
792 "VK_KANJI", /* 0x19 */ /* Alt + ����Ⱦ�� */
793 0,
794 "VK_ESCAPE", /* 0x1B */
795 "VK_CONVERT", /* 0x1C */ /* �Ѵ� */
796 "VK_NONCONVERT", /* 0x1D */ /* ̵�Ѵ� */
797 "VK_ACCEPT", /* 0x1E */
798 "VK_MODECHANGE", /* 0x1F */
799
800 "VK_SPACE", /* 0x20 */
801 "VK_PRIOR", /* 0x21 */ /* PageUp */
802 "VK_NEXT", /* 0x22 */ /* PageDown */
803 "VK_END", /* 0x23 */
804 "VK_HOME", /* 0x24 */
805 "VK_LEFT", /* 0x25 */
806 "VK_UP", /* 0x26 */
807 "VK_RIGHT", /* 0x27 */
808
809 "VK_DOWN", /* 0x28 */
810 "VK_SELECT", /* 0x29 */
811 "VK_PRINT", /* 0x2A */
812 "VK_EXECUTE", /* 0x2B */
813 "VK_SNAPSHOT", /* 0x2C */ /* PrintScreen */
814 "VK_INSERT", /* 0x2D */
815 "VK_DELETE", /* 0x2E */
816 "VK_HELP", /* 0x2F */
817
818 "0",
819 "1",
820 "2",
821 "3",
822 "4",
823 "5",
824 "6",
825 "7",
826
827 "8",
828 "9",
829 0,
830 0,
831 0,
832 0,
833 0,
834 0,
835
836 0,
837 "A",
838 "B",
839 "C",
840 "D",
841 "E",
842 "F",
843 "G",
844
845 "H",
846 "I",
847 "J",
848 "K",
849 "L",
850 "M",
851 "N",
852 "O",
853
854 "P",
855 "Q",
856 "R",
857 "S",
858 "T",
859 "U",
860 "V",
861 "W",
862
863 "X",
864 "Y",
865 "Z",
866 "VK_LWIN", /* 0x5B */
867 "VK_RWIN", /* 0x5C */
868 "VK_APPS", /* 0x5D */
869 0,
870 0,
871
872 "VK_NUMPAD0", /* 0x60 */
873 "VK_NUMPAD1", /* 0x61 */
874 "VK_NUMPAD2", /* 0x62 */
875 "VK_NUMPAD3", /* 0x63 */
876 "VK_NUMPAD4", /* 0x64 */
877 "VK_NUMPAD5", /* 0x65 */
878 "VK_NUMPAD6", /* 0x66 */
879 "VK_NUMPAD7", /* 0x67 */
880
881 "VK_NUMPAD8", /* 0x68 */
882 "VK_NUMPAD9", /* 0x69 */
883 "VK_MULTIPLY", /* 0x6A */
884 "VK_ADD", /* 0x6B */
885 "VK_SEPARATOR", /* 0x6C */
886 "VK_SUBTRACT", /* 0x6D */
887 "VK_DECIMAL", /* 0x6E */ /* �ƥ� . */
888 "VK_DIVIDE", /* 0x6F */
889
890 "VK_F1", /* 0x70 */
891 "VK_F2", /* 0x71 */
892 "VK_F3", /* 0x72 */
893 "VK_F4", /* 0x73 */
894 "VK_F5", /* 0x74 */
895 "VK_F6", /* 0x75 */
896 "VK_F7", /* 0x76 */
897 "VK_F8", /* 0x77 */
898
899 "VK_F9", /* 0x78 */
900 "VK_F10", /* 0x79 */
901 "VK_F11", /* 0x7A */
902 "VK_F12", /* 0x7B */
903 "VK_F13", /* 0x7C */
904 "VK_F14", /* 0x7D */
905 "VK_F15", /* 0x7E */
906 "VK_F16", /* 0x7F */
907
908 "VK_F17", /* 0x80 */
909 "VK_F18", /* 0x81 */
910 "VK_F19", /* 0x82 */
911 "VK_F20", /* 0x83 */
912 "VK_F21", /* 0x84 */
913 "VK_F22", /* 0x85 */
914 "VK_F23", /* 0x86 */
915 "VK_F24", /* 0x87 */
916
917 0,
918 0,
919 0,
920 0,
921 0,
922 0,
923 0,
924 0,
925
926 "VK_NUMLOCK", /* 0x90 */
927 "VK_SCROLL", /* 0x91 */ /* ScrollLock */
928 0,
929 0,
930 0,
931 0,
932 0,
933 0,
934
935 0,
936 0,
937 0,
938 0,
939 0,
940 0,
941 0,
942 0,
943
944 "VK_LSHIFT", /* 0xA0 */
945 "VK_RSHIFT", /* 0xA1 */
946 "VK_LCONTROL", /* 0xA2 */
947 "VK_RCONTROL", /* 0xA3 */
948 "VK_LMENU", /* 0xA4 */
949 "VK_RMENU", /* 0xA5 */
950 0,
951 0,
952
953 0,
954 0,
955 0,
956 0,
957 0,
958 0,
959 0,
960 0,
961 /* 0xB0 */
962 0,
963 0,
964 0,
965 0,
966 0,
967 0,
968 0,
969 0,
970
971 0,
972 0,
973 ":",
974 ";",
975 ",",
976 "-",
977 ".",
978 "/",
979 /* 0xC0 */
980 "@",
981 0,
982 0,
983 0,
984 0,
985 0,
986 0,
987 0,
988
989 0,
990 0,
991 0,
992 0,
993 0,
994 0,
995 0,
996 0,
997 /* 0xD0 */
998 0,
999 0,
1000 0,
1001 0,
1002 0,
1003 0,
1004 0,
1005 0,
1006
1007 0,
1008 0,
1009 0,
1010 "[",
1011 "\\",
1012 "]",
1013 "^",
1014 0,
1015
1016 0,
1017 0,
1018 "_",
1019 0,
1020 0,
1021 "VK_PROCESSKEY", /* 0xE5 */ /* Ctrl + F10, ����Ⱦ��? */
1022 0,
1023 0,
1024
1025 0,
1026 0,
1027 0,
1028 0,
1029 0,
1030 0,
1031 0,
1032 0,
1033
1034 0,
1035 0, /* Shift + �Ҥ餬�� */
1036 0, /* Shift + �Ҥ餬�� */
1037 0, /* ����Ⱦ�� */
1038 0, /* ����Ⱦ�� */
1039 0, /* Alt + �Ҥ餬�� */
1040 "VK_ATTN", /* 0xF6 */ /* Alt + �Ҥ餬�� */
1041 "VK_CRSEL", /* 0xF7 */
1042
1043 "VK_EXSEL", /* 0xF8 */
1044 "VK_EREOF", /* 0xF9 */
1045 "VK_PLAY", /* 0xFA */
1046 "VK_ZOOM", /* 0xFB */
1047 "VK_NONAME", /* 0xFC */
1048 "VK_PA1", /* 0xFD */
1049 "VK_OEM_CLEAR", /* 0xFE */
1050 0,
1051
1052 /*
1053 ����������
1054
1055 Ctrl + ESC �������ȥ�˥塼
1056 Alt + ESC �����������å�
1057 Alt + Space ������ɥ���˥塼
1058 �Ҥ餬�� DOWN/UP ȿ���ʤ�?
1059 Pause DOWN/UPϢ³ȯ��
1060 PrintScreen DOWN�ʤ��� UP����
1061
1062 VK_INSERT �Ȥ� VK_UP �Ȥ�
1063 ��ĥ�ե饰�� 0 �ʤ� �ƥ� (NumLock����)
1064 ��ĥ�ե饰�� 1 �ʤ� �ᥤ��
1065
1066
1067 �� IMEͭ���ˤ���Ȥ���˲������ʤ롣��̣���� ��
1068
1069 Ctrl + F10 0xE7 IME��˥塼
1070
1071 ����Ⱦ�� ��������ȡ�KEYDOWN (0xe5) ��ȯ������IME ������
1072 KEYUP��ȯ�����ʤ���
1073 IME ������δ֤ϡ��ɤΥ������Ƥ⡢KEYDOWN (0xe5)
1074 ��ȯ�����롣(KEYUP�ϡ����Υ����Υ�����)��
1075 ���ٲ�������ȡ�KEYUP (0xf4 or 0xf3) ��ȯ������IME ��
1076 ���ա�(0xf3/0xf4 �ΰ㤤������)
1077 Ʊ���ˡ�KEYDOWN (0xe5) ��ȯ��
1078
1079 �Ѵ� ����Ⱦ�Ѥ�Ʊ����
1080 ���դϡ�KEYDOWN (0x1c)
1081
1082 �Ҥ餬�� ����Ⱦ�Ѥ˻��Ƥ뤬���ʤ㤦��
1083 */
1084
1085 };
1086
key_event_debug(UINT msg,WPARAM wp,LPARAM lp)1087 static void key_event_debug(UINT msg, WPARAM wp, LPARAM lp)
1088 {
1089
1090 int on = FALSE;
1091 const char *s;
1092
1093 switch (msg) {
1094 case WM_SYSKEYDOWN: /* Alt / F10 ���� */
1095 s = "Sys*On ";
1096 on = TRUE;
1097 goto KEY_COMMON;
1098
1099 case WM_SYSKEYUP: /* ���� */
1100 s = "Sys*Off";
1101 goto KEY_COMMON;
1102
1103 case WM_KEYDOWN: /* ����¾�������� */
1104 s = "KEY On ";
1105 on = TRUE;
1106 goto KEY_COMMON;
1107
1108 case WM_KEYUP: /* ���� */
1109 s = "KEY Off";
1110 goto KEY_COMMON;
1111
1112 KEY_COMMON:
1113
1114 /* lp bit 0-15 ������ԡ��Ȳ�� (DOWN�Τߡ��ޤȤ�����λ�)
1115 bit 16-23 ���������
1116 bit 24 ��ĥ����
1117 bit 25-26 na
1118 bit 27-28 OS
1119 bit 29 Alt
1120 bit 30 repeat
1121 bit 31 1:DOWN / 0:UP
1122 */
1123
1124 if (on && (lp & 0x40000000UL)) {
1125
1126 ; /* �����ȥ�ԡ����� */
1127
1128 } else {
1129 /*
1130 fprintf(debugfp, "%s %02x [%08X] ", s, wp, lp);
1131 */
1132 fprintf(debugfp, "%s %02x <%x> ", s, wp, (lp&(1UL<<24))?1:0);
1133 s = vk_list[wp];
1134 if (s) {
1135 fprintf(debugfp, "%s\n", s);
1136 } else {
1137 fprintf(debugfp, "0x%02X\n", wp);
1138 }
1139 }
1140 break;
1141
1142
1143 case WM_CHAR:
1144 /* �������롢INS/DEL��F1 �ʤɤ���ʤ� */
1145 /* BackSpace = 0x08 */
1146 /* Tab = 0x09 */
1147 /* Enter = 0x0d */
1148 /* Esc r = 0x1b */
1149 fprintf(debugfp, "Chr %c [%02x]\n", wp, wp);
1150 break;
1151 }
1152 }
1153