src/events/SDL_keyboard.c
author Sam Lantinga <slouken@libsdl.org>
Sun, 02 Jun 2013 01:09:12 -0700
changeset 7258 89d47188c9a4
parent 7191 75360622e65f
child 7312 b36811d7db33
permissions -rw-r--r--
Fixed bug 1882 - SDL_GetKeyboardState should return const. Yuri K. Schlesner The array returned by SDL_GetKeyboardState is also used internally by SDL to keep track of pressed/released keys and must not be modified, lest weird behaviour occurs. Because of this I believe it's return type should be changed to return a const pointer, which will provide a code indication of that fact.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
     1
/*
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5414
diff changeset
     2
  Simple DirectMedia Layer
6885
700f1b25f77f Happy New Year!
Sam Lantinga <slouken@libsdl.org>
parents: 6813
diff changeset
     3
  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
     4
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5414
diff changeset
     5
  This software is provided 'as-is', without any express or implied
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5414
diff changeset
     6
  warranty.  In no event will the authors be held liable for any damages
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5414
diff changeset
     7
  arising from the use of this software.
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
     8
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5414
diff changeset
     9
  Permission is granted to anyone to use this software for any purpose,
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5414
diff changeset
    10
  including commercial applications, and to alter it and redistribute it
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5414
diff changeset
    11
  freely, subject to the following restrictions:
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    12
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5414
diff changeset
    13
  1. The origin of this software must not be misrepresented; you must not
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5414
diff changeset
    14
     claim that you wrote the original software. If you use this software
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5414
diff changeset
    15
     in a product, an acknowledgment in the product documentation would be
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5414
diff changeset
    16
     appreciated but is not required.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5414
diff changeset
    17
  2. Altered source versions must be plainly marked as such, and must not be
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5414
diff changeset
    18
     misrepresented as being the original software.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5414
diff changeset
    19
  3. This notice may not be removed or altered from any source distribution.
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    20
*/
1402
d910939febfa Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
    21
#include "SDL_config.h"
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    22
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    23
/* General keyboard handling code for SDL */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    24
1358
c71e05b4dc2e More header massaging... works great on Windows. ;-)
Sam Lantinga <slouken@libsdl.org>
parents: 1336
diff changeset
    25
#include "SDL_timer.h"
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    26
#include "SDL_events.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    27
#include "SDL_events_c.h"
5123
dc0dfdd58f27 Removed completely non-portable event thread hack.
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
    28
#include "../video/SDL_sysvideo.h"
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    29
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    30
6661
cd8befc0a969 Reset the keyboard when we lose input focus
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
    31
/*#define DEBUG_KEYBOARD*/
cd8befc0a969 Reset the keyboard when we lose input focus
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
    32
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
    33
/* Global keyboard information */
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4437
diff changeset
    34
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4437
diff changeset
    35
typedef struct SDL_Keyboard SDL_Keyboard;
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4437
diff changeset
    36
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4437
diff changeset
    37
struct SDL_Keyboard
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4437
diff changeset
    38
{
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4437
diff changeset
    39
    /* Data common to all keyboards */
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4437
diff changeset
    40
    SDL_Window *focus;
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4437
diff changeset
    41
    Uint16 modstate;
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4437
diff changeset
    42
    Uint8 keystate[SDL_NUM_SCANCODES];
5220
1fbe1c202501 Renamed SDL_Key to SDL_Keycode to clarify terminology.
Sam Lantinga <slouken@libsdl.org>
parents: 5219
diff changeset
    43
    SDL_Keycode keymap[SDL_NUM_SCANCODES];
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4437
diff changeset
    44
};
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4437
diff changeset
    45
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4437
diff changeset
    46
static SDL_Keyboard SDL_keyboard;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    47
5220
1fbe1c202501 Renamed SDL_Key to SDL_Keycode to clarify terminology.
Sam Lantinga <slouken@libsdl.org>
parents: 5219
diff changeset
    48
