src/events/scancodes_xfree86.h
author Sam Lantinga <slouken@libsdl.org>
Wed, 03 Dec 2008 04:32:24 +0000
changeset 2825 620a91b6d263
parent 2305 fbe8ff44c519
child 2859 99210400e8b9
permissions -rw-r--r--
Date: Tue, 02 Dec 2008 23:38:26 +0100
From: Couriersud
Subject: Re: SDL: Keyboard layout unknown

I have attached a diff which will add an additional keyboard layout to
the x11 driver. The issue arose, when I moved to ubuntu intrepid. I was
only able to map the keys available on my keyboard. The differences to
the existing keyboard was the mapping of HOME,UP,DOWN and some other
keys.

Now only one issue remains. Dead keys (e.g. ^, ` ') on european
keyboards do not generate a "scancode" event. Just a text event when the
key is composed (e.g. ?? ?? ??).
     1 /*
     2     SDL - Simple DirectMedia Layer
     3     Copyright (C) 1997-2006 Sam Lantinga
     4 
     5     This library is free software; you can redistribute it and/or
     6     modify it under the terms of the GNU Lesser General Public
     7     License as published by the Free Software Foundation; either
     8     version 2.1 of the License, or (at your option) any later version.
     9 
    10     This library is distributed in the hope that it will be useful,
    11     but WITHOUT ANY WARRANTY; without even the implied warranty of
    12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    13     Lesser General Public License for more details.
    14 
    15     You should have received a copy of the GNU Lesser General Public
    16     License along with this library; if not, write to the Free Software
    17     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    18 
    19     Sam Lantinga
    20     slouken@libsdl.org
    21 */
    22 #include "../../include/SDL_scancode.h"
    23 
    24 /* XFree86 key code to SDL scancode mapping table
    25    Sources:
    26    - atKeyNames.h from XFree86 source code
    27 */
    28 /* *INDENT-OFF* */
    29 static SDL_scancode xfree86_scancode_table[] = {
    30     /*  0 */    SDL_SCANCODE_UNKNOWN,
    31     /*  1 */    SDL_SCANCODE_ESCAPE,
    32     /*  2 */    SDL_SCANCODE_1,
    33     /*  3 */    SDL_SCANCODE_2,
    34     /*  4 */    SDL_SCANCODE_3,
    35     /*  5 */    SDL_SCANCODE_4,
    36     /*  6 */    SDL_SCANCODE_5,
    37     /*  7 */    SDL_SCANCODE_6,
    38     /*  8 */    SDL_SCANCODE_7,
    39     /*  9 */    SDL_SCANCODE_8,
    40     /*  10 */   SDL_SCANCODE_9,
    41     /*  11 */   SDL_SCANCODE_0,
    42     /*  12 */   SDL_SCANCODE_MINUS,
    43     /*  13 */   SDL_SCANCODE_EQUALS,
    44     /*  14 */   SDL_SCANCODE_BACKSPACE,
    45     /*  15 */   SDL_SCANCODE_TAB,
    46     /*  16 */   SDL_SCANCODE_Q,
    47     /*  17 */   SDL_SCANCODE_W,
    48     /*  18 */   SDL_SCANCODE_E,
    49     /*  19 */   SDL_SCANCODE_R,
    50     /*  20 */   SDL_SCANCODE_T,
    51     /*  21 */   SDL_SCANCODE_Y,
    52     /*  22 */   SDL_SCANCODE_U,
    53     /*  23 */   SDL_SCANCODE_I,
    54     /*  24 */   SDL_SCANCODE_O,
    55     /*  25 */   SDL_SCANCODE_P,
    56     /*  26 */   SDL_SCANCODE_LEFTBRACKET,
    57     /*  27 */   SDL_SCANCODE_RIGHTBRACKET,
    58     /*  28 */   SDL_SCANCODE_RETURN,
    59     /*  29 */   SDL_SCANCODE_LCTRL,
    60     /*  30 */   SDL_SCANCODE_A,
    61     /*  31 */   SDL_SCANCODE_S,
    62     /*  32 */   SDL_SCANCODE_D,
    63     /*  33 */   SDL_SCANCODE_F,
    64     /*  34 */   SDL_SCANCODE_G,
    65     /*  35 */   SDL_SCANCODE_H,
    66     /*  36 */   SDL_SCANCODE_J,
    67     /*  37 */   SDL_SCANCODE_K,
    68     /*  38 */   SDL_SCANCODE_L,
    69     /*  39 */   SDL_SCANCODE_SEMICOLON,
    70     /*  40 */   SDL_SCANCODE_APOSTROPHE,
    71     /*  41 */   SDL_SCANCODE_GRAVE,
    72     /*  42 */   SDL_SCANCODE_LSHIFT,
    73     /*  43 */   SDL_SCANCODE_BACKSLASH,
    74     /*  44 */   SDL_SCANCODE_Z,
    75     /*  45 */   SDL_SCANCODE_X,
    76     /*  46 */   SDL_SCANCODE_C,
    77     /*  47 */   SDL_SCANCODE_V,
    78     /*  48 */   SDL_SCANCODE_B,
    79     /*  49 */   SDL_SCANCODE_N,
    80     /*  50 */   SDL_SCANCODE_M,
    81     /*  51 */   SDL_SCANCODE_COMMA,
    82     /*  52 */   SDL_SCANCODE_PERIOD,
    83     /*  53 */   SDL_SCANCODE_SLASH,
    84     /*  54 */   SDL_SCANCODE_RSHIFT,
    85     /*  55 */   SDL_SCANCODE_KP_MULTIPLY,
    86     /*  56 */   SDL_SCANCODE_LALT,
    87     /*  57 */   SDL_SCANCODE_SPACE,
    88     /*  58 */   SDL_SCANCODE_CAPSLOCK,
    89     /*  59 */   SDL_SCANCODE_F1,
    90     /*  60 */   SDL_SCANCODE_F2,
    91     /*  61 */   SDL_SCANCODE_F3,
    92     /*  62 */   SDL_SCANCODE_F4,
    93     /*  63 */   SDL_SCANCODE_F5,
    94     /*  64 */   SDL_SCANCODE_F6,
    95     /*  65 */   SDL_SCANCODE_F7,
    96     /*  66 */   SDL_SCANCODE_F8,
    97     /*  67 */   SDL_SCANCODE_F9,
    98     /*  68 */   SDL_SCANCODE_F10,
    99     /*  69 */   SDL_SCANCODE_NUMLOCKCLEAR,
   100     /*  70 */   SDL_SCANCODE_SCROLLLOCK,
   101     /*  71 */   SDL_SCANCODE_KP_7,
   102     /*  72 */   SDL_SCANCODE_KP_8,
   103     /*  73 */   SDL_SCANCODE_KP_9,
   104     /*  74 */   SDL_SCANCODE_KP_MINUS,
   105     /*  75 */   SDL_SCANCODE_KP_4,
   106     /*  76 */   SDL_SCANCODE_KP_5,
   107     /*  77 */   SDL_SCANCODE_KP_6,
   108     /*  78 */   SDL_SCANCODE_KP_PLUS,
   109     /*  79 */   SDL_SCANCODE_KP_1,
   110     /*  80 */   SDL_SCANCODE_KP_2,
   111     /*  81 */   SDL_SCANCODE_KP_3,
   112     /*  82 */   SDL_SCANCODE_KP_0,
   113     /*  83 */   SDL_SCANCODE_KP_PERIOD,
   114     /*  84 */   SDL_SCANCODE_SYSREQ,
   115     /*  85 */   SDL_SCANCODE_MODE,
   116     /*  86 */   SDL_SCANCODE_NONUSBACKSLASH,
   117     /*  87 */   SDL_SCANCODE_F11,
   118     /*  88 */   SDL_SCANCODE_F12,
   119     /*  89 */   SDL_SCANCODE_HOME,
   120     /*  90 */   SDL_SCANCODE_UP,
   121     /*  91 */   SDL_SCANCODE_PAGEUP,
   122     /*  92 */   SDL_SCANCODE_LEFT,
   123     /*  93 */   SDL_SCANCODE_BRIGHTNESSDOWN, /* on PowerBook G4 / KEY_Begin */
   124     /*  94 */   SDL_SCANCODE_RIGHT,
   125     /*  95 */   SDL_SCANCODE_END,
   126     /*  96 */   SDL_SCANCODE_DOWN,
   127     /*  97 */   SDL_SCANCODE_PAGEDOWN,
   128     /*  98 */   SDL_SCANCODE_INSERT,
   129     /*  99 */   SDL_SCANCODE_DELETE,
   130     /*  100 */  SDL_SCANCODE_KP_ENTER,
   131     /*  101 */  SDL_SCANCODE_RCTRL,
   132     /*  102 */  SDL_SCANCODE_PAUSE,
   133     /*  103 */  SDL_SCANCODE_PRINTSCREEN,
   134     /*  104 */  SDL_SCANCODE_KP_DIVIDE,
   135     /*  105 */  SDL_SCANCODE_RALT,
   136     /*  106 */  SDL_SCANCODE_UNKNOWN, /* BREAK */
   137     /*  107 */  SDL_SCANCODE_LGUI,
   138     /*  108 */  SDL_SCANCODE_RGUI,
   139     /*  109 */  SDL_SCANCODE_APPLICATION,
   140     /*  110 */  SDL_SCANCODE_F13,
   141     /*  111 */  SDL_SCANCODE_F14,
   142     /*  112 */  SDL_SCANCODE_F15,
   143     /*  113 */  SDL_SCANCODE_F16,
   144     /*  114 */  SDL_SCANCODE_F17,
   145     /*  115 */	SDL_SCANCODE_UNKNOWN,
   146     /*	116 */  SDL_SCANCODE_UNKNOWN, /* is translated to XK_ISO_Level3_Shift by my X server, but I have no keyboard that generates this code, so I don't know what the correct SDL_SCANCODE_* for it is */
   147     /*  117 */  SDL_SCANCODE_UNKNOWN,
   148     /*  118 */  SDL_SCANCODE_KP_EQUALS,
   149     /*  119 */  SDL_SCANCODE_UNKNOWN,
   150     /*  120 */  SDL_SCANCODE_UNKNOWN,
   151     /*  121 */  SDL_SCANCODE_UNKNOWN,
   152     /*  122 */  SDL_SCANCODE_UNKNOWN,
   153     /*  123 */  SDL_SCANCODE_UNKNOWN,
   154     /*  124 */  SDL_SCANCODE_UNKNOWN,
   155     /*  125 */  SDL_SCANCODE_INTERNATIONAL3, /* Yen */
   156     /*  126 */  SDL_SCANCODE_UNKNOWN,
   157     /*  127 */  SDL_SCANCODE_UNKNOWN,
   158     /*  128 */  SDL_SCANCODE_UNKNOWN,
   159     /*  129 */  SDL_SCANCODE_UNKNOWN,
   160     /*  130 */  SDL_SCANCODE_UNKNOWN,
   161     /*  131 */  SDL_SCANCODE_UNKNOWN,
   162     /*  132 */  SDL_SCANCODE_POWER,
   163     /*  133 */  SDL_SCANCODE_MUTE,
   164     /*  134 */  SDL_SCANCODE_VOLUMEDOWN,
   165     /*  135 */  SDL_SCANCODE_VOLUMEUP,
   166     /*  136 */  SDL_SCANCODE_HELP,
   167     /*  137 */  SDL_SCANCODE_STOP,
   168     /*  138 */  SDL_SCANCODE_AGAIN,
   169     /*  139 */  SDL_SCANCODE_UNKNOWN, /* PROPS */
   170     /*  140 */  SDL_SCANCODE_UNDO,
   171     /*  141 */  SDL_SCANCODE_UNKNOWN, /* FRONT */
   172     /*  142 */  SDL_SCANCODE_COPY,
   173     /*  143 */  SDL_SCANCODE_UNKNOWN, /* OPEN */
   174     /*  144 */  SDL_SCANCODE_PASTE,
   175     /*  145 */  SDL_SCANCODE_FIND,
   176     /*  146 */  SDL_SCANCODE_CUT,
   177 };
   178 
   179 /* for wireless usb keyboard (manufacturer TRUST) without numpad. */
   180 static SDL_scancode xfree86_scancode_table2[] = {
   181     /*  0 */    SDL_SCANCODE_UNKNOWN,
   182     /*  1 */    SDL_SCANCODE_ESCAPE,
   183     /*  2 */    SDL_SCANCODE_1,
   184     /*  3 */    SDL_SCANCODE_2,
   185     /*  4 */    SDL_SCANCODE_3,
   186     /*  5 */    SDL_SCANCODE_4,
   187     /*  6 */    SDL_SCANCODE_5,
   188     /*  7 */    SDL_SCANCODE_6,
   189     /*  8 */    SDL_SCANCODE_7,
   190     /*  9 */    SDL_SCANCODE_8,
   191     /*  10 */   SDL_SCANCODE_9,
   192     /*  11 */   SDL_SCANCODE_0,
   193     /*  12 */   SDL_SCANCODE_MINUS,
   194     /*  13 */   SDL_SCANCODE_EQUALS,
   195     /*  14 */   SDL_SCANCODE_BACKSPACE,
   196     /*  15 */   SDL_SCANCODE_TAB,
   197     /*  16 */   SDL_SCANCODE_Q,
   198     /*  17 */   SDL_SCANCODE_W,
   199     /*  18 */   SDL_SCANCODE_E,
   200     /*  19 */   SDL_SCANCODE_R,
   201     /*  20 */   SDL_SCANCODE_T,
   202     /*  21 */   SDL_SCANCODE_Y,
   203     /*  22 */   SDL_SCANCODE_U,
   204     /*  23 */   SDL_SCANCODE_I,
   205     /*  24 */   SDL_SCANCODE_O,
   206     /*  25 */   SDL_SCANCODE_P,
   207     /*  26 */   SDL_SCANCODE_LEFTBRACKET,
   208     /*  27 */   SDL_SCANCODE_RIGHTBRACKET,
   209     /*  28 */   SDL_SCANCODE_RETURN,
   210     /*  29 */   SDL_SCANCODE_LCTRL,
   211     /*  30 */   SDL_SCANCODE_A,
   212     /*  31 */   SDL_SCANCODE_S,
   213     /*  32 */   SDL_SCANCODE_D,
   214     /*  33 */   SDL_SCANCODE_F,
   215     /*  34 */   SDL_SCANCODE_G,
   216     /*  35 */   SDL_SCANCODE_H,
   217     /*  36 */   SDL_SCANCODE_J,
   218     /*  37 */   SDL_SCANCODE_K,
   219     /*  38 */   SDL_SCANCODE_L,
   220     /*  39 */   SDL_SCANCODE_SEMICOLON,
   221     /*  40 */   SDL_SCANCODE_APOSTROPHE,
   222     /*  41 */   SDL_SCANCODE_GRAVE,
   223     /*  42 */   SDL_SCANCODE_LSHIFT,
   224     /*  43 */   SDL_SCANCODE_BACKSLASH,
   225     /*  44 */   SDL_SCANCODE_Z,
   226     /*  45 */   SDL_SCANCODE_X,
   227     /*  46 */   SDL_SCANCODE_C,
   228     /*  47 */   SDL_SCANCODE_V,
   229     /*  48 */   SDL_SCANCODE_B,
   230     /*  49 */   SDL_SCANCODE_N,
   231     /*  50 */   SDL_SCANCODE_M,
   232     /*  51 */   SDL_SCANCODE_COMMA,
   233     /*  52 */   SDL_SCANCODE_PERIOD,
   234     /*  53 */   SDL_SCANCODE_SLASH,
   235     /*  54 */   SDL_SCANCODE_RSHIFT,
   236     /*  55 */   SDL_SCANCODE_KP_MULTIPLY,
   237     /*  56 */   SDL_SCANCODE_LALT,
   238     /*  57 */   SDL_SCANCODE_SPACE,
   239     /*  58 */   SDL_SCANCODE_CAPSLOCK,
   240     /*  59 */   SDL_SCANCODE_F1,
   241     /*  60 */   SDL_SCANCODE_F2,
   242     /*  61 */   SDL_SCANCODE_F3,
   243     /*  62 */   SDL_SCANCODE_F4,
   244     /*  63 */   SDL_SCANCODE_F5,
   245     /*  64 */   SDL_SCANCODE_F6,
   246     /*  65 */   SDL_SCANCODE_F7,
   247     /*  66 */   SDL_SCANCODE_F8,
   248     /*  67 */   SDL_SCANCODE_F9,
   249     /*  68 */   SDL_SCANCODE_F10,
   250     /*  69 */   SDL_SCANCODE_NUMLOCKCLEAR,
   251     /*  70 */   SDL_SCANCODE_SCROLLLOCK,
   252     /*  71 */   SDL_SCANCODE_KP_7,
   253     /*  72 */   SDL_SCANCODE_KP_8,
   254     /*  73 */   SDL_SCANCODE_KP_9,
   255     /*  74 */   SDL_SCANCODE_KP_MINUS,
   256     /*  75 */   SDL_SCANCODE_KP_4,
   257     /*  76 */   SDL_SCANCODE_KP_5,
   258     /*  77 */   SDL_SCANCODE_KP_6,
   259     /*  78 */   SDL_SCANCODE_KP_PLUS,
   260     /*  79 */   SDL_SCANCODE_KP_1,
   261     /*  80 */   SDL_SCANCODE_KP_2,
   262     /*  81 */   SDL_SCANCODE_KP_3,
   263     /*  82 */   SDL_SCANCODE_KP_0,
   264     /*  83 */   SDL_SCANCODE_KP_PERIOD,
   265     /*  84 */   SDL_SCANCODE_SYSREQ,		/* ???? */
   266     /*  85 */   SDL_SCANCODE_MODE,			/* ???? */
   267     /*  86 */   SDL_SCANCODE_NONUSBACKSLASH,
   268     /*  87 */   SDL_SCANCODE_F11,
   269     /*  88 */   SDL_SCANCODE_F12,
   270     /*  89 */   SDL_SCANCODE_UNKNOWN,
   271     /*  90 */   SDL_SCANCODE_UNKNOWN,
   272     /*  91 */   SDL_SCANCODE_UNKNOWN,
   273     /*  92 */   SDL_SCANCODE_UNKNOWN,
   274     /*  93 */   SDL_SCANCODE_UNKNOWN,
   275     /*  94 */   SDL_SCANCODE_UNKNOWN,
   276     /*  95 */   SDL_SCANCODE_UNKNOWN,
   277     /*  96 */   SDL_SCANCODE_UNKNOWN,
   278     /*  97 */   SDL_SCANCODE_RCTRL,
   279     /*  98 */   SDL_SCANCODE_KP_DIVIDE,
   280     /*  99 */   SDL_SCANCODE_UNKNOWN,
   281     /* 100 */   SDL_SCANCODE_RALT,	 /* ISO_Level3_Shift, ALTGR, RALT */
   282     /* 101 */   SDL_SCANCODE_UNKNOWN,
   283     /* 102 */   SDL_SCANCODE_HOME,
   284     /* 103 */   SDL_SCANCODE_UP,
   285     /* 104 */   SDL_SCANCODE_PAGEUP,
   286     /* 105 */   SDL_SCANCODE_LEFT,
   287     /* 106 */   SDL_SCANCODE_RIGHT,
   288     /* 107 */   SDL_SCANCODE_END,
   289     /* 108 */   SDL_SCANCODE_DOWN,
   290     /* 109 */   SDL_SCANCODE_PAGEDOWN,
   291     /* 110 */   SDL_SCANCODE_INSERT,
   292     /* 111 */   SDL_SCANCODE_DELETE,
   293     /* 112 */   SDL_SCANCODE_UNKNOWN,
   294     /* 113 */   SDL_SCANCODE_UNKNOWN,
   295     /* 114 */   SDL_SCANCODE_UNKNOWN,
   296     /* 115 */   SDL_SCANCODE_UNKNOWN,
   297     /* 116 */   SDL_SCANCODE_UNKNOWN,
   298     /* 117 */   SDL_SCANCODE_UNKNOWN,
   299     /* 118 */   SDL_SCANCODE_UNKNOWN,
   300     /* 119 */   SDL_SCANCODE_UNKNOWN,
   301     /* 120 */   SDL_SCANCODE_UNKNOWN,
   302     /* 121 */ 	SDL_SCANCODE_PAUSE,
   303     /* 122 */   SDL_SCANCODE_UNKNOWN,
   304     /* 123 */   SDL_SCANCODE_UNKNOWN,
   305     /* 124 */   SDL_SCANCODE_UNKNOWN,
   306     /* 125 */  SDL_SCANCODE_LGUI,
   307     /* 126 */  SDL_SCANCODE_RGUI,
   308     /* 127 */  SDL_SCANCODE_APPLICATION,
   309     /* 128 */  SDL_SCANCODE_UNKNOWN,
   310     /* 129 */  SDL_SCANCODE_UNKNOWN,
   311     /* 130 */  SDL_SCANCODE_UNKNOWN,
   312     /* 131 */  SDL_SCANCODE_UNKNOWN,
   313     /* 132 */  SDL_SCANCODE_UNKNOWN,
   314     /* 133 */  SDL_SCANCODE_UNKNOWN,
   315     /* 134 */  SDL_SCANCODE_UNKNOWN,
   316     /* 135 */  SDL_SCANCODE_UNKNOWN,
   317     /* 136 */  SDL_SCANCODE_UNKNOWN,
   318     /* 137 */  SDL_SCANCODE_UNKNOWN,
   319     /* 138 */  SDL_SCANCODE_UNKNOWN,
   320     /* 139 */  SDL_SCANCODE_UNKNOWN,
   321     /* 140 */  SDL_SCANCODE_UNKNOWN,
   322     /* 141 */  SDL_SCANCODE_UNKNOWN,
   323     /* 142 */  SDL_SCANCODE_UNKNOWN,
   324     /* 143 */  SDL_SCANCODE_UNKNOWN,
   325     /* 144 */  SDL_SCANCODE_UNKNOWN,
   326     /* 145 */  SDL_SCANCODE_UNKNOWN,
   327     /* 146 */  SDL_SCANCODE_UNKNOWN,
   328 };
   329 
   330 /* *INDENT-ON* */