src/events/scancodes_darwin.h
changeset 2305 fbe8ff44c519
child 2308 514f7c1651fc
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/events/scancodes_darwin.h	Thu Feb 07 15:31:09 2008 +0000
     1.3 @@ -0,0 +1,160 @@
     1.4 +/*
     1.5 +    SDL - Simple DirectMedia Layer
     1.6 +    Copyright (C) 1997-2006 Sam Lantinga
     1.7 +
     1.8 +    This library is free software; you can redistribute it and/or
     1.9 +    modify it under the terms of the GNU Lesser General Public
    1.10 +    License as published by the Free Software Foundation; either
    1.11 +    version 2.1 of the License, or (at your option) any later version.
    1.12 +
    1.13 +    This library is distributed in the hope that it will be useful,
    1.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    1.16 +    Lesser General Public License for more details.
    1.17 +
    1.18 +    You should have received a copy of the GNU Lesser General Public
    1.19 +    License along with this library; if not, write to the Free Software
    1.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    1.21 +
    1.22 +    Sam Lantinga
    1.23 +    slouken@libsdl.org
    1.24 +*/
    1.25 +
    1.26 +/* Mac virtual key code to SDLKey mapping table
    1.27 +   Sources:
    1.28 +   - Inside Macintosh: Text <http://developer.apple.com/documentation/mac/Text/Text-571.html>
    1.29 +   - Apple USB keyboard driver source <http://darwinsource.opendarwin.org/10.4.6.ppc/IOHIDFamily-172.8/IOHIDFamily/Cosmo_USB2ADB.c>
    1.30 +   - experimentation on various ADB and USB ISO keyboards and one ADB ANSI keyboard
    1.31 +*/
    1.32 +/* *INDENT-OFF* */
    1.33 +static SDL_scancode darwin_scancode_table[] = {
    1.34 +    /*   0 */   SDL_SCANCODE_A,
    1.35 +    /*   1 */   SDL_SCANCODE_S,
    1.36 +    /*   2 */   SDL_SCANCODE_D,
    1.37 +    /*   3 */   SDL_SCANCODE_F,
    1.38 +    /*   4 */   SDL_SCANCODE_H,
    1.39 +    /*   5 */   SDL_SCANCODE_G,
    1.40 +    /*   6 */   SDL_SCANCODE_Z,
    1.41 +    /*   7 */   SDL_SCANCODE_X,
    1.42 +    /*   8 */   SDL_SCANCODE_C,
    1.43 +    /*   9 */   SDL_SCANCODE_V,
    1.44 +    /*  10 */   SDL_SCANCODE_NONUSBACKSLASH, /* SDL_SCANCODE_NONUSBACKSLASH on ANSI and JIS keyboards (if this key would exist there), SDL_SCANCODE_GRAVE on ISO. (The USB keyboard driver actually translates these usage codes to different virtual key codes depending on whether the keyboard is ISO/ANSI/JIS. That's why you have to help it identify the keyboard type when you plug in a PC USB keyboard. It's a historical thing - ADB keyboards are wired this way.) */
    1.45 +    /*  11 */   SDL_SCANCODE_B,
    1.46 +    /*  12 */   SDL_SCANCODE_Q,
    1.47 +    /*  13 */   SDL_SCANCODE_W,
    1.48 +    /*  14 */   SDL_SCANCODE_E,
    1.49 +    /*  15 */   SDL_SCANCODE_R,
    1.50 +    /*  16 */   SDL_SCANCODE_Y,
    1.51 +    /*  17 */   SDL_SCANCODE_T,
    1.52 +    /*  18 */   SDL_SCANCODE_1,
    1.53 +    /*  19 */   SDL_SCANCODE_2,
    1.54 +    /*  20 */   SDL_SCANCODE_3,
    1.55 +    /*  21 */   SDL_SCANCODE_4,
    1.56 +    /*  22 */   SDL_SCANCODE_6,
    1.57 +    /*  23 */   SDL_SCANCODE_5,
    1.58 +    /*  24 */   SDL_SCANCODE_EQUALS,
    1.59 +    /*  25 */   SDL_SCANCODE_9,
    1.60 +    /*  26 */   SDL_SCANCODE_7,
    1.61 +    /*  27 */   SDL_SCANCODE_MINUS,
    1.62 +    /*  28 */   SDL_SCANCODE_8,
    1.63 +    /*  29 */   SDL_SCANCODE_0,
    1.64 +    /*  30 */   SDL_SCANCODE_RIGHTBRACKET,
    1.65 +    /*  31 */   SDL_SCANCODE_O,
    1.66 +    /*  32 */   SDL_SCANCODE_U,
    1.67 +    /*  33 */   SDL_SCANCODE_LEFTBRACKET,
    1.68 +    /*  34 */   SDL_SCANCODE_I,
    1.69 +    /*  35 */   SDL_SCANCODE_P,
    1.70 +    /*  36 */   SDL_SCANCODE_RETURN,
    1.71 +    /*  37 */   SDL_SCANCODE_L,
    1.72 +    /*  38 */   SDL_SCANCODE_J,
    1.73 +    /*  39 */   SDL_SCANCODE_APOSTROPHE,
    1.74 +    /*  40 */   SDL_SCANCODE_K,
    1.75 +    /*  41 */   SDL_SCANCODE_SEMICOLON,
    1.76 +    /*  42 */   SDL_SCANCODE_BACKSLASH,
    1.77 +    /*  43 */   SDL_SCANCODE_COMMA,
    1.78 +    /*  44 */   SDL_SCANCODE_SLASH,
    1.79 +    /*  45 */   SDL_SCANCODE_N,
    1.80 +    /*  46 */   SDL_SCANCODE_M,
    1.81 +    /*  47 */   SDL_SCANCODE_PERIOD,
    1.82 +    /*  48 */   SDL_SCANCODE_TAB,
    1.83 +    /*  49 */   SDL_SCANCODE_SPACE,
    1.84 +    /*  50 */   SDL_SCANCODE_GRAVE, /* SDL_SCANCODE_GRAVE on ANSI and JIS keyboards, SDL_SCANCODE_NONUSBACKSLASH on ISO (see comment about virtual key code 10 above) */
    1.85 +    /*  51 */   SDL_SCANCODE_BACKSPACE,
    1.86 +    /*  52 */   SDL_SCANCODE_KP_ENTER, /* keyboard enter on portables */
    1.87 +    /*  53 */   SDL_SCANCODE_ESCAPE,
    1.88 +    /*  54 */   SDL_SCANCODE_RGUI,
    1.89 +    /*  55 */   SDL_SCANCODE_LGUI,
    1.90 +    /*  56 */   SDL_SCANCODE_LSHIFT,
    1.91 +    /*  57 */   SDL_SCANCODE_CAPSLOCK,
    1.92 +    /*  58 */   SDL_SCANCODE_LALT,
    1.93 +    /*  59 */   SDL_SCANCODE_LCTRL,
    1.94 +    /*  60 */   SDL_SCANCODE_RSHIFT,
    1.95 +    /*  61 */   SDL_SCANCODE_RALT,
    1.96 +    /*  62 */   SDL_SCANCODE_RCTRL,
    1.97 +    /*  63 */   SDL_SCANCODE_RGUI, /* fn on portables, acts as a hardware-level modifier already, so we don't generate events for it, also XK_Meta_R */
    1.98 +    /*  64 */   SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
    1.99 +    /*  65 */   SDL_SCANCODE_KP_PERIOD,
   1.100 +    /*  66 */   SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
   1.101 +    /*  67 */   SDL_SCANCODE_KP_MULTIPLY,
   1.102 +    /*  68 */   SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
   1.103 +    /*  69 */   SDL_SCANCODE_KP_PLUS,
   1.104 +    /*  70 */   SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
   1.105 +    /*  71 */   SDL_SCANCODE_NUMLOCKCLEAR,
   1.106 +    /*  72 */   SDL_SCANCODE_VOLUMEUP,
   1.107 +    /*  73 */   SDL_SCANCODE_VOLUMEDOWN,
   1.108 +    /*  74 */   SDL_SCANCODE_MUTE,
   1.109 +    /*  75 */   SDL_SCANCODE_KP_DIVIDE,
   1.110 +    /*  76 */   SDL_SCANCODE_KP_ENTER, /* keypad enter on external keyboards, fn-return on portables */
   1.111 +    /*  77 */   SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
   1.112 +    /*  78 */   SDL_SCANCODE_KP_MINUS,
   1.113 +    /*  79 */   SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
   1.114 +    /*  80 */   SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
   1.115 +    /*  81 */   SDL_SCANCODE_KP_EQUALS,
   1.116 +    /*  82 */   SDL_SCANCODE_KP_0,
   1.117 +    /*  83 */   SDL_SCANCODE_KP_1,
   1.118 +    /*  84 */   SDL_SCANCODE_KP_2,
   1.119 +    /*  85 */   SDL_SCANCODE_KP_3,
   1.120 +    /*  86 */   SDL_SCANCODE_KP_4,
   1.121 +    /*  87 */   SDL_SCANCODE_KP_5,
   1.122 +    /*  88 */   SDL_SCANCODE_KP_6,
   1.123 +    /*  89 */   SDL_SCANCODE_KP_7,
   1.124 +    /*  90 */   SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
   1.125 +    /*  91 */   SDL_SCANCODE_KP_8,
   1.126 +    /*  92 */   SDL_SCANCODE_KP_9,
   1.127 +    /*  93 */   SDL_SCANCODE_INTERNATIONAL3, /* Cosmo_USB2ADB.c says "Yen (JIS)" */
   1.128 +    /*  94 */   SDL_SCANCODE_INTERNATIONAL1, /* Cosmo_USB2ADB.c says "Ro (JIS)" */
   1.129 +    /*  95 */   SDL_SCANCODE_KP_COMMA, /* Cosmo_USB2ADB.c says ", JIS only" */
   1.130 +    /*  96 */   SDL_SCANCODE_F5,
   1.131 +    /*  97 */   SDL_SCANCODE_F6,
   1.132 +    /*  98 */   SDL_SCANCODE_F7,
   1.133 +    /*  99 */   SDL_SCANCODE_F3,
   1.134 +    /* 100 */   SDL_SCANCODE_F8,
   1.135 +    /* 101 */   SDL_SCANCODE_F9,
   1.136 +    /* 102 */   SDL_SCANCODE_LANG2, /* Cosmo_USB2ADB.c says "Eisu" */
   1.137 +    /* 103 */   SDL_SCANCODE_F11,
   1.138 +    /* 104 */   SDL_SCANCODE_LANG1, /* Cosmo_USB2ADB.c says "Kana" */
   1.139 +    /* 105 */   SDL_SCANCODE_PRINTSCREEN, /* On ADB keyboards, this key is labeled "F13/print screen". Problem: USB has different usage codes for these two functions. On Apple USB keyboards, the key is labeled "F13" and sends the F13 usage code (SDL_SCANCODE_F13). I decided to use SDL_SCANCODE_PRINTSCREEN here nevertheless since SDL applications are more likely to assume the presence of a print screen key than an F13 key. */
   1.140 +    /* 106 */   SDL_SCANCODE_F16,
   1.141 +    /* 107 */   SDL_SCANCODE_SCROLLLOCK, /* F14/scroll lock, see comment about F13/print screen above */
   1.142 +    /* 108 */   SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
   1.143 +    /* 109 */   SDL_SCANCODE_F10,
   1.144 +    /* 110 */   SDL_SCANCODE_APPLICATION, /* windows contextual menu key, fn-enter on portables */
   1.145 +    /* 111 */   SDL_SCANCODE_F12,
   1.146 +    /* 112 */   SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
   1.147 +    /* 113 */   SDL_SCANCODE_PAUSE, /* F15/pause, see comment about F13/print screen above */
   1.148 +    /* 114 */   SDL_SCANCODE_INSERT, /* the key is actually labeled "help" on Apple keyboards, and works as such in Mac OS, but it sends the "insert" usage code even on Apple USB keyboards */
   1.149 +    /* 115 */   SDL_SCANCODE_HOME,
   1.150 +    /* 116 */   SDL_SCANCODE_PAGEUP,
   1.151 +    /* 117 */   SDL_SCANCODE_DELETE,
   1.152 +    /* 118 */   SDL_SCANCODE_F4,
   1.153 +    /* 119 */   SDL_SCANCODE_END,
   1.154 +    /* 120 */   SDL_SCANCODE_F2,
   1.155 +    /* 121 */   SDL_SCANCODE_PAGEDOWN,
   1.156 +    /* 122 */   SDL_SCANCODE_F1,
   1.157 +    /* 123 */   SDL_SCANCODE_LEFT,
   1.158 +    /* 124 */   SDL_SCANCODE_RIGHT,
   1.159 +    /* 125 */   SDL_SCANCODE_DOWN,
   1.160 +    /* 126 */   SDL_SCANCODE_UP,
   1.161 +    /* 127 */   SDL_SCANCODE_POWER
   1.162 +};
   1.163 +/* *INDENT-ON* */