static const SDL_Keycode SDL_default_keymap[SDL_NUM_SCANCODES] = {
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    49
    0, 0, 0, 0,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    50
    'a',
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    51
    'b',
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    52
    'c',
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    53
    'd',
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    54
    'e',
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    55
    'f',
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    56
    'g',
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    57
    'h',
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    58
    'i',
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    59
    'j',
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    60
    'k',
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    61
    'l',
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    62
    'm',
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    63
    'n',
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    64
    'o',
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    65
    'p',
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    66
    'q',
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    67
    'r',
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    68
    's',
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    69
    't',
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    70
    'u',
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    71
    'v',
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    72
    'w',
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    73
    'x',
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    74
    'y',
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    75
    'z',
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    76
    '1',
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    77
    '2',
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    78
    '3',
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    79
    '4',
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    80
    '5',
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    81
    '6',
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    82
    '7',
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    83
    '8',
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    84
    '9',
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    85
    '0',
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    86
    SDLK_RETURN,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    87
    SDLK_ESCAPE,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    88
    SDLK_BACKSPACE,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    89
    SDLK_TAB,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    90
    SDLK_SPACE,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    91
    '-',
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    92
    '=',
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    93
    '[',
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    94
    ']',
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    95
    '\\',
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    96
    '#',
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    97
    ';',
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    98
    '\'',
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
    99
    '`',
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   100
    ',',
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   101
    '.',
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   102
    '/',
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   103
    SDLK_CAPSLOCK,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   104
    SDLK_F1,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   105
    SDLK_F2,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   106
    SDLK_F3,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   107
    SDLK_F4,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   108
    SDLK_F5,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   109
    SDLK_F6,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   110
    SDLK_F7,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   111
    SDLK_F8,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   112
    SDLK_F9,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   113
    SDLK_F10,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   114
    SDLK_F11,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   115
    SDLK_F12,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   116
    SDLK_PRINTSCREEN,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   117
    SDLK_SCROLLLOCK,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   118
    SDLK_PAUSE,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   119
    SDLK_INSERT,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   120
    SDLK_HOME,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   121
    SDLK_PAGEUP,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   122
    SDLK_DELETE,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   123
    SDLK_END,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   124
    SDLK_PAGEDOWN,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   125
    SDLK_RIGHT,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   126
    SDLK_LEFT,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   127
    SDLK_DOWN,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   128
    SDLK_UP,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   129
    SDLK_NUMLOCKCLEAR,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   130
    SDLK_KP_DIVIDE,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   131
    SDLK_KP_MULTIPLY,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   132
    SDLK_KP_MINUS,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   133
    SDLK_KP_PLUS,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   134
    SDLK_KP_ENTER,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   135
    SDLK_KP_1,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   136
    SDLK_KP_2,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   137
    SDLK_KP_3,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   138
    SDLK_KP_4,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   139
    SDLK_KP_5,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   140
    SDLK_KP_6,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   141
    SDLK_KP_7,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   142
    SDLK_KP_8,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   143
    SDLK_KP_9,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   144
    SDLK_KP_0,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   145
    SDLK_KP_PERIOD,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   146
    0,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   147
    SDLK_APPLICATION,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   148
    SDLK_POWER,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   149
    SDLK_KP_EQUALS,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   150
    SDLK_F13,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   151
    SDLK_F14,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   152
    SDLK_F15,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   153
    SDLK_F16,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   154
    SDLK_F17,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   155
    SDLK_F18,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   156
    SDLK_F19,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   157
    SDLK_F20,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   158
    SDLK_F21,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   159
    SDLK_F22,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   160
    SDLK_F23,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   161
    SDLK_F24,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   162
    SDLK_EXECUTE,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   163
    SDLK_HELP,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   164
    SDLK_MENU,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   165
    SDLK_SELECT,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   166
    SDLK_STOP,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   167
    SDLK_AGAIN,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   168
    SDLK_UNDO,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   169
    SDLK_CUT,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   170
    SDLK_COPY,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   171
    SDLK_PASTE,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   172
    SDLK_FIND,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   173
    SDLK_MUTE,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   174
    SDLK_VOLUMEUP,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   175
    SDLK_VOLUMEDOWN,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   176
    0, 0, 0,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   177
    SDLK_KP_COMMA,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   178
    SDLK_KP_EQUALSAS400,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   179
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   180
    SDLK_ALTERASE,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   181
    SDLK_SYSREQ,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   182
    SDLK_CANCEL,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   183
    SDLK_CLEAR,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   184
    SDLK_PRIOR,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   185
    SDLK_RETURN2,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   186
    SDLK_SEPARATOR,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   187
    SDLK_OUT,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   188
    SDLK_OPER,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   189
    SDLK_CLEARAGAIN,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   190
    SDLK_CRSEL,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   191
    SDLK_EXSEL,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   192
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   193
    SDLK_KP_00,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   194
    SDLK_KP_000,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   195
    SDLK_THOUSANDSSEPARATOR,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   196
    SDLK_DECIMALSEPARATOR,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   197
    SDLK_CURRENCYUNIT,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   198
    SDLK_CURRENCYSUBUNIT,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   199
    SDLK_KP_LEFTPAREN,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   200
    SDLK_KP_RIGHTPAREN,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   201
    SDLK_KP_LEFTBRACE,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   202
    SDLK_KP_RIGHTBRACE,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   203
    SDLK_KP_TAB,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   204
    SDLK_KP_BACKSPACE,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   205
    SDLK_KP_A,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   206
    SDLK_KP_B,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   207
    SDLK_KP_C,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   208
    SDLK_KP_D,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   209
    SDLK_KP_E,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   210
    SDLK_KP_F,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   211
    SDLK_KP_XOR,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   212
    SDLK_KP_POWER,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   213
    SDLK_KP_PERCENT,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   214
    SDLK_KP_LESS,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   215
    SDLK_KP_GREATER,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   216
    SDLK_KP_AMPERSAND,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   217
    SDLK_KP_DBLAMPERSAND,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   218
    SDLK_KP_VERTICALBAR,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   219
    SDLK_KP_DBLVERTICALBAR,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   220
    SDLK_KP_COLON,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   221
    SDLK_KP_HASH,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   222
    SDLK_KP_SPACE,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   223
    SDLK_KP_AT,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   224
    SDLK_KP_EXCLAM,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   225
    SDLK_KP_MEMSTORE,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   226
    SDLK_KP_MEMRECALL,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   227
    SDLK_KP_MEMCLEAR,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   228
    SDLK_KP_MEMADD,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   229
    SDLK_KP_MEMSUBTRACT,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   230
    SDLK_KP_MEMMULTIPLY,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   231
    SDLK_KP_MEMDIVIDE,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   232
    SDLK_KP_PLUSMINUS,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   233
    SDLK_KP_CLEAR,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   234
    SDLK_KP_CLEARENTRY,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   235
    SDLK_KP_BINARY,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   236
    SDLK_KP_OCTAL,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   237
    SDLK_KP_DECIMAL,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   238
    SDLK_KP_HEXADECIMAL,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   239
    0, 0,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   240
    SDLK_LCTRL,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   241
    SDLK_LSHIFT,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   242
    SDLK_LALT,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   243
    SDLK_LGUI,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   244
    SDLK_RCTRL,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   245
    SDLK_RSHIFT,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   246
    SDLK_RALT,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   247
    SDLK_RGUI,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   248
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   249
    SDLK_MODE,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   250
    SDLK_AUDIONEXT,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   251
    SDLK_AUDIOPREV,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   252
    SDLK_AUDIOSTOP,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   253
    SDLK_AUDIOPLAY,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   254
    SDLK_AUDIOMUTE,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   255
    SDLK_MEDIASELECT,
2305
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2303
diff changeset
   256
    SDLK_WWW,
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   257
    SDLK_MAIL,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   258
    SDLK_CALCULATOR,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   259
    SDLK_COMPUTER,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   260
    SDLK_AC_SEARCH,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   261
    SDLK_AC_HOME,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   262
    SDLK_AC_BACK,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   263
    SDLK_AC_FORWARD,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   264
    SDLK_AC_STOP,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   265
    SDLK_AC_REFRESH,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   266
    SDLK_AC_BOOKMARKS,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   267
    SDLK_BRIGHTNESSDOWN,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   268
    SDLK_BRIGHTNESSUP,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   269
    SDLK_DISPLAYSWITCH,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   270
    SDLK_KBDILLUMTOGGLE,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   271
    SDLK_KBDILLUMDOWN,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   272
    SDLK_KBDILLUMUP,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   273
    SDLK_EJECT,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   274
    SDLK_SLEEP,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   275
};
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   276
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   277
static const char *SDL_scancode_names[SDL_NUM_SCANCODES] = {
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   278
    NULL, NULL, NULL, NULL,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   279
    "A",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   280
    "B",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   281
    "C",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   282
    "D",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   283
    "E",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   284
    "F",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   285
    "G",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   286
    "H",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   287
    "I",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   288
    "J",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   289
    "K",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   290
    "L",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   291
    "M",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   292
    "N",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   293
    "O",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   294
    "P",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   295
    "Q",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   296
    "R",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   297
    "S",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   298
    "T",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   299
    "U",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   300
    "V",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   301
    "W",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   302
    "X",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   303
    "Y",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   304
    "Z",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   305
    "1",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   306
    "2",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   307
    "3",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   308
    "4",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   309
    "5",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   310
    "6",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   311
    "7",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   312
    "8",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   313
    "9",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   314
    "0",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   315
    "Return",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   316
    "Escape",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   317
    "Backspace",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   318
    "Tab",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   319
    "Space",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   320
    "-",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   321
    "=",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   322
    "[",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   323
    "]",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   324
    "\\",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   325
    "#",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   326
    ";",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   327
    "'",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   328
    "`",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   329
    ",",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   330
    ".",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   331
    "/",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   332
    "CapsLock",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   333
    "F1",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   334
    "F2",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   335
    "F3",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   336
    "F4",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   337
    "F5",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   338
    "F6",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   339
    "F7",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   340
    "F8",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   341
    "F9",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   342
    "F10",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   343
    "F11",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   344
    "F12",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   345
    "PrintScreen",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   346
    "ScrollLock",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   347
    "Pause",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   348
    "Insert",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   349
    "Home",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   350
    "PageUp",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   351
    "Delete",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   352
    "End",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   353
    "PageDown",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   354
    "Right",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   355
    "Left",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   356
    "Down",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   357
    "Up",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   358
    "Numlock",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   359
    "Keypad /",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   360
    "Keypad *",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   361
    "Keypad -",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   362
    "Keypad +",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   363
    "Keypad Enter",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   364
    "Keypad 1",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   365
    "Keypad 2",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   366
    "Keypad 3",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   367
    "Keypad 4",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   368
    "Keypad 5",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   369
    "Keypad 6",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   370
    "Keypad 7",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   371
    "Keypad 8",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   372
    "Keypad 9",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   373
    "Keypad 0",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   374
    "Keypad .",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   375
    NULL,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   376
    "Application",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   377
    "Power",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   378
    "Keypad =",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   379
    "F13",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   380
    "F14",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   381
    "F15",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   382
    "F16",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   383
    "F17",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   384
    "F18",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   385
    "F19",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   386
    "F20",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   387
    "F21",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   388
    "F22",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   389
    "F23",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   390
    "F24",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   391
    "Execute",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   392
    "Help",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   393
    "Menu",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   394
    "Select",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   395
    "Stop",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   396
    "Again",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   397
    "Undo",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   398
    "Cut",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   399
    "Copy",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   400
    "Paste",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   401
    "Find",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   402
    "Mute",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   403
    "VolumeUp",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   404
    "VolumeDown",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   405
    NULL, NULL, NULL,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   406
    "Keypad ,",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   407
    "Keypad = (AS400)",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   408
    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   409
    NULL, NULL, NULL, NULL, NULL, NULL,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   410
    "AltErase",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   411
    "SysReq",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   412
    "Cancel",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   413
    "Clear",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   414
    "Prior",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   415
    "Return",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   416
    "Separator",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   417
    "Out",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   418
    "Oper",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   419
    "Clear / Again",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   420
    "CrSel",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   421
    "ExSel",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   422
    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   423
    "Keypad 00",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   424
    "Keypad 000",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   425
    "ThousandsSeparator",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   426
    "DecimalSeparator",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   427
    "CurrencyUnit",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   428
    "CurrencySubUnit",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   429
    "Keypad (",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   430
    "Keypad )",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   431
    "Keypad {",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   432
    "Keypad }",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   433
    "Keypad Tab",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   434
    "Keypad Backspace",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   435
    "Keypad A",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   436
    "Keypad B",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   437
    "Keypad C",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   438
    "Keypad D",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   439
    "Keypad E",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   440
    "Keypad F",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   441
    "Keypad XOR",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   442
    "Keypad ^",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   443
    "Keypad %",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   444
    "Keypad <",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   445
    "Keypad >",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   446
    "Keypad &",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   447
    "Keypad &&",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   448
    "Keypad |",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   449
    "Keypad ||",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   450
    "Keypad :",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   451
    "Keypad #",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   452
    "Keypad Space",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   453
    "Keypad @",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   454
    "Keypad !",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   455
    "Keypad MemStore",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   456
    "Keypad MemRecall",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   457
    "Keypad MemClear",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   458
    "Keypad MemAdd",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   459
    "Keypad MemSubtract",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   460
    "Keypad MemMultiply",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   461
    "Keypad MemDivide",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   462
    "Keypad +/-",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   463
    "Keypad Clear",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   464
    "Keypad ClearEntry",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   465
    "Keypad Binary",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   466
    "Keypad Octal",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   467
    "Keypad Decimal",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   468
    "Keypad Hexadecimal",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   469
    NULL, NULL,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   470
    "Left Ctrl",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   471
    "Left Shift",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   472
    "Left Alt",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   473
    "Left GUI",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   474
    "Right Ctrl",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   475
    "Right Shift",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   476
    "Right Alt",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   477
    "Right GUI",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   478
    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   479
    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   480
    NULL,
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   481
    "ModeSwitch",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   482
    "AudioNext",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   483
    "AudioPrev",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   484
    "AudioStop",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   485
    "AudioPlay",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   486
    "AudioMute",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   487
    "MediaSelect",
2305
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2303
diff changeset
   488
    "WWW",
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   489
    "Mail",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   490
    "Calculator",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   491
    "Computer",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   492
    "AC Search",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   493
    "AC Home",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   494
    "AC Back",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   495
    "AC Forward",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   496
    "AC Stop",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   497
    "AC Refresh",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   498
    "AC Bookmarks",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   499
    "BrightnessDown",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   500
    "BrightnessUp",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   501
    "DisplaySwitch",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   502
    "KBDIllumToggle",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   503
    "KBDIllumDown",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   504
    "KBDIllumUp",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   505
    "Eject",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   506
    "Sleep",
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   507
};
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   508
2295
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 2268
diff changeset
   509
