2 Skelton for retropc emulator
4 Author : K.Ohta <whatisthis.sowhat _at_ gmail.com>
11 #include <QApplication>
16 #include "../fileio.h"
20 #include "qt_gldraw.h"
24 //#include "mainwidget.h"
25 //#include "csp_logger.h"
26 #include "dropdown_keyset.h"
28 #define KEY_KEEP_FRAMES 3
30 static const int numpad_table[256] = {
31 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x00,
32 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33 // 0x00, 0x69, 0x63, 0x61, 0x67, 0x64, 0x68, 0x66, 0x62, 0x00, 0x00, 0x00, 0x00, 0x60, 0x6e, 0x00,
34 0x00, 0x69, 0x63, 0x61, 0x67, 0x64, 0x68, 0x66, 0x62, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, // remove shift + period
35 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
51 void OSD_BASE::initialize_input()
54 memset(key_status, 0, sizeof(key_status));
55 memset(joy_status, 0, sizeof(joy_status));
56 memset(mouse_status, 0, sizeof(mouse_status));
57 // mouse emulation is disenabled
58 mouse_enabled = false;
59 mouse_ptrx = mouse_oldx = get_screen_width() / 2;
60 mouse_ptry = mouse_oldy = get_screen_height() / 2;
61 // initialize keycode convert table
62 FILEIO* fio = new FILEIO();
63 if(fio->Fopen(bios_path(_T("keycode.cfg")), FILEIO_READ_BINARY)) {
64 fio->Fread(keycode_conv, sizeof(keycode_conv), 1);
67 for(int i = 0; i < 256; i++) {
74 // initialize shift+numpad conversion
75 memset(key_converted, 0, sizeof(key_converted));
76 key_shift_pressed = key_shift_released = false;
80 void OSD_BASE::release_input()
88 void OSD_BASE::do_assign_js_setting(int jsnum, int axis_idx, int assigned_value)
90 if((jsnum < 0) || (jsnum >= 4)) return;
91 if((axis_idx < 0) || (axis_idx >= 16)) return;
92 if((assigned_value < -256) || (assigned_value >= 0x10000)) return;
93 p_config->joy_buttons[jsnum][axis_idx] = assigned_value;
96 void OSD_BASE::update_input()
98 bool press_flag = false;
99 bool release_flag = false;
100 if(get_use_shift_numpad_key()) {
101 //update numpad key status
102 if(key_shift_pressed && !key_shift_released) {
103 if(key_status[VK_SHIFT] == 0) {
104 // shift key is newly pressed
105 key_status[VK_SHIFT] = 0x80;
106 if(!this->get_notify_key_down_lr_shift()) key_status[VK_LSHIFT] = 0x80;
107 if(this->get_notify_key_down()) vm_key_down(VK_SHIFT, false);
109 } else if(!key_shift_pressed && key_shift_released) {
110 if(key_status[VK_SHIFT] != 0) {
111 // shift key is newly released
112 key_status[VK_SHIFT] = 0;
113 if(!this->get_notify_key_down_lr_shift()) key_status[VK_LSHIFT] = 0;
114 if(this->get_notify_key_down()) vm_key_up(VK_SHIFT);
116 if(!(GetAsyncKeyState(VK_LSHIFT) & 0x8000)) key_status[VK_LSHIFT] &= 0x7f;
117 if(!(GetAsyncKeyState(VK_RSHIFT) & 0x8000)) key_status[VK_RSHIFT] &= 0x7f;
119 if(key_status[VK_LSHIFT] != 0) {
120 // shift key is newly released
121 key_status[VK_LSHIFT] = 0;
122 if(this->get_notify_key_down()) vm_key_up(VK_LSHIFT);
124 if(!(GetAsyncKeyState(VK_LSHIFT) & 0x8000)) key_status[VK_LSHIFT] &= 0x7f;
126 if(key_status[VK_RSHIFT] != 0) {
127 // shift key is newly released
128 key_status[VK_RSHIFT] = 0;
129 if(this->get_notify_key_down()) vm_key_up(VK_RSHIFT);
131 if(!(GetAsyncKeyState(VK_RSHIFT) & 0x8000)) key_status[VK_RSHIFT] &= 0x7f;
134 key_shift_pressed = key_shift_released = false;
138 if(lost_focus && !now_auto_key) {
139 // we lost key focus so release all pressed keys
140 for(int i = 0; i < 256; i++) {
141 if(key_status[i] & 0x80) {
142 key_status[i] &= 0x7f;
144 if(this->get_notify_key_down()) {
152 for(int i = 0; i < 256; i++) {
153 if(key_status[i] & 0x7f) {
154 key_status[i] = (key_status[i] & 0x80) | ((key_status[i] & 0x7f) - 1);
156 if(this->get_notify_key_down()) {
166 update_buttons(press_flag, release_flag);
167 // update mouse status
170 memset(mouse_status, 0, sizeof(mouse_status));
171 mouse_status[0] = mouse_ptrx - mouse_oldx;
172 mouse_status[1] = mouse_ptry - mouse_oldy;
173 mouse_status[2] = mouse_button;
174 mouse_oldx = mouse_ptrx;
175 mouse_oldy = mouse_ptry;
179 void OSD_BASE::key_down(int code, bool extended, bool repeat)
181 if((code >= 256) || (code < 0)) return; // WORKAROUND
182 //#ifdef USE_AUTO_KEY
183 if(!__USE_AUTO_KEY || (!now_auto_key && !p_config->romaji_to_kana)) {
185 //if(!dinput_key_available) {
186 if(code == VK_SHIFT) {
187 if(!(key_status[VK_LSHIFT] & 0x80) && (GetAsyncKeyState(VK_LSHIFT) & 0x8000)) {
189 } else if(!(key_status[VK_RSHIFT] & 0x80) && (GetAsyncKeyState(VK_RSHIFT) & 0x8000)) {
194 } else if(code == VK_CONTROL) {
195 if(!(key_status[VK_LCONTROL] & 0x80) && (GetAsyncKeyState(VK_LCONTROL) & 0x8000)) {
197 } else if(!(key_status[VK_RCONTROL] & 0x80) && (GetAsyncKeyState(VK_RCONTROL) & 0x8000)) {
202 } else if(code == VK_MENU) {
203 if(!(key_status[VK_LMENU] & 0x80) && (GetAsyncKeyState(VK_LMENU) & 0x8000)) {
205 } else if(!(key_status[VK_RMENU] & 0x80) && (GetAsyncKeyState(VK_RMENU) & 0x8000)) {
212 //#ifdef USE_SHIFT_NUMPAD_KEY
213 if(__USE_SHIFT_NUMPAD_KEY) {
214 // if(code == VK_LSHIFT || code == VK_RSHIFT) {
215 if(code == VK_LSHIFT) {
216 key_shift_pressed = true;
222 if(key_shift_pressed || key_shift_released || key_status[VK_NUMPAD0]) {
224 key_shift_pressed = true;
228 if(key_shift_pressed || key_shift_released || key_status[VK_NUMPAD1]) {
230 key_shift_pressed = true;
234 if(key_shift_pressed || key_shift_released || key_status[VK_NUMPAD2]) {
236 key_shift_pressed = true;
240 if(key_shift_pressed || key_shift_released || key_status[VK_NUMPAD3]) {
242 key_shift_pressed = true;
246 if(key_shift_pressed || key_shift_released || key_status[VK_NUMPAD4]) {
248 key_shift_pressed = true;
252 if(key_shift_pressed || key_shift_released || key_status[VK_NUMPAD5]) {
254 key_shift_pressed = true;
258 if(key_shift_pressed || key_shift_released || key_status[VK_NUMPAD6]) {
260 key_shift_pressed = true;
264 if(key_shift_pressed || key_shift_released || key_status[VK_NUMPAD7]) {
266 key_shift_pressed = true;
270 if(key_shift_pressed || key_shift_released || key_status[VK_NUMPAD8]) {
272 key_shift_pressed = true;
276 if(key_shift_pressed || key_shift_released || key_status[VK_NUMPAD9]) {
278 key_shift_pressed = true;
286 key_down_native(code, repeat);
288 // if(repeat || code == 0xf0 || code == 0xf1 || code == 0xf2 || code == 0xf3 || code == 0xf4) {
289 // key_down_native(code, repeat);
292 //#ifdef USE_AUTO_KEY
296 if(code == VK_SHIFT) {
297 if(!(key_status[VK_LSHIFT] & 0x80) && (GetAsyncKeyState(VK_LSHIFT) & 0x8000)) {
299 } else if(!(key_status[VK_RSHIFT] & 0x80) && (GetAsyncKeyState(VK_RSHIFT) & 0x8000)) {
304 } else if(code == VK_CONTROL) {
305 if(!(key_status[VK_LCONTROL] & 0x80) && (GetAsyncKeyState(VK_LCONTROL) & 0x8000)) {
307 } else if(!(key_status[VK_RCONTROL] & 0x80) && (GetAsyncKeyState(VK_RCONTROL) & 0x8000)) {
312 } else if(code == VK_MENU) {
313 if(!(key_status[VK_LMENU] & 0x80) && (GetAsyncKeyState(VK_LMENU) & 0x8000)) {
315 } else if(!(key_status[VK_RMENU] & 0x80) && (GetAsyncKeyState(VK_RMENU) & 0x8000)) {
321 if(get_use_shift_numpad_key()) {
322 if(code == VK_LSHIFT) {
323 key_shift_pressed = true;
325 } else if(numpad_table[code] != 0) {
326 if(key_shift_pressed || key_shift_released) {
327 key_converted[code] = 1;
328 key_shift_pressed = true;
329 code = numpad_table[code];
333 key_down_native(code, repeat);
337 void OSD_BASE::key_up(int code, bool extended)
339 if((code >= 256) || (code < 0)) return; // WORKAROUND
340 //#ifdef USE_AUTO_KEY
341 if(!__USE_AUTO_KEY || (!now_auto_key && !p_config->romaji_to_kana)) {
343 //if(!dinput_key_available) {
344 if(code == VK_SHIFT) {
345 if((key_status[VK_LSHIFT] & 0x80) && !(GetAsyncKeyState(VK_LSHIFT) & 0x8000)) {
347 } else if((key_status[VK_RSHIFT] & 0x80) && !(GetAsyncKeyState(VK_RSHIFT) & 0x8000)) {
352 } else if(code == VK_CONTROL) {
353 if((key_status[VK_LCONTROL] & 0x80) && !(GetAsyncKeyState(VK_LCONTROL) & 0x8000)) {
355 } else if((key_status[VK_RCONTROL] & 0x80) && !(GetAsyncKeyState(VK_RCONTROL) & 0x8000)) {
360 } else if(code == VK_MENU) {
361 if((key_status[VK_LMENU] & 0x80) && !(GetAsyncKeyState(VK_LMENU) & 0x8000)) {
363 } else if((key_status[VK_RMENU] & 0x80) && !(GetAsyncKeyState(VK_RMENU) & 0x8000)) {
369 //#ifdef USE_SHIFT_NUMPAD_KEY
370 if(__USE_SHIFT_NUMPAD_KEY) {
372 // if(code == VK_LSHIFT || code == VK_RSHIFT) {
373 if(code == VK_LSHIFT) {
374 key_shift_pressed = false;
375 key_shift_released = true;
380 case VK_NUMPAD0: case VK_INSERT:
381 key_up_native(VK_NUMPAD0);
382 key_up_native(VK_INSERT);
384 case VK_NUMPAD1: case VK_END:
385 key_up_native(VK_NUMPAD1);
386 key_up_native(VK_END);
388 case VK_NUMPAD2: case VK_DOWN:
389 key_up_native(VK_NUMPAD2);
390 key_up_native(VK_DOWN);
392 case VK_NUMPAD3: case VK_NEXT:
393 key_up_native(VK_NUMPAD3);
394 key_up_native(VK_NEXT);
396 case VK_NUMPAD4: case VK_LEFT:
397 key_up_native(VK_NUMPAD4);
398 key_up_native(VK_LEFT);
400 case VK_NUMPAD5: case VK_CLEAR:
401 key_up_native(VK_NUMPAD5);
402 key_up_native(VK_CLEAR);
404 case VK_NUMPAD6: case VK_RIGHT:
405 key_up_native(VK_NUMPAD6);
406 key_up_native(VK_RIGHT);
408 case VK_NUMPAD7: case VK_HOME:
409 key_up_native(VK_NUMPAD7);
410 key_up_native(VK_HOME);
412 case VK_NUMPAD8: case VK_UP:
413 key_up_native(VK_NUMPAD8);
414 key_up_native(VK_UP);
416 case VK_NUMPAD9: case VK_PRIOR:
417 key_up_native(VK_NUMPAD9);
418 key_up_native(VK_PRIOR);
426 //#ifdef USE_AUTO_KEY
430 if(code == VK_SHIFT) {
431 if((key_status[VK_LSHIFT] & 0x80) && !(GetAsyncKeyState(VK_LSHIFT) & 0x8000)) {
433 } else if((key_status[VK_RSHIFT] & 0x80) && !(GetAsyncKeyState(VK_RSHIFT) & 0x8000)) {
438 } else if(code == VK_CONTROL) {
439 if((key_status[VK_LCONTROL] & 0x80) && !(GetAsyncKeyState(VK_LCONTROL) & 0x8000)) {
441 } else if((key_status[VK_RCONTROL] & 0x80) && !(GetAsyncKeyState(VK_RCONTROL) & 0x8000)) {
446 } else if(code == VK_MENU) {
447 if((key_status[VK_LMENU] & 0x80) && !(GetAsyncKeyState(VK_LMENU) & 0x8000)) {
449 } else if((key_status[VK_RMENU] & 0x80) && !(GetAsyncKeyState(VK_RMENU) & 0x8000)) {
455 if(get_use_shift_numpad_key()) {
456 if(code == VK_LSHIFT) {
457 key_shift_pressed = false;
458 key_shift_released = true;
460 } else if(key_converted[code] != 0) {
461 key_converted[code] = 0;
462 code = numpad_table[code];
470 void OSD_BASE::key_down_native(int code, bool repeat)
472 bool keep_frames = false;
477 } else if(code == 0xf2) {
480 } else if(code == 0xf3 || code == 0xf4) {
484 code = keycode_conv[code];
486 if(get_dont_keeep_key_pressed()) {
487 if(!(code == VK_LSHIFT || code == VK_RSHIFT || code == VK_LCONTROL || code == VK_RCONTROL || code == VK_LMENU || code == VK_RMENU)) {
488 key_status[code] = KEY_KEEP_FRAMES;
490 key_status[code] = keep_frames ? KEY_KEEP_FRAMES : 0x80;
493 key_status[code] = keep_frames ? KEY_KEEP_FRAMES : 0x80;
496 uint8_t prev_shift = key_status[VK_SHIFT];
497 uint8_t prev_control = key_status[VK_CONTROL];
498 uint8_t prev_menu = key_status[VK_MENU];
499 key_status[VK_SHIFT] = key_status[VK_LSHIFT] | key_status[VK_RSHIFT];
500 key_status[VK_CONTROL] = key_status[VK_LCONTROL] | key_status[VK_RCONTROL];
501 key_status[VK_MENU] = key_status[VK_LMENU] | key_status[VK_RMENU];
503 if(get_notify_key_down()) {
507 if(!get_notify_key_down_lr_shift()) {
508 if(code == VK_LSHIFT || code == VK_RSHIFT) {
509 if(prev_shift == 0 && key_status[VK_SHIFT] != 0) {
510 vm_key_down(VK_SHIFT, repeat);
515 if(!get_notify_key_down_lr_control()) {
516 if(code == VK_LCONTROL|| code == VK_RCONTROL) {
517 if(prev_control == 0 && key_status[VK_CONTROL] != 0) {
518 vm_key_down(VK_CONTROL, repeat);
523 if(!get_notify_key_down_lr_menu()) {
524 if(code == VK_LMENU|| code == VK_RMENU) {
525 if(prev_menu == 0 && key_status[VK_MENU] != 0) {
526 vm_key_down(VK_MENU, repeat);
531 vm_key_down(code, repeat);
535 void OSD_BASE::key_up_native(int code)
537 if(!(code == VK_LSHIFT || code == VK_RSHIFT || code == VK_LCONTROL || code == VK_RCONTROL || code == VK_LMENU || code == VK_RMENU)) {
538 code = keycode_conv[code];
540 if(key_status[code] == 0) {
543 if((key_status[code] &= 0x7f) != 0) {
547 uint8_t prev_shift = key_status[VK_SHIFT];
548 uint8_t prev_control = key_status[VK_CONTROL];
549 uint8_t prev_menu = key_status[VK_MENU];
550 key_status[VK_SHIFT] = key_status[VK_LSHIFT] | key_status[VK_RSHIFT];
551 key_status[VK_CONTROL] = key_status[VK_LCONTROL] | key_status[VK_RCONTROL];
552 key_status[VK_MENU] = key_status[VK_LMENU] | key_status[VK_RMENU];
555 if(get_notify_key_down()) {
556 if(!get_notify_key_down_lr_shift()) {
557 if(code == VK_LSHIFT || code == VK_RSHIFT) {
558 if(prev_shift != 0 && key_status[VK_SHIFT] == 0) {
564 if(!get_notify_key_down_lr_control()) {
565 if(code == VK_LCONTROL|| code == VK_RCONTROL) {
566 if(prev_control != 0 && key_status[VK_CONTROL] == 0) {
567 vm_key_up(VK_CONTROL);
572 if(!get_notify_key_down_lr_menu()) {
573 if(code == VK_LMENU || code == VK_RMENU) {
574 if(prev_menu != 0 && key_status[VK_MENU] == 0) {
584 void OSD_BASE::key_down_sub(int code, bool repeat)
586 bool keep_frames = false;
591 } else if(code == 0xf2) {
594 } else if(code == 0xf3 || code == 0xf4) {
598 if(!(code == VK_LSHIFT || code == VK_RSHIFT || code == VK_LCONTROL || code == VK_RCONTROL || code == VK_LMENU || code == VK_RMENU)) {
599 code = keycode_conv[code];
603 if(get_dont_keeep_key_pressed()) {
604 if(!(code == VK_LSHIFT || code == VK_RSHIFT || code == VK_LCONTROL || code == VK_RCONTROL || code == VK_LMENU || code == VK_RMENU)) {
605 key_status[code] = KEY_KEEP_FRAMES;
607 key_status[code] = keep_frames ? KEY_KEEP_FRAMES : 0x80;
610 key_status[code] = keep_frames ? KEY_KEEP_FRAMES : 0x80;
613 uint8_t prev_shift = key_status[VK_SHIFT];
614 uint8_t prev_control = key_status[VK_CONTROL];
615 uint8_t prev_menu = key_status[VK_MENU];
617 key_status[VK_SHIFT] = key_status[VK_LSHIFT] | key_status[VK_RSHIFT];
618 key_status[VK_CONTROL] = key_status[VK_LCONTROL] | key_status[VK_RCONTROL];
619 key_status[VK_MENU] = key_status[VK_LMENU] | key_status[VK_RMENU];
621 if(get_notify_key_down()) {
625 if(!get_notify_key_down_lr_shift()) {
626 if(code == VK_LSHIFT || code == VK_RSHIFT) {
627 if(prev_shift == 0 && key_status[VK_SHIFT] != 0) {
628 vm_key_down(VK_SHIFT, repeat);
633 if(!get_notify_key_down_lr_control()) {
634 if(code == VK_LCONTROL|| code == VK_RCONTROL) {
635 if(prev_control == 0 && key_status[VK_CONTROL] != 0) {
636 vm_key_down(VK_CONTROL, repeat);
641 if(!get_notify_key_down_lr_menu()) {
642 if(code == VK_LMENU|| code == VK_RMENU) {
643 if(prev_menu == 0 && key_status[VK_MENU] != 0) {
644 vm_key_down(VK_MENU, repeat);
649 vm_key_down(code, repeat);
653 void OSD_BASE::key_up_sub(int code)
655 if(!(code == VK_LSHIFT || code == VK_RSHIFT || code == VK_LCONTROL || code == VK_RCONTROL || code == VK_LMENU || code == VK_RMENU)) {
656 code = keycode_conv[code];
658 if(key_status[code] == 0) {
661 if((key_status[code] &= 0x7f) != 0) {
665 uint8_t prev_shift = key_status[VK_SHIFT];
666 uint8_t prev_control = key_status[VK_CONTROL];
667 uint8_t prev_menu = key_status[VK_MENU];
668 key_status[VK_SHIFT] = key_status[VK_LSHIFT] | key_status[VK_RSHIFT];
669 key_status[VK_CONTROL] = key_status[VK_LCONTROL] | key_status[VK_RCONTROL];
670 key_status[VK_MENU] = key_status[VK_LMENU] | key_status[VK_RMENU];
671 if(get_notify_key_down()) {
672 if(!get_notify_key_down_lr_shift()) {
673 if(code == VK_LSHIFT || code == VK_RSHIFT) {
674 if(prev_shift != 0 && key_status[VK_SHIFT] == 0) {
680 if(!get_notify_key_down_lr_control()) {
681 if(code == VK_LCONTROL|| code == VK_RCONTROL) {
682 if(prev_control != 0 && key_status[VK_CONTROL] == 0) {
683 vm_key_up(VK_CONTROL);
688 if(!get_notify_key_down_lr_menu()) {
689 if(code == VK_LMENU || code == VK_RMENU) {
690 if(prev_menu != 0 && key_status[VK_MENU] == 0) {
701 void OSD_BASE::key_modifiers(uint32_t mod)
707 void OSD_BASE::modify_key_buffer(int code, uint8_t val)
709 key_status[code] = val;
712 void OSD_BASE::key_lost_focus()
717 uint8_t* OSD_BASE::get_key_buffer()
722 uint32_t* OSD_BASE::get_joy_buffer()
727 int* OSD_BASE::get_mouse_buffer()
732 void OSD_BASE::press_button(int num)
734 if(get_one_board_micro_computer()) {
735 int code = get_vm_buttons_code(num);
738 key_down_sub(code, false);
739 key_status[code] = KEY_KEEP_FRAMES;
741 // code=0: reset virtual machine
748 void OSD_BASE::enable_mouse()
750 // enable mouse emulation
752 mouse_oldx = mouse_ptrx = get_screen_width() / 2;
753 mouse_oldy = mouse_ptry = get_screen_height() / 2;
756 mouse_status[2] = mouse_button;
757 emit sig_enable_mouse();
759 mouse_enabled = true;
762 void OSD_BASE::disable_mouse()
764 // disenable mouse emulation
766 emit sig_disable_mouse();
768 mouse_enabled = false;
771 void OSD_BASE::toggle_mouse()
773 // toggle mouse enable / disenable
781 bool OSD_BASE::is_mouse_enabled()
783 return mouse_enabled;
786 void OSD_BASE::set_mouse_pointer(int x, int y)
792 void OSD_BASE::set_mouse_button(int button)
794 mouse_button = button;
797 int OSD_BASE::get_mouse_button()
802 #if !defined(Q_OS_WIN) && !defined(Q_OS_CYGWIN)
803 uint16_t OSD_BASE::GetAsyncKeyState(uint32_t vk)
805 vk = vk & 0xff; // OK?
806 quint32 modstate = modkey_status;
807 //printf("Mod %d %08x\n", vk, mod);
810 if((modstate & Qt::ShiftModifier) != 0) return 0xffff;
813 if((modstate & Qt::ShiftModifier) != 0) return 0xffff;
816 if((modstate & Qt::ShiftModifier) != 0) return 0xffff;
819 if((modstate & Qt::ControlModifier) != 0) return 0xffff;
822 if((modstate & Qt::ControlModifier) != 0) return 0xffff;
825 if((modstate & Qt::ControlModifier) != 0) return 0xffff;
828 if((modstate & Qt::AltModifier) != 0) return 0xffff;
831 if((modstate & Qt::AltModifier) != 0) return 0xffff;