- Timestamp:
- Feb 18, 2007 9:04:39 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp
r953 r962 2575 2575 return (gfAbsoluteMouseHost && gfAbsoluteMouseGuest); 2576 2576 } 2577 2578 #if defined(__DARWIN__) 2579 /** 2580 * Fallback keycode conversion using SDL symbols. 2581 * 2582 * This is used to catch keycodes that's missing from the translation table. 2583 * 2584 * @returns XT scancode 2585 * @param ev SDL scancode 2586 */ 2587 static uint8_t Keyevent2KeycodeFallback(const SDL_KeyboardEvent *ev) 2588 { 2589 const SDLKey sym = ev->keysym.sym; 2590 Log(("SDL key event: sym=%d scancode=%#x unicode=%#x\n", 2591 sym, ev->keysym.scancode, ev->keysym.unicode)); 2592 switch (sym) 2593 { /* set 1 scan code */ 2594 case SDLK_ESCAPE: return 0x01; 2595 case SDLK_EXCLAIM: 2596 case SDLK_1: return 0x02; 2597 case SDLK_AT: 2598 case SDLK_2: return 0x03; 2599 case SDLK_HASH: 2600 case SDLK_3: return 0x04; 2601 case SDLK_DOLLAR: 2602 case SDLK_4: return 0x05; 2603 /* % */ 2604 case SDLK_5: return 0x06; 2605 case SDLK_CARET: 2606 case SDLK_6: return 0x07; 2607 case SDLK_AMPERSAND: 2608 case SDLK_7: return 0x08; 2609 case SDLK_ASTERISK: 2610 case SDLK_8: return 0x09; 2611 case SDLK_LEFTPAREN: 2612 case SDLK_9: return 0x0a; 2613 case SDLK_RIGHTPAREN: 2614 case SDLK_0: return 0x0b; 2615 case SDLK_UNDERSCORE: 2616 case SDLK_MINUS: return 0x0c; 2617 case SDLK_EQUALS: 2618 case SDLK_PLUS: return 0x0d; 2619 case SDLK_BACKSPACE: return 0x0e; 2620 case SDLK_TAB: return 0x0f; 2621 case SDLK_q: return 0x10; 2622 case SDLK_w: return 0x11; 2623 case SDLK_e: return 0x12; 2624 case SDLK_r: return 0x13; 2625 case SDLK_t: return 0x14; 2626 case SDLK_y: return 0x15; 2627 case SDLK_u: return 0x16; 2628 case SDLK_i: return 0x17; 2629 case SDLK_o: return 0x18; 2630 case SDLK_p: return 0x19; 2631 case SDLK_LEFTBRACKET: return 0x1a; 2632 case SDLK_RIGHTBRACKET: return 0x1b; 2633 case SDLK_RETURN: return 0x1c; 2634 case SDLK_KP_ENTER: return 0x1c | 0x80; 2635 case SDLK_LCTRL: return 0x1d; 2636 case SDLK_RCTRL: return 0x1d | 0x80; 2637 case SDLK_a: return 0x1e; 2638 case SDLK_s: return 0x1f; 2639 case SDLK_d: return 0x20; 2640 case SDLK_f: return 0x21; 2641 case SDLK_g: return 0x22; 2642 case SDLK_h: return 0x23; 2643 case SDLK_j: return 0x24; 2644 case SDLK_k: return 0x25; 2645 case SDLK_l: return 0x26; 2646 case SDLK_COLON: 2647 case SDLK_SEMICOLON: return 0x27; 2648 case SDLK_QUOTEDBL: 2649 case SDLK_QUOTE: return 0x28; 2650 case SDLK_BACKQUOTE: return 0x29; 2651 case SDLK_LSHIFT: return 0x2a; 2652 case SDLK_BACKSLASH: return 0x2b; 2653 case SDLK_z: return 0x2c; 2654 case SDLK_x: return 0x2d; 2655 case SDLK_c: return 0x2e; 2656 case SDLK_v: return 0x2f; 2657 case SDLK_b: return 0x30; 2658 case SDLK_n: return 0x31; 2659 case SDLK_m: return 0x32; 2660 case SDLK_LESS: 2661 case SDLK_COMMA: return 0x33; 2662 case SDLK_GREATER: 2663 case SDLK_PERIOD: return 0x34; 2664 case SDLK_KP_DIVIDE: /*??*/ 2665 case SDLK_QUESTION: 2666 case SDLK_SLASH: return 0x35; 2667 case SDLK_RSHIFT: return 0x36; 2668 case SDLK_KP_MULTIPLY: 2669 case SDLK_PRINT: return 0x37; /* fixme */ 2670 case SDLK_LALT: return 0x38; 2671 case SDLK_MODE: /* alt gr*/ 2672 case SDLK_RALT: return 0x38 | 0x80; 2673 case SDLK_SPACE: return 0x39; 2674 case SDLK_CAPSLOCK: return 0x3a; 2675 case SDLK_F1: return 0x3b; 2676 case SDLK_F2: return 0x3c; 2677 case SDLK_F3: return 0x3d; 2678 case SDLK_F4: return 0x3e; 2679 case SDLK_F5: return 0x3f; 2680 case SDLK_F6: return 0x40; 2681 case SDLK_F7: return 0x41; 2682 case SDLK_F8: return 0x42; 2683 case SDLK_F9: return 0x43; 2684 case SDLK_F10: return 0x44; 2685 case SDLK_PAUSE: return 0x45; /* not right */ 2686 case SDLK_NUMLOCK: return 0x45; 2687 case SDLK_SCROLLOCK: return 0x46; 2688 case SDLK_KP7: return 0x47; 2689 case SDLK_HOME: return 0x47 | 0x80; 2690 case SDLK_KP8: return 0x48; 2691 case SDLK_UP: return 0x48 | 0x80; 2692 case SDLK_KP9: return 0x49; 2693 case SDLK_PAGEUP: return 0x49 | 0x80; 2694 case SDLK_KP_MINUS: return 0x4a; 2695 case SDLK_KP4: return 0x4b; 2696 case SDLK_LEFT: return 0x4b | 0x80; 2697 case SDLK_KP5: return 0x4c; 2698 case SDLK_KP6: return 0x4d; 2699 case SDLK_RIGHT: return 0x4d | 0x80; 2700 case SDLK_KP_PLUS: return 0x4e; 2701 case SDLK_KP1: return 0x4f; 2702 case SDLK_END: return 0x4f | 0x80; 2703 case SDLK_KP2: return 0x50; 2704 case SDLK_DOWN: return 0x50 | 0x80; 2705 case SDLK_KP3: return 0x51; 2706 case SDLK_PAGEDOWN: return 0x51 | 0x80; 2707 case SDLK_KP0: return 0x52; 2708 case SDLK_INSERT: return 0x52 | 0x80; 2709 case SDLK_KP_PERIOD: return 0x53; 2710 case SDLK_DELETE: return 0x53 | 0x80; 2711 case SDLK_SYSREQ: return 0x54; 2712 case SDLK_F11: return 0x57; 2713 case SDLK_F12: return 0x58; 2714 case SDLK_F13: return 0x5b; 2715 case SDLK_LMETA: 2716 case SDLK_LSUPER: return 0x5b | 0x80; 2717 case SDLK_F14: return 0x5c; 2718 case SDLK_RMETA: 2719 case SDLK_RSUPER: return 0x5c | 0x80; 2720 case SDLK_F15: return 0x5d; 2721 case SDLK_MENU: return 0x5d | 0x80; 2722 #if 0 2723 case SDLK_CLEAR: return 0x; 2724 case SDLK_KP_EQUALS: return 0x; 2725 case SDLK_COMPOSE: return 0x; 2726 case SDLK_HELP: return 0x; 2727 case SDLK_BREAK: return 0x; 2728 case SDLK_POWER: return 0x; 2729 case SDLK_EURO: return 0x; 2730 case SDLK_UNDO: return 0x; 2731 #endif 2732 default: 2733 Log(("Unhandled sdl key event: sym=%d scancode=%#x unicode=%#x\n", 2734 ev->keysym.sym, ev->keysym.scancode, ev->keysym.unicode)); 2735 return 0; 2736 } 2737 } 2738 #endif 2577 2739 2578 2740 /** … … 2675 2837 keycode = 0; 2676 2838 } 2839 2840 #elif defined(__DARWIN__) 2841 /* This is derived partially from SDL_QuartzKeys.h and partially from testing. */ 2842 static const uint8_t s_aMacToSet1[] = 2843 { 2844 /* set-1 SDL_QuartzKeys.h */ 2845 0x1e, /* QZ_a 0x00 */ 2846 0x1f, /* QZ_s 0x01 */ 2847 0x20, /* QZ_d 0x02 */ 2848 0x21, /* QZ_f 0x03 */ 2849 0x23, /* QZ_h 0x04 */ 2850 0x22, /* QZ_g 0x05 */ 2851 0x2c, /* QZ_z 0x06 */ 2852 0x2d, /* QZ_x 0x07 */ 2853 0x2e, /* QZ_c 0x08 */ 2854 0x2f, /* QZ_v 0x09 */ 2855 0x56, /* between lshift and z. 'INT 1'? */ 2856 0x30, /* QZ_b 0x0B */ 2857 0x10, /* QZ_q 0x0C */ 2858 0x11, /* QZ_w 0x0D */ 2859 0x12, /* QZ_e 0x0E */ 2860 0x13, /* QZ_r 0x0F */ 2861 0x15, /* QZ_y 0x10 */ 2862 0x14, /* QZ_t 0x11 */ 2863 0x02, /* QZ_1 0x12 */ 2864 0x03, /* QZ_2 0x13 */ 2865 0x04, /* QZ_3 0x14 */ 2866 0x05, /* QZ_4 0x15 */ 2867 0x07, /* QZ_6 0x16 */ 2868 0x06, /* QZ_5 0x17 */ 2869 0x0d, /* QZ_EQUALS 0x18 */ 2870 0x0a, /* QZ_9 0x19 */ 2871 0x08, /* QZ_7 0x1A */ 2872 0x0c, /* QZ_MINUS 0x1B */ 2873 0x09, /* QZ_8 0x1C */ 2874 0x0b, /* QZ_0 0x1D */ 2875 0x1b, /* QZ_RIGHTBRACKET 0x1E */ 2876 0x18, /* QZ_o 0x1F */ 2877 0x16, /* QZ_u 0x20 */ 2878 0x1a, /* QZ_LEFTBRACKET 0x21 */ 2879 0x17, /* QZ_i 0x22 */ 2880 0x19, /* QZ_p 0x23 */ 2881 0x1c, /* QZ_RETURN 0x24 */ 2882 0x26, /* QZ_l 0x25 */ 2883 0x24, /* QZ_j 0x26 */ 2884 0x28, /* QZ_QUOTE 0x27 */ 2885 0x25, /* QZ_k 0x28 */ 2886 0x27, /* QZ_SEMICOLON 0x29 */ 2887 0x2b, /* QZ_BACKSLASH 0x2A */ 2888 0x33, /* QZ_COMMA 0x2B */ 2889 0x35, /* QZ_SLASH 0x2C */ 2890 0x31, /* QZ_n 0x2D */ 2891 0x32, /* QZ_m 0x2E */ 2892 0x34, /* QZ_PERIOD 0x2F */ 2893 0x0f, /* QZ_TAB 0x30 */ 2894 0x39, /* QZ_SPACE 0x31 */ 2895 0x29, /* QZ_BACKQUOTE 0x32 */ 2896 0x0e, /* QZ_BACKSPACE 0x33 */ 2897 0x9c, /* QZ_IBOOK_ENTER 0x34 */ 2898 0x01, /* QZ_ESCAPE 0x35 */ 2899 0x5c|0x80, /* QZ_RMETA 0x36 */ 2900 0x5b|0x80, /* QZ_LMETA 0x37 */ 2901 0x2a, /* QZ_LSHIFT 0x38 */ 2902 0x3a, /* QZ_CAPSLOCK 0x39 */ 2903 0x38, /* QZ_LALT 0x3A */ 2904 0x1d, /* QZ_LCTRL 0x3B */ 2905 0x36, /* QZ_RSHIFT 0x3C */ 2906 0x38|0x80, /* QZ_RALT 0x3D */ 2907 0x1d|0x80, /* QZ_RCTRL 0x3E */ 2908 0, /* */ 2909 0, /* */ 2910 0x53, /* QZ_KP_PERIOD 0x41 */ 2911 0, /* */ 2912 0x37, /* QZ_KP_MULTIPLY 0x43 */ 2913 0, /* */ 2914 0x4e, /* QZ_KP_PLUS 0x45 */ 2915 0, /* */ 2916 0x45, /* QZ_NUMLOCK 0x47 */ 2917 0, /* */ 2918 0, /* */ 2919 0, /* */ 2920 0x35|0x80, /* QZ_KP_DIVIDE 0x4B */ 2921 0x1c|0x80, /* QZ_KP_ENTER 0x4C */ 2922 0, /* */ 2923 0x4a, /* QZ_KP_MINUS 0x4E */ 2924 0, /* */ 2925 0, /* */ 2926 0x0d/*?*/, /* QZ_KP_EQUALS 0x51 */ 2927 0x52, /* QZ_KP0 0x52 */ 2928 0x4f, /* QZ_KP1 0x53 */ 2929 0x50, /* QZ_KP2 0x54 */ 2930 0x51, /* QZ_KP3 0x55 */ 2931 0x4b, /* QZ_KP4 0x56 */ 2932 0x4c, /* QZ_KP5 0x57 */ 2933 0x4d, /* QZ_KP6 0x58 */ 2934 0x47, /* QZ_KP7 0x59 */ 2935 0, /* */ 2936 0x48, /* QZ_KP8 0x5B */ 2937 0x49, /* QZ_KP9 0x5C */ 2938 0, /* */ 2939 0, /* */ 2940 0, /* */ 2941 0x3f, /* QZ_F5 0x60 */ 2942 0x40, /* QZ_F6 0x61 */ 2943 0x41, /* QZ_F7 0x62 */ 2944 0x3d, /* QZ_F3 0x63 */ 2945 0x42, /* QZ_F8 0x64 */ 2946 0x43, /* QZ_F9 0x65 */ 2947 0, /* */ 2948 0x57, /* QZ_F11 0x67 */ 2949 0, /* */ 2950 0x37|0x80, /* QZ_PRINT / F13 0x69 */ 2951 0x63, /* QZ_F16 0x6A */ 2952 0x46, /* QZ_SCROLLOCK 0x6B */ 2953 0, /* */ 2954 0x44, /* QZ_F10 0x6D */ 2955 0x5d|0x80, /* */ 2956 0x58, /* QZ_F12 0x6F */ 2957 0, /* */ 2958 0/* 0xe1,0x1d,0x45*/, /* QZ_PAUSE 0x71 */ 2959 0x52|0x80, /* QZ_INSERT / HELP 0x72 */ 2960 0x47|0x80, /* QZ_HOME 0x73 */ 2961 0x49|0x80, /* QZ_PAGEUP 0x74 */ 2962 0x53|0x80, /* QZ_DELETE 0x75 */ 2963 0x3e, /* QZ_F4 0x76 */ 2964 0x4f|0x80, /* QZ_END 0x77 */ 2965 0x3c, /* QZ_F2 0x78 */ 2966 0x51|0x80, /* QZ_PAGEDOWN 0x79 */ 2967 0x3b, /* QZ_F1 0x7A */ 2968 0x4b|0x80, /* QZ_LEFT 0x7B */ 2969 0x4d|0x80, /* QZ_RIGHT 0x7C */ 2970 0x50|0x80, /* QZ_DOWN 0x7D */ 2971 0x48|0x80, /* QZ_UP 0x7E */ 2972 0x5e|0x80, /* QZ_POWER 0x7F */ /* have different break key! */ 2973 }; 2974 2975 if (keycode == 0) 2976 { 2977 /* This could be a modifier or it could be 'a'. */ 2978 switch (ev->keysym.sym) 2979 { 2980 case SDLK_LSHIFT: keycode = 0x2a; break; 2981 case SDLK_RSHIFT: keycode = 0x36; break; 2982 case SDLK_LCTRL: keycode = 0x1d; break; 2983 case SDLK_RCTRL: keycode = 0x1d | 0x80; break; 2984 case SDLK_LALT: keycode = 0x38; break; 2985 case SDLK_MODE: /* alt gr */ 2986 case SDLK_RALT: keycode = 0x38 | 0x80; break; 2987 case SDLK_RMETA: 2988 case SDLK_RSUPER: keycode = 0x5c | 0x80; break; 2989 case SDLK_LMETA: 2990 case SDLK_LSUPER: keycode = 0x5b | 0x80; break; 2991 /* Sssumes normal key. */ 2992 default: keycode = s_aMacToSet1[keycode]; break; 2993 } 2994 } 2995 else 2996 { 2997 if ((unsigned)keycode < RT_ELEMENTS(s_aMacToSet1)) 2998 keycode = s_aMacToSet1[keycode]; 2999 else 3000 keycode = 0; 3001 if (!keycode) 3002 { 3003 #ifdef DEBUG_bird 3004 RTPrintf("Untranslated: keycode=%#x (%d)\n", keycode, keycode); 3005 #endif 3006 keycode = Keyevent2KeycodeFallback(ev); 3007 } 3008 } 3009 #ifdef DEBUG_bird 3010 RTPrintf("scancode=%#x -> %#x\n", ev->keysym.scancode, keycode); 3011 #endif 3012 2677 3013 #endif 2678 3014 return keycode;
Note:
See TracChangeset
for help on using the changeset viewer.