/* Taken from SDL_iconv() */
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   510
static char *
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   511
SDL_UCS4ToUTF8(Uint32 ch, char *dst)
2295
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 2268
diff changeset
   512
{
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 2268
diff changeset
   513
    Uint8 *p = (Uint8 *) dst;
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 2268
diff changeset
   514
    if (ch <= 0x7F) {
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 2268
diff changeset
   515
        *p = (Uint8) ch;
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 2268
diff changeset
   516
        ++dst;
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 2268
diff changeset
   517
    } else if (ch <= 0x7FF) {
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 2268
diff changeset
   518
        p[0] = 0xC0 | (Uint8) ((ch >> 6) & 0x1F);
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 2268
diff changeset
   519
        p[1] = 0x80 | (Uint8) (ch & 0x3F);
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 2268
diff changeset
   520
        dst += 2;
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 2268
diff changeset
   521
    } else if (ch <= 0xFFFF) {
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 2268
diff changeset
   522
        p[0] = 0xE0 | (Uint8) ((ch >> 12) & 0x0F);
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 2268
diff changeset
   523
        p[1] = 0x80 | (Uint8) ((ch >> 6) & 0x3F);
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 2268
diff changeset
   524
        p[2] = 0x80 | (Uint8) (ch & 0x3F);
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 2268
diff changeset
   525
        dst += 3;
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 2268
diff changeset
   526
    } else if (ch <= 0x1FFFFF) {
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 2268
diff changeset
   527
        p[0] = 0xF0 | (Uint8) ((ch >> 18) & 0x07);
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 2268
diff changeset
   528
        p[1] = 0x80 | (Uint8) ((ch >> 12) & 0x3F);
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 2268
diff changeset
   529
        p[2] = 0x80 | (Uint8) ((ch >> 6) & 0x3F);
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 2268
diff changeset
   530
        p[3] = 0x80 | (Uint8) (ch & 0x3F);
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 2268
diff changeset
   531
        dst += 4;
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 2268
diff changeset
   532
    } else if (ch <= 0x3FFFFFF) {
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 2268
diff changeset
   533
        p[0] = 0xF8 | (Uint8) ((ch >> 24) & 0x03);
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 2268
diff changeset
   534
        p[1] = 0x80 | (Uint8) ((ch >> 18) & 0x3F);
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 2268
diff changeset
   535
        p[2] = 0x80 | (Uint8) ((ch >> 12) & 0x3F);
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 2268
diff changeset
   536
        p[3] = 0x80 | (Uint8) ((ch >> 6) & 0x3F);
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 2268
diff changeset
   537
        p[4] = 0x80 | (Uint8) (ch & 0x3F);
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 2268
diff changeset
   538
        dst += 5;
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 2268
diff changeset
   539
    } else {
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 2268
diff changeset
   540
        p[0] = 0xFC | (Uint8) ((ch >> 30) & 0x01);
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 2268
diff changeset
   541
        p[1] = 0x80 | (Uint8) ((ch >> 24) & 0x3F);
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 2268
diff changeset
   542
        p[2] = 0x80 | (Uint8) ((ch >> 18) & 0x3F);
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 2268
diff changeset
   543
        p[3] = 0x80 | (Uint8) ((ch >> 12) & 0x3F);
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 2268
diff changeset
   544
        p[4] = 0x80 | (Uint8) ((ch >> 6) & 0x3F);
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 2268
diff changeset
   545
        p[5] = 0x80 | (Uint8) (ch & 0x3F);
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 2268
diff changeset
   546
        dst += 6;
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 2268
diff changeset
   547
    }
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 2268
diff changeset
   548
    return dst;
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 2268
diff changeset
   549
}
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 2268
diff changeset
   550
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   551
/* Public functions */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   552
int
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   553
SDL_KeyboardInit(void)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   554
{
4490
06c7423f8c60 Updated iPhone keyboard code (which builds and runs on the iPad and iPhone simulator now)
Sam Lantinga <slouken@libsdl.org>
parents: 4465
diff changeset
   555
    SDL_Keyboard *keyboard = &SDL_keyboard;
06c7423f8c60 Updated iPhone keyboard code (which builds and runs on the iPad and iPhone simulator now)
Sam Lantinga <slouken@libsdl.org>
parents: 4465
diff changeset
   556
06c7423f8c60 Updated iPhone keyboard code (which builds and runs on the iPad and iPhone simulator now)
Sam Lantinga <slouken@libsdl.org>
parents: 4465
diff changeset
   557
    /* Set the default keymap */
06c7423f8c60 Updated iPhone keyboard code (which builds and runs on the iPad and iPhone simulator now)
Sam Lantinga <slouken@libsdl.org>
parents: 4465
diff changeset
   558
    SDL_memcpy(keyboard->keymap, SDL_default_keymap, sizeof(SDL_default_keymap));
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   559
    return (0);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   560
}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   561
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4437
diff changeset
   562
void
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4437
diff changeset
   563
SDL_ResetKeyboard(void)
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   564
{
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4437
diff changeset
   565
    SDL_Keyboard *keyboard = &SDL_keyboard;
5218
572a73d71b5f Sheena pointed out that "scancode" and "keysym" are single words and shouldn't be camel-cased.
Sam Lantinga <slouken@libsdl.org>
parents: 5123
diff changeset
   566
    SDL_Scancode scancode;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   567
6661
cd8befc0a969 Reset the keyboard when we lose input focus
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   568
#ifdef DEBUG_KEYBOARD
cd8befc0a969 Reset the keyboard when we lose input focus
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   569
    printf("Resetting keyboard\n");
cd8befc0a969 Reset the keyboard when we lose input focus
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   570
#endif
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   571
    for (scancode = 0; scancode < SDL_NUM_SCANCODES; ++scancode) {
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   572
        if (keyboard->keystate[scancode] == SDL_PRESSED) {
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4437
diff changeset
   573
            SDL_SendKeyboardKey(SDL_RELEASED, scancode);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   574
        }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   575
    }
1123
28ac87a38c17 Date: Fri, 08 Jul 2005 22:43:48 +0200 (CEST)
Sam Lantinga <slouken@libsdl.org>
parents: 1021
diff changeset
   576
}
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   577
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   578
void
5220
1fbe1c202501 Renamed SDL_Key to SDL_Keycode to clarify terminology.
Sam Lantinga <slouken@libsdl.org>
parents: 5219
diff changeset
   579
SDL_GetDefaultKeymap(SDL_Keycode * keymap)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   580
{
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   581
    SDL_memcpy(keymap, SDL_default_keymap, sizeof(SDL_default_keymap));
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   582
}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   583
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   584
void
5220
1fbe1c202501 Renamed SDL_Key to SDL_Keycode to clarify terminology.
Sam Lantinga <slouken@libsdl.org>
parents: 5219
diff changeset
   585
SDL_SetKeymap(int start, SDL_Keycode * keys, int length)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   586
{
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4437
diff changeset
   587
    SDL_Keyboard *keyboard = &SDL_keyboard;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   588
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   589
    if (start < 0 || start + length > SDL_NUM_SCANCODES) {
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   590
        return;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   591
    }
2268
4baee598306d Date: Thu, 05 Jul 2007 14:02:33 -0700
Sam Lantinga <slouken@libsdl.org>
parents: 2229
diff changeset
   592
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   593
    SDL_memcpy(&keyboard->keymap[start], keys, sizeof(*keys) * length);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   594
}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   595
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   596
void
5218
572a73d71b5f Sheena pointed out that "scancode" and "keysym" are single words and shouldn't be camel-cased.
Sam Lantinga <slouken@libsdl.org>
parents: 5123
diff changeset
   597
SDL_SetScancodeName(SDL_Scancode scancode, const char *name)
2268
4baee598306d Date: Thu, 05 Jul 2007 14:02:33 -0700
Sam Lantinga <slouken@libsdl.org>
parents: 2229
diff changeset
   598
{
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   599
    SDL_scancode_names[scancode] = name;
2268
4baee598306d Date: Thu, 05 Jul 2007 14:02:33 -0700
Sam Lantinga <slouken@libsdl.org>
parents: 2229
diff changeset
   600
}
4baee598306d Date: Thu, 05 Jul 2007 14:02:33 -0700
Sam Lantinga <slouken@libsdl.org>
parents: 2229
diff changeset
   601
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4437
diff changeset
   602
SDL_Window *
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4437
diff changeset
   603
SDL_GetKeyboardFocus(void)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   604
{
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4437
diff changeset
   605
    SDL_Keyboard *keyboard = &SDL_keyboard;
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4437
diff changeset
   606
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4437
diff changeset
   607
    return keyboard->focus;
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4437
diff changeset
   608
}
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   609
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4437
diff changeset
   610
void
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4437
diff changeset
   611
SDL_SetKeyboardFocus(SDL_Window * window)
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4437
diff changeset
   612
{
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4437
diff changeset
   613
    SDL_Keyboard *keyboard = &SDL_keyboard;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   614
6665
c0ea8c57034c Reset the keyboard before we lose focus so the correct window is listed in focus events.
Sam Lantinga <slouken@libsdl.org>
parents: 6661
diff changeset
   615
    if (keyboard->focus && !window) {
c0ea8c57034c Reset the keyboard before we lose focus so the correct window is listed in focus events.
Sam Lantinga <slouken@libsdl.org>
parents: 6661
diff changeset
   616
        /* We won't get anymore keyboard messages, so reset keyboard state */
c0ea8c57034c Reset the keyboard before we lose focus so the correct window is listed in focus events.
Sam Lantinga <slouken@libsdl.org>
parents: 6661
diff changeset
   617
        SDL_ResetKeyboard();
c0ea8c57034c Reset the keyboard before we lose focus so the correct window is listed in focus events.
Sam Lantinga <slouken@libsdl.org>
parents: 6661
diff changeset
   618
    }
c0ea8c57034c Reset the keyboard before we lose focus so the correct window is listed in focus events.
Sam Lantinga <slouken@libsdl.org>
parents: 6661
diff changeset
   619
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   620
    /* See if the current window has lost focus */
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3502
diff changeset
   621
    if (keyboard->focus && keyboard->focus != window) {
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4437
diff changeset
   622
        SDL_SendWindowEvent(keyboard->focus, SDL_WINDOWEVENT_FOCUS_LOST,
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4437
diff changeset
   623
                            0, 0);
4890
443771460df9 Fixed crash on systems that don't have StopTextInput
Sam Lantinga <slouken@libsdl.org>
parents: 4882
diff changeset
   624
443771460df9 Fixed crash on systems that don't have StopTextInput
Sam Lantinga <slouken@libsdl.org>
parents: 4882
diff changeset
   625
        /* Ensures IME compositions are committed */
443771460df9 Fixed crash on systems that don't have StopTextInput
Sam Lantinga <slouken@libsdl.org>
parents: 4882
diff changeset
   626
        if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) {
443771460df9 Fixed crash on systems that don't have StopTextInput
Sam Lantinga <slouken@libsdl.org>
parents: 4882
diff changeset
   627
            SDL_VideoDevice *video = SDL_GetVideoDevice();
443771460df9 Fixed crash on systems that don't have StopTextInput
Sam Lantinga <slouken@libsdl.org>
parents: 4882
diff changeset
   628
            if (video && video->StopTextInput) {
443771460df9 Fixed crash on systems that don't have StopTextInput
Sam Lantinga <slouken@libsdl.org>
parents: 4882
diff changeset
   629
                video->StopTextInput(video);
443771460df9 Fixed crash on systems that don't have StopTextInput
Sam Lantinga <slouken@libsdl.org>
parents: 4882
diff changeset
   630
            }
443771460df9 Fixed crash on systems that don't have StopTextInput
Sam Lantinga <slouken@libsdl.org>
parents: 4882
diff changeset
   631
        }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   632
    }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   633
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3502
diff changeset
   634
    keyboard->focus = window;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   635
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   636
    if (keyboard->focus) {
3502
98a819296cdc Whenever a window becomes fullscreen, shown, unminimized, and has input focus it will change the display to the corresponding fullscreen video mode.
Sam Lantinga <slouken@libsdl.org>
parents: 3280
diff changeset
   637
        SDL_SendWindowEvent(keyboard->focus, SDL_WINDOWEVENT_FOCUS_GAINED,
98a819296cdc Whenever a window becomes fullscreen, shown, unminimized, and has input focus it will change the display to the corresponding fullscreen video mode.
Sam Lantinga <slouken@libsdl.org>
parents: 3280
diff changeset
   638
                            0, 0);
4435
e953700da4ca Minor cleanup on Jiang's patch
Sam Lantinga <slouken@libsdl.org>
parents: 4434
diff changeset
   639
e953700da4ca Minor cleanup on Jiang's patch
Sam Lantinga <slouken@libsdl.org>
parents: 4434
diff changeset
   640
        if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) {
4890
443771460df9 Fixed crash on systems that don't have StopTextInput
Sam Lantinga <slouken@libsdl.org>
parents: 4882
diff changeset
   641
            SDL_VideoDevice *video = SDL_GetVideoDevice();
443771460df9 Fixed crash on systems that don't have StopTextInput
Sam Lantinga <slouken@libsdl.org>
parents: 4882
diff changeset
   642
            if (video && video->StartTextInput) {
443771460df9 Fixed crash on systems that don't have StopTextInput
Sam Lantinga <slouken@libsdl.org>
parents: 4882
diff changeset
   643
                video->StartTextInput(video);
443771460df9 Fixed crash on systems that don't have StopTextInput
Sam Lantinga <slouken@libsdl.org>
parents: 4882
diff changeset
   644
            }
4435
e953700da4ca Minor cleanup on Jiang's patch
Sam Lantinga <slouken@libsdl.org>
parents: 4434
diff changeset
   645
        }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   646
    }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   647
}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   648
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   649
int
5218
572a73d71b5f Sheena pointed out that "scancode" and "keysym" are single words and shouldn't be camel-cased.
Sam Lantinga <slouken@libsdl.org>
parents: 5123
diff changeset
   650
SDL_SendKeyboardKey(Uint8 state, SDL_Scancode scancode)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   651
{
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4437
diff changeset
   652
    SDL_Keyboard *keyboard = &SDL_keyboard;
2129
047245361002 Key repeat is handled by the OS, since text input is now decoupled from physical key events.
Sam Lantinga <slouken@libsdl.org>
parents: 1959
diff changeset
   653
    int posted;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   654
    Uint16 modstate;
4429
faa9fc8e7f67 General improvements for user custom event registration
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
   655
    Uint32 type;
4565
e2d46c5c7483 Fixed key repeat detection on X11, and simplified the code for everyone else.
Sam Lantinga <slouken@libsdl.org>
parents: 4562
diff changeset
   656
    Uint8 repeat;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   657
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4437
diff changeset
   658
    if (!scancode) {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   659
        return 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   660
    }
6661
cd8befc0a969 Reset the keyboard when we lose input focus
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   661
#ifdef DEBUG_KEYBOARD
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   662
    printf("The '%s' key has been %s\n", SDL_GetScancodeName(scancode),
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   663
           state == SDL_PRESSED ? "pressed" : "released");
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   664
#endif
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   665
    if (state == SDL_PRESSED) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   666
        modstate = keyboard->modstate;
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   667
        switch (scancode) {
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   668
        case SDL_SCANCODE_NUMLOCKCLEAR:
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   669
            keyboard->modstate ^= KMOD_NUM;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   670
            break;
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   671
        case SDL_SCANCODE_CAPSLOCK:
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   672
            keyboard->modstate ^= KMOD_CAPS;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   673
            break;
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   674
        case SDL_SCANCODE_LCTRL:
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   675
            keyboard->modstate |= KMOD_LCTRL;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   676
            break;
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   677
        case SDL_SCANCODE_RCTRL:
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   678
            keyboard->modstate |= KMOD_RCTRL;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   679
            break;
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   680
        case SDL_SCANCODE_LSHIFT:
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   681
            keyboard->modstate |= KMOD_LSHIFT;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   682
            break;
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   683
        case SDL_SCANCODE_RSHIFT:
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   684
            keyboard->modstate |= KMOD_RSHIFT;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   685
            break;
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   686
        case SDL_SCANCODE_LALT:
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   687
            keyboard->modstate |= KMOD_LALT;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   688
            break;
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   689
        case SDL_SCANCODE_RALT:
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   690
            keyboard->modstate |= KMOD_RALT;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   691
            break;
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   692
        case SDL_SCANCODE_LGUI:
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   693
            keyboard->modstate |= KMOD_LGUI;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   694
            break;
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   695
        case SDL_SCANCODE_RGUI:
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   696
            keyboard->modstate |= KMOD_RGUI;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   697
            break;
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   698
        case SDL_SCANCODE_MODE:
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   699
            keyboard->modstate |= KMOD_MODE;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   700
            break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   701
        default:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   702
            break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   703
        }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   704
    } else {
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   705
        switch (scancode) {
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   706
        case SDL_SCANCODE_NUMLOCKCLEAR:
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   707
        case SDL_SCANCODE_CAPSLOCK:
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   708
            break;
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   709
        case SDL_SCANCODE_LCTRL:
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   710
            keyboard->modstate &= ~KMOD_LCTRL;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   711
            break;
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   712
        case SDL_SCANCODE_RCTRL:
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   713
            keyboard->modstate &= ~KMOD_RCTRL;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   714
            break;
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   715
        case SDL_SCANCODE_LSHIFT:
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   716
            keyboard->modstate &= ~KMOD_LSHIFT;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   717
            break;
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   718
        case SDL_SCANCODE_RSHIFT:
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   719
            keyboard->modstate &= ~KMOD_RSHIFT;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   720
            break;
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   721
        case SDL_SCANCODE_LALT:
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   722
            keyboard->modstate &= ~KMOD_LALT;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   723
            break;
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   724
        case SDL_SCANCODE_RALT:
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   725
            keyboard->modstate &= ~KMOD_RALT;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   726
            break;
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   727
        case SDL_SCANCODE_LGUI:
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   728
            keyboard->modstate &= ~KMOD_LGUI;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   729
            break;
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   730
        case SDL_SCANCODE_RGUI:
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   731
            keyboard->modstate &= ~KMOD_RGUI;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   732
            break;
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   733
        case SDL_SCANCODE_MODE:
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   734
            keyboard->modstate &= ~KMOD_MODE;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   735
            break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   736
        default:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   737
            break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   738
        }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   739
        modstate = keyboard->modstate;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   740
    }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   741
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   742
    /* Figure out what type of event this is */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   743
    switch (state) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   744
    case SDL_PRESSED:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   745
        type = SDL_KEYDOWN;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   746
        break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   747
    case SDL_RELEASED:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   748
        type = SDL_KEYUP;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   749
        break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   750
    default:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   751
        /* Invalid state -- bail */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   752
        return 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   753
    }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   754
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   755
    /* Drop events that don't change state */
4565
e2d46c5c7483 Fixed key repeat detection on X11, and simplified the code for everyone else.
Sam Lantinga <slouken@libsdl.org>
parents: 4562
diff changeset
   756
    repeat = (state && keyboard->keystate[scancode]);
4560
95352c671a6e Added support for keyboard repeat (only tested on Windows so far)
Sam Lantinga <slouken@libsdl.org>
parents: 4529
diff changeset
   757
    if (keyboard->keystate[scancode] == state && !repeat) {
1282
217f5d5a49e5 Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents: 1123
diff changeset
   758
#if 0
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   759
        printf("Keyboard event didn't change state - dropped!\n");
1282
217f5d5a49e5 Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents: 1123
diff changeset
   760
#endif
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   761
        return 0;
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   762
    }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   763
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   764
    /* Update internal keyboard state */
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   765
    keyboard->keystate[scancode] = state;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   766
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   767
    /* Post the event, if desired */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   768
    posted = 0;
4429
faa9fc8e7f67 General improvements for user custom event registration
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
   769
    if (SDL_GetEventState(type) == SDL_ENABLE) {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   770
        SDL_Event event;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   771
        event.key.type = type;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   772
        event.key.state = state;
4565
e2d46c5c7483 Fixed key repeat detection on X11, and simplified the code for everyone else.
Sam Lantinga <slouken@libsdl.org>
parents: 4562
diff changeset
   773
        event.key.repeat = repeat;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   774
        event.key.keysym.scancode = scancode;
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   775
        event.key.keysym.sym = keyboard->keymap[scancode];
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   776
        event.key.keysym.mod = modstate;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   777
        event.key.keysym.unicode = 0;
4437
25e45611fa3d Fix a crash caused by empty keyboard focus
Jjgod Jiang <gzjjgod@gmail.com>
parents: 4435
diff changeset
   778
        event.key.windowID = keyboard->focus ? keyboard->focus->id : 0;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   779
        posted = (SDL_PushEvent(&event) > 0);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   780
    }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   781
    return (posted);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   782
}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   783
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   784
int
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4437
diff changeset
   785
SDL_SendKeyboardText(const char *text)
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   786
{
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4437
diff changeset
   787
    SDL_Keyboard *keyboard = &SDL_keyboard;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   788
    int posted;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   789
4529
05ab4141ce93 Fixed bug 1014
Sam Lantinga <slouken@libsdl.org>
parents: 4490
diff changeset
   790
    /* Don't post text events for unprintable characters */
4567
1d7ea8724f4a Daniel Wyatt to slouken
Sam Lantinga <slouken@libsdl.org>
parents: 4565
diff changeset
   791
    if ((unsigned char)*text < ' ' || *text == 127) {
4529
05ab4141ce93 Fixed bug 1014
Sam Lantinga <slouken@libsdl.org>
parents: 4490
diff changeset
   792
        return 0;
05ab4141ce93 Fixed bug 1014
Sam Lantinga <slouken@libsdl.org>
parents: 4490
diff changeset
   793
    }
05ab4141ce93 Fixed bug 1014
Sam Lantinga <slouken@libsdl.org>
parents: 4490
diff changeset
   794
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   795
    /* Post the event, if desired */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   796
    posted = 0;
4429
faa9fc8e7f67 General improvements for user custom event registration
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
   797
    if (SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE) {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   798
        SDL_Event event;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   799
        event.text.type = SDL_TEXTINPUT;
4435
e953700da4ca Minor cleanup on Jiang's patch
Sam Lantinga <slouken@libsdl.org>
parents: 4434
diff changeset
   800
        event.text.windowID = keyboard->focus ? keyboard->focus->id : 0;
4754
2072fed2f583 Added SDL_utf8strlcpy to copy at UTF-8 character boundaries.
dewyatt
parents: 4753
diff changeset
   801
        SDL_utf8strlcpy(event.text.text, text, SDL_arraysize(event.text.text));
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   802
        posted = (SDL_PushEvent(&event) > 0);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   803
    }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
   804
    return (posted);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   805
}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   806
3280
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents: 3162
diff changeset
   807
int
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4437
diff changeset
   808
SDL_SendEditingText(const char *text, int start, int length)
3280
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents: 3162
diff changeset
   809
{
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4437
diff changeset
   810
    SDL_Keyboard *keyboard = &SDL_keyboard;
3280
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents: 3162
diff changeset
   811
    int posted;
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents: 3162
diff changeset
   812
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents: 3162
diff changeset
   813
    /* Post the event, if desired */
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents: 3162
diff changeset
   814
    posted = 0;
4429
faa9fc8e7f67 General improvements for user custom event registration
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
   815
    if (SDL_GetEventState(SDL_TEXTEDITING) == SDL_ENABLE) {
3280
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents: 3162
diff changeset
   816
        SDL_Event event;
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents: 3162
diff changeset
   817
        event.edit.type = SDL_TEXTEDITING;
4435
e953700da4ca Minor cleanup on Jiang's patch
Sam Lantinga <slouken@libsdl.org>
parents: 4434
diff changeset
   818
        event.edit.windowID = keyboard->focus ? keyboard->focus->id : 0;
3280
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents: 3162
diff changeset
   819
        event.edit.start = start;
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents: 3162
diff changeset
   820
        event.edit.length = length;
4754
2072fed2f583 Added SDL_utf8strlcpy to copy at UTF-8 character boundaries.
dewyatt
parents: 4753
diff changeset
   821
        SDL_utf8strlcpy(event.edit.text, text, SDL_arraysize(event.edit.text));
3280
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents: 3162
diff changeset
   822
        posted = (SDL_PushEvent(&event) > 0);
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents: 3162
diff changeset
   823
    }
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents: 3162
diff changeset
   824
    return (posted);
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents: 3162
diff changeset
   825
}
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents: 3162
diff changeset
   826
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   827
void
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   828
SDL_KeyboardQuit(void)
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   829
{
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   830
}
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   831
7258
89d47188c9a4 Fixed bug 1882 - SDL_GetKeyboardState should return const.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   832
const Uint8 *
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   833
SDL_GetKeyboardState(int *numkeys)
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   834
{
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4437
diff changeset
   835
    SDL_Keyboard *keyboard = &SDL_keyboard;
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   836
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   837
    if (numkeys != (int *) 0) {
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   838
        *numkeys = SDL_NUM_SCANCODES;
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   839
    }
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   840
    return keyboard->keystate;
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   841
}
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   842
5220
1fbe1c202501 Renamed SDL_Key to SDL_Keycode to clarify terminology.
Sam Lantinga <slouken@libsdl.org>
parents: 5219
diff changeset
   843
SDL_Keymod
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   844
SDL_GetModState(void)
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   845
{
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4437
diff changeset
   846
    SDL_Keyboard *keyboard = &SDL_keyboard;
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   847
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   848
    return keyboard->modstate;
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   849
}
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   850
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   851
void
5220
1fbe1c202501 Renamed SDL_Key to SDL_Keycode to clarify terminology.
Sam Lantinga <slouken@libsdl.org>
parents: 5219
diff changeset
   852
SDL_SetModState(SDL_Keymod modstate)
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   853
{
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4437
diff changeset
   854
    SDL_Keyboard *keyboard = &SDL_keyboard;
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   855
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   856
    keyboard->modstate = modstate;
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   857
}
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   858
5220
1fbe1c202501 Renamed SDL_Key to SDL_Keycode to clarify terminology.
Sam Lantinga <slouken@libsdl.org>
parents: 5219
diff changeset
   859
SDL_Keycode
5218
572a73d71b5f Sheena pointed out that "scancode" and "keysym" are single words and shouldn't be camel-cased.
Sam Lantinga <slouken@libsdl.org>
parents: 5123
diff changeset
   860
SDL_GetKeyFromScancode(SDL_Scancode scancode)
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   861
{
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4437
diff changeset
   862
    SDL_Keyboard *keyboard = &SDL_keyboard;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
   863
6983
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6885
diff changeset
   864
    if (scancode < SDL_SCANCODE_UNKNOWN || scancode >= SDL_NUM_SCANCODES) {
6813
b21879e67db2 Add input validation to SDL_GetKeyFromScancode; fix compiler warning in testautomation driver on Linux; update keyboard test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6811
diff changeset
   865
          SDL_InvalidParamError("scancode");
b21879e67db2 Add input validation to SDL_GetKeyFromScancode; fix compiler warning in testautomation driver on Linux; update keyboard test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6811
diff changeset
   866
          return 0;
b21879e67db2 Add input validation to SDL_GetKeyFromScancode; fix compiler warning in testautomation driver on Linux; update keyboard test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6811
diff changeset
   867
    }
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   868
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   869
    return keyboard->keymap[scancode];
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   870
}
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   871
5218
572a73d71b5f Sheena pointed out that "scancode" and "keysym" are single words and shouldn't be camel-cased.
Sam Lantinga <slouken@libsdl.org>
parents: 5123
diff changeset
   872
SDL_Scancode
5220
1fbe1c202501 Renamed SDL_Key to SDL_Keycode to clarify terminology.
Sam Lantinga <slouken@libsdl.org>
parents: 5219
diff changeset
   873
SDL_GetScancodeFromKey(SDL_Keycode key)
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   874
{
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4437
diff changeset
   875
    SDL_Keyboard *keyboard = &SDL_keyboard;
5218
572a73d71b5f Sheena pointed out that "scancode" and "keysym" are single words and shouldn't be camel-cased.
Sam Lantinga <slouken@libsdl.org>
parents: 5123
diff changeset
   876
    SDL_Scancode scancode;
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   877
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   878
    for (scancode = SDL_SCANCODE_UNKNOWN; scancode < SDL_NUM_SCANCODES;
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   879
         ++scancode) {
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   880
        if (keyboard->keymap[scancode] == key) {
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   881
            return scancode;
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   882
        }
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   883
    }
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   884
    return SDL_SCANCODE_UNKNOWN;
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   885
}
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   886
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   887
const char *
5218
572a73d71b5f Sheena pointed out that "scancode" and "keysym" are single words and shouldn't be camel-cased.
Sam Lantinga <slouken@libsdl.org>
parents: 5123
diff changeset
   888
SDL_GetScancodeName(SDL_Scancode scancode)
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   889
{
6983
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6885
diff changeset
   890
    const char *name;
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6885
diff changeset
   891
    if (scancode < SDL_SCANCODE_UNKNOWN || scancode >= SDL_NUM_SCANCODES) {
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6885
diff changeset
   892
          SDL_InvalidParamError("scancode");
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
   893
          return "";
6983
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6885
diff changeset
   894
    }
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   895
6983
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6885
diff changeset
   896
    name = SDL_scancode_names[scancode];
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   897
    if (name)
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   898
        return name;
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   899
    else
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   900
        return "";
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   901
}
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   902
6029
4a8bbaa52b9b Added SDL_GetScancodeFromName() and SDL_GetKeyFromName()
Sam Lantinga <slouken@libsdl.org>
parents: 5535
diff changeset
   903
SDL_Scancode SDL_GetScancodeFromName(const char *name)
4a8bbaa52b9b Added SDL_GetScancodeFromName() and SDL_GetKeyFromName()
Sam Lantinga <slouken@libsdl.org>
parents: 5535
diff changeset
   904
{
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
   905
    int i;
6029
4a8bbaa52b9b Added SDL_GetScancodeFromName() and SDL_GetKeyFromName()
Sam Lantinga <slouken@libsdl.org>
parents: 5535
diff changeset
   906
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
   907
    if (!name || !*name) {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
   908
            SDL_InvalidParamError("name");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
   909
        return SDL_SCANCODE_UNKNOWN;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
   910
    }
6029
4a8bbaa52b9b Added SDL_GetScancodeFromName() and SDL_GetKeyFromName()
Sam Lantinga <slouken@libsdl.org>
parents: 5535
diff changeset
   911
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
   912
    for (i = 0; i < SDL_arraysize(SDL_scancode_names); ++i) {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
   913
        if (!SDL_scancode_names[i]) {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
   914
            continue;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
   915
        }
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
   916
        if (SDL_strcasecmp(name, SDL_scancode_names[i]) == 0) {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
   917
            return (SDL_Scancode)i;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
   918
        }
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
   919
    }
6811
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   920
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
   921
    SDL_InvalidParamError("name");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
   922
    return SDL_SCANCODE_UNKNOWN;
6029
4a8bbaa52b9b Added SDL_GetScancodeFromName() and SDL_GetKeyFromName()
Sam Lantinga <slouken@libsdl.org>
parents: 5535
diff changeset
   923
}
4a8bbaa52b9b Added SDL_GetScancodeFromName() and SDL_GetKeyFromName()
Sam Lantinga <slouken@libsdl.org>
parents: 5535
diff changeset
   924
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   925
const char *
5220
1fbe1c202501 Renamed SDL_Key to SDL_Keycode to clarify terminology.
Sam Lantinga <slouken@libsdl.org>
parents: 5219
diff changeset
   926
SDL_GetKeyName(SDL_Keycode key)
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   927
{
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   928
    static char name[8];
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   929
    char *end;
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   930
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   931
    if (key & SDLK_SCANCODE_MASK) {
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   932
        return
5218
572a73d71b5f Sheena pointed out that "scancode" and "keysym" are single words and shouldn't be camel-cased.
Sam Lantinga <slouken@libsdl.org>
parents: 5123
diff changeset
   933
            SDL_GetScancodeName((SDL_Scancode) (key & ~SDLK_SCANCODE_MASK));
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   934
    }
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   935
2989
aba5a5cc2e63 Make the SDL keysyms that represent unprintable ASCII values actually have
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
   936
    switch (key) {
aba5a5cc2e63 Make the SDL keysyms that represent unprintable ASCII values actually have
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
   937
    case SDLK_RETURN:
2990
Sam Lantinga <slouken@libsdl.org>
parents: 2989
diff changeset
   938
        return SDL_GetScancodeName(SDL_SCANCODE_RETURN);
2989
aba5a5cc2e63 Make the SDL keysyms that represent unprintable ASCII values actually have
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
   939
    case SDLK_ESCAPE:
2990
Sam Lantinga <slouken@libsdl.org>
parents: 2989
diff changeset
   940
        return SDL_GetScancodeName(SDL_SCANCODE_ESCAPE);
2989
aba5a5cc2e63 Make the SDL keysyms that represent unprintable ASCII values actually have
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
   941
    case SDLK_BACKSPACE:
2990
Sam Lantinga <slouken@libsdl.org>
parents: 2989
diff changeset
   942
        return SDL_GetScancodeName(SDL_SCANCODE_BACKSPACE);
2989
aba5a5cc2e63 Make the SDL keysyms that represent unprintable ASCII values actually have
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
   943
    case SDLK_TAB:
2990
Sam Lantinga <slouken@libsdl.org>
parents: 2989
diff changeset
   944
        return SDL_GetScancodeName(SDL_SCANCODE_TAB);
2989
aba5a5cc2e63 Make the SDL keysyms that represent unprintable ASCII values actually have
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
   945
    case SDLK_SPACE:
2990
Sam Lantinga <slouken@libsdl.org>
parents: 2989
diff changeset
   946
        return SDL_GetScancodeName(SDL_SCANCODE_SPACE);
2989
aba5a5cc2e63 Make the SDL keysyms that represent unprintable ASCII values actually have
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
   947
    case SDLK_DELETE:
2990
Sam Lantinga <slouken@libsdl.org>
parents: 2989
diff changeset
   948
        return SDL_GetScancodeName(SDL_SCANCODE_DELETE);
2989
aba5a5cc2e63 Make the SDL keysyms that represent unprintable ASCII values actually have
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
   949
    default:
aba5a5cc2e63 Make the SDL keysyms that represent unprintable ASCII values actually have
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
   950
        /* Unaccented letter keys on latin keyboards are normally
aba5a5cc2e63 Make the SDL keysyms that represent unprintable ASCII values actually have
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
   951
           labeled in upper case (and probably on others like Greek or
aba5a5cc2e63 Make the SDL keysyms that represent unprintable ASCII values actually have
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
   952
           Cyrillic too, so if you happen to know for sure, please
aba5a5cc2e63 Make the SDL keysyms that represent unprintable ASCII values actually have
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
   953
           adapt this). */
aba5a5cc2e63 Make the SDL keysyms that represent unprintable ASCII values actually have
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
   954
        if (key >= 'a' && key <= 'z') {
aba5a5cc2e63 Make the SDL keysyms that represent unprintable ASCII values actually have
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
   955
            key -= 32;
aba5a5cc2e63 Make the SDL keysyms that represent unprintable ASCII values actually have
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
   956
        }
aba5a5cc2e63 Make the SDL keysyms that represent unprintable ASCII values actually have
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
   957
aba5a5cc2e63 Make the SDL keysyms that represent unprintable ASCII values actually have
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
   958
        end = SDL_UCS4ToUTF8((Uint32) key, name);
aba5a5cc2e63 Make the SDL keysyms that represent unprintable ASCII values actually have
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
   959
        *end = '\0';
aba5a5cc2e63 Make the SDL keysyms that represent unprintable ASCII values actually have
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
   960
        return name;
2303
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   961
    }
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   962
}
d87417504c75 First pass implementation of new SDL scancode concept, as discussed with
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
   963
6029
4a8bbaa52b9b Added SDL_GetScancodeFromName() and SDL_GetKeyFromName()
Sam Lantinga <slouken@libsdl.org>
parents: 5535
diff changeset
   964
SDL_Keycode
4a8bbaa52b9b Added SDL_GetScancodeFromName() and SDL_GetKeyFromName()
Sam Lantinga <slouken@libsdl.org>
parents: 5535
diff changeset
   965
SDL_GetKeyFromName(const char *name)
4a8bbaa52b9b Added SDL_GetScancodeFromName() and SDL_GetKeyFromName()
Sam Lantinga <slouken@libsdl.org>
parents: 5535
diff changeset
   966
{
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
   967
    SDL_Keycode key;
6029
4a8bbaa52b9b Added SDL_GetScancodeFromName() and SDL_GetKeyFromName()
Sam Lantinga <slouken@libsdl.org>
parents: 5535
diff changeset
   968
6803
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6665
diff changeset
   969
        /* Check input */
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6665
diff changeset
   970
        if (name == NULL) return SDLK_UNKNOWN;
6029
4a8bbaa52b9b Added SDL_GetScancodeFromName() and SDL_GetKeyFromName()
Sam Lantinga <slouken@libsdl.org>
parents: 5535
diff changeset
   971
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
   972
    /* If it's a single UTF-8 character, then that's the keycode itself */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
   973
    key = *(const unsigned char *)name;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
   974
    if (key >= 0xF0) {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
   975
        if (SDL_strlen(name) == 4) {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
   976
            int i = 0;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
   977
            key  = (Uint16)(name[i]&0x07) << 18;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
   978
            key |= (Uint16)(name[++i]&0x3F) << 12;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
   979
            key |= (Uint16)(name[++i]&0x3F) << 6;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
   980
            key |= (Uint16)(name[++i]&0x3F);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
   981
            return key;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
   982
        }
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
   983
        return SDLK_UNKNOWN;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
   984
    } else if (key >= 0xE0) {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
   985
        if (SDL_strlen(name) == 3) {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
   986
            int i = 0;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
   987
            key  = (Uint16)(name[i]&0x0F) << 12;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
   988
            key |= (Uint16)(name[++i]&0x3F) << 6;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
   989
            key |= (Uint16)(name[++i]&0x3F);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
   990
            return key;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
   991
        }
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
   992
        return SDLK_UNKNOWN;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
   993
    } else if (key >= 0xC0) {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
   994
        if (SDL_strlen(name) == 2) {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
   995
            int i = 0;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
   996
            key  = (Uint16)(name[i]&0x1F) << 6;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
   997
            key |= (Uint16)(name[++i]&0x3F);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
   998
            return key;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
   999
        }
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
  1000
        return SDLK_UNKNOWN;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
  1001
    } else {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
  1002
        if (SDL_strlen(name) == 1) {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
  1003
            if (key >= 'A' && key <= 'Z') {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
  1004
                key += 32;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
  1005
            }
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
  1006
            return key;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
  1007
        }
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
  1008
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
  1009
        /* Get the scancode for this name, and the associated keycode */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
  1010
        return SDL_default_keymap[SDL_GetScancodeFromName(name)];
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6983
diff changeset
  1011
    }
6029
4a8bbaa52b9b Added SDL_GetScancodeFromName() and SDL_GetKeyFromName()
Sam Lantinga <slouken@libsdl.org>
parents: 5535
diff changeset
  1012
}
4a8bbaa52b9b Added SDL_GetScancodeFromName() and SDL_GetKeyFromName()
Sam Lantinga <slouken@libsdl.org>
parents: 5535
diff changeset
  1013
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
  1014
/* vi: set ts=4 sw=4 expandtab: */