src/events/scancodes_darwin.h
author Sam Lantinga <slouken@libsdl.org>
Mon, 22 Jun 2015 23:36:06 -0700
changeset 9776 952ff8a5076f
parent 9619 b94b6d0bff0f
child 9998 f67cf37e9cd4
permissions -rw-r--r--
Fixed bug 3030 - SDL_RecreateWindow fails to restore title, icon, etc.

Adam M.

It loses the title and icon when window recreation fails. For instance, this may happen when trying to create an OpenGL ES window on a system that doesn't support it. But at that point, the title and icon have already been lost.
slouken@2305
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@9619
     3
  Copyright (C) 1997-2015 Sam Lantinga <slouken@libsdl.org>
slouken@2305
     4
slouken@5535
     5
  This software is provided 'as-is', without any express or implied
slouken@5535
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     7
  arising from the use of this software.
slouken@2305
     8
slouken@5535
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
    10
  including commercial applications, and to alter it and redistribute it
slouken@5535
    11
  freely, subject to the following restrictions:
slouken@2305
    12
slouken@5535
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@5535
    14
     claim that you wrote the original software. If you use this software
slouken@5535
    15
     in a product, an acknowledgment in the product documentation would be
slouken@5535
    16
     appreciated but is not required.
slouken@5535
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@5535
    18
     misrepresented as being the original software.
slouken@5535
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@2305
    20
*/
slouken@2305
    21
slouken@2308
    22
/* Mac virtual key code to SDL scancode mapping table
slouken@2305
    23
   Sources:
slouken@2305
    24
   - Inside Macintosh: Text <http://developer.apple.com/documentation/mac/Text/Text-571.html>
slouken@2305
    25
   - Apple USB keyboard driver source <http://darwinsource.opendarwin.org/10.4.6.ppc/IOHIDFamily-172.8/IOHIDFamily/Cosmo_USB2ADB.c>
slouken@2305
    26
   - experimentation on various ADB and USB ISO keyboards and one ADB ANSI keyboard
slouken@2305
    27
*/
slouken@2305
    28
/* *INDENT-OFF* */
slouken@5218
    29
static const SDL_Scancode darwin_scancode_table[] = {
slouken@2305
    30
    /*   0 */   SDL_SCANCODE_A,
slouken@2305
    31
    /*   1 */   SDL_SCANCODE_S,
slouken@2305
    32
    /*   2 */   SDL_SCANCODE_D,
slouken@2305
    33
    /*   3 */   SDL_SCANCODE_F,
slouken@2305
    34
    /*   4 */   SDL_SCANCODE_H,
slouken@2305
    35
    /*   5 */   SDL_SCANCODE_G,
slouken@2305
    36
    /*   6 */   SDL_SCANCODE_Z,
slouken@2305
    37
    /*   7 */   SDL_SCANCODE_X,
slouken@2305
    38
    /*   8 */   SDL_SCANCODE_C,
slouken@2305
    39
    /*   9 */   SDL_SCANCODE_V,
slouken@2305
    40
    /*  10 */   SDL_SCANCODE_NONUSBACKSLASH, /* SDL_SCANCODE_NONUSBACKSLASH on ANSI and JIS keyboards (if this key would exist there), SDL_SCANCODE_GRAVE on ISO. (The USB keyboard driver actually translates these usage codes to different virtual key codes depending on whether the keyboard is ISO/ANSI/JIS. That's why you have to help it identify the keyboard type when you plug in a PC USB keyboard. It's a historical thing - ADB keyboards are wired this way.) */
slouken@2305
    41
    /*  11 */   SDL_SCANCODE_B,
slouken@2305
    42
    /*  12 */   SDL_SCANCODE_Q,
slouken@2305
    43
    /*  13 */   SDL_SCANCODE_W,
slouken@2305
    44
    /*  14 */   SDL_SCANCODE_E,
slouken@2305
    45
    /*  15 */   SDL_SCANCODE_R,
slouken@2305
    46
    /*  16 */   SDL_SCANCODE_Y,
slouken@2305
    47
    /*  17 */   SDL_SCANCODE_T,
slouken@2305
    48
    /*  18 */   SDL_SCANCODE_1,
slouken@2305
    49
    /*  19 */   SDL_SCANCODE_2,
slouken@2305
    50
    /*  20 */   SDL_SCANCODE_3,
slouken@2305
    51
    /*  21 */   SDL_SCANCODE_4,
slouken@2305
    52
    /*  22 */   SDL_SCANCODE_6,
slouken@2305
    53
    /*  23 */   SDL_SCANCODE_5,
slouken@2305
    54
    /*  24 */   SDL_SCANCODE_EQUALS,
slouken@2305
    55
    /*  25 */   SDL_SCANCODE_9,
slouken@2305
    56
    /*  26 */   SDL_SCANCODE_7,
slouken@2305
    57
    /*  27 */   SDL_SCANCODE_MINUS,
slouken@2305
    58
    /*  28 */   SDL_SCANCODE_8,
slouken@2305
    59
    /*  29 */   SDL_SCANCODE_0,
slouken@2305
    60
    /*  30 */   SDL_SCANCODE_RIGHTBRACKET,
slouken@2305
    61
    /*  31 */   SDL_SCANCODE_O,
slouken@2305
    62
    /*  32 */   SDL_SCANCODE_U,
slouken@2305
    63
    /*  33 */   SDL_SCANCODE_LEFTBRACKET,
slouken@2305
    64
    /*  34 */   SDL_SCANCODE_I,
slouken@2305
    65
    /*  35 */   SDL_SCANCODE_P,
slouken@2305
    66
    /*  36 */   SDL_SCANCODE_RETURN,
slouken@2305
    67
    /*  37 */   SDL_SCANCODE_L,
slouken@2305
    68
    /*  38 */   SDL_SCANCODE_J,
slouken@2305
    69
    /*  39 */   SDL_SCANCODE_APOSTROPHE,
slouken@2305
    70
    /*  40 */   SDL_SCANCODE_K,
slouken@2305
    71
    /*  41 */   SDL_SCANCODE_SEMICOLON,
slouken@2305
    72
    /*  42 */   SDL_SCANCODE_BACKSLASH,
slouken@2305
    73
    /*  43 */   SDL_SCANCODE_COMMA,
slouken@2305
    74
    /*  44 */   SDL_SCANCODE_SLASH,
slouken@2305
    75
    /*  45 */   SDL_SCANCODE_N,
slouken@2305
    76
    /*  46 */   SDL_SCANCODE_M,
slouken@2305
    77
    /*  47 */   SDL_SCANCODE_PERIOD,
slouken@2305
    78
    /*  48 */   SDL_SCANCODE_TAB,
slouken@2305
    79
    /*  49 */   SDL_SCANCODE_SPACE,
slouken@2305
    80
    /*  50 */   SDL_SCANCODE_GRAVE, /* SDL_SCANCODE_GRAVE on ANSI and JIS keyboards, SDL_SCANCODE_NONUSBACKSLASH on ISO (see comment about virtual key code 10 above) */
slouken@2305
    81
    /*  51 */   SDL_SCANCODE_BACKSPACE,
slouken@2305
    82
    /*  52 */   SDL_SCANCODE_KP_ENTER, /* keyboard enter on portables */
slouken@2305
    83
    /*  53 */   SDL_SCANCODE_ESCAPE,
slouken@2305
    84
    /*  54 */   SDL_SCANCODE_RGUI,
slouken@2305
    85
    /*  55 */   SDL_SCANCODE_LGUI,
slouken@2305
    86
    /*  56 */   SDL_SCANCODE_LSHIFT,
slouken@2305
    87
    /*  57 */   SDL_SCANCODE_CAPSLOCK,
slouken@2305
    88
    /*  58 */   SDL_SCANCODE_LALT,
slouken@2305
    89
    /*  59 */   SDL_SCANCODE_LCTRL,
slouken@2305
    90
    /*  60 */   SDL_SCANCODE_RSHIFT,
slouken@2305
    91
    /*  61 */   SDL_SCANCODE_RALT,
slouken@2305
    92
    /*  62 */   SDL_SCANCODE_RCTRL,
slouken@2305
    93
    /*  63 */   SDL_SCANCODE_RGUI, /* fn on portables, acts as a hardware-level modifier already, so we don't generate events for it, also XK_Meta_R */
slouken@7579
    94
    /*  64 */   SDL_SCANCODE_F17,
slouken@2305
    95
    /*  65 */   SDL_SCANCODE_KP_PERIOD,
slouken@2305
    96
    /*  66 */   SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
slouken@2305
    97
    /*  67 */   SDL_SCANCODE_KP_MULTIPLY,
slouken@2305
    98
    /*  68 */   SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
slouken@2305
    99
    /*  69 */   SDL_SCANCODE_KP_PLUS,
slouken@2305
   100
    /*  70 */   SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
slouken@2305
   101
    /*  71 */   SDL_SCANCODE_NUMLOCKCLEAR,
slouken@2305
   102
    /*  72 */   SDL_SCANCODE_VOLUMEUP,
slouken@2305
   103
    /*  73 */   SDL_SCANCODE_VOLUMEDOWN,
slouken@2305
   104
    /*  74 */   SDL_SCANCODE_MUTE,
slouken@2305
   105
    /*  75 */   SDL_SCANCODE_KP_DIVIDE,
slouken@2305
   106
    /*  76 */   SDL_SCANCODE_KP_ENTER, /* keypad enter on external keyboards, fn-return on portables */
slouken@2305
   107
    /*  77 */   SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
slouken@2305
   108
    /*  78 */   SDL_SCANCODE_KP_MINUS,
slouken@7579
   109
    /*  79 */   SDL_SCANCODE_F18,
slouken@7579
   110
    /*  80 */   SDL_SCANCODE_F19,
slouken@2305
   111
    /*  81 */   SDL_SCANCODE_KP_EQUALS,
slouken@2305
   112
    /*  82 */   SDL_SCANCODE_KP_0,
slouken@2305
   113
    /*  83 */   SDL_SCANCODE_KP_1,
slouken@2305
   114
    /*  84 */   SDL_SCANCODE_KP_2,
slouken@2305
   115
    /*  85 */   SDL_SCANCODE_KP_3,
slouken@2305
   116
    /*  86 */   SDL_SCANCODE_KP_4,
slouken@2305
   117
    /*  87 */   SDL_SCANCODE_KP_5,
slouken@2305
   118
    /*  88 */   SDL_SCANCODE_KP_6,
slouken@2305
   119
    /*  89 */   SDL_SCANCODE_KP_7,
slouken@2305
   120
    /*  90 */   SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
slouken@2305
   121
    /*  91 */   SDL_SCANCODE_KP_8,
slouken@2305
   122
    /*  92 */   SDL_SCANCODE_KP_9,
slouken@2305
   123
    /*  93 */   SDL_SCANCODE_INTERNATIONAL3, /* Cosmo_USB2ADB.c says "Yen (JIS)" */
slouken@2305
   124
    /*  94 */   SDL_SCANCODE_INTERNATIONAL1, /* Cosmo_USB2ADB.c says "Ro (JIS)" */
slouken@2305
   125
    /*  95 */   SDL_SCANCODE_KP_COMMA, /* Cosmo_USB2ADB.c says ", JIS only" */
slouken@2305
   126
    /*  96 */   SDL_SCANCODE_F5,
slouken@2305
   127
    /*  97 */   SDL_SCANCODE_F6,
slouken@2305
   128
    /*  98 */   SDL_SCANCODE_F7,
slouken@2305
   129
    /*  99 */   SDL_SCANCODE_F3,
slouken@2305
   130
    /* 100 */   SDL_SCANCODE_F8,
slouken@2305
   131
    /* 101 */   SDL_SCANCODE_F9,
slouken@2305
   132
    /* 102 */   SDL_SCANCODE_LANG2, /* Cosmo_USB2ADB.c says "Eisu" */
slouken@2305
   133
    /* 103 */   SDL_SCANCODE_F11,
slouken@2305
   134
    /* 104 */   SDL_SCANCODE_LANG1, /* Cosmo_USB2ADB.c says "Kana" */
slouken@2305
   135
    /* 105 */   SDL_SCANCODE_PRINTSCREEN, /* On ADB keyboards, this key is labeled "F13/print screen". Problem: USB has different usage codes for these two functions. On Apple USB keyboards, the key is labeled "F13" and sends the F13 usage code (SDL_SCANCODE_F13). I decided to use SDL_SCANCODE_PRINTSCREEN here nevertheless since SDL applications are more likely to assume the presence of a print screen key than an F13 key. */
slouken@2305
   136
    /* 106 */   SDL_SCANCODE_F16,
slouken@2305
   137
    /* 107 */   SDL_SCANCODE_SCROLLLOCK, /* F14/scroll lock, see comment about F13/print screen above */
slouken@2305
   138
    /* 108 */   SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
slouken@2305
   139
    /* 109 */   SDL_SCANCODE_F10,
slouken@2305
   140
    /* 110 */   SDL_SCANCODE_APPLICATION, /* windows contextual menu key, fn-enter on portables */
slouken@2305
   141
    /* 111 */   SDL_SCANCODE_F12,
slouken@2305
   142
    /* 112 */   SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
slouken@2305
   143
    /* 113 */   SDL_SCANCODE_PAUSE, /* F15/pause, see comment about F13/print screen above */
slouken@2305
   144
    /* 114 */   SDL_SCANCODE_INSERT, /* the key is actually labeled "help" on Apple keyboards, and works as such in Mac OS, but it sends the "insert" usage code even on Apple USB keyboards */
slouken@2305
   145
    /* 115 */   SDL_SCANCODE_HOME,
slouken@2305
   146
    /* 116 */   SDL_SCANCODE_PAGEUP,
slouken@2305
   147
    /* 117 */   SDL_SCANCODE_DELETE,
slouken@2305
   148
    /* 118 */   SDL_SCANCODE_F4,
slouken@2305
   149
    /* 119 */   SDL_SCANCODE_END,
slouken@2305
   150
    /* 120 */   SDL_SCANCODE_F2,
slouken@2305
   151
    /* 121 */   SDL_SCANCODE_PAGEDOWN,
slouken@2305
   152
    /* 122 */   SDL_SCANCODE_F1,
slouken@2305
   153
    /* 123 */   SDL_SCANCODE_LEFT,
slouken@2305
   154
    /* 124 */   SDL_SCANCODE_RIGHT,
slouken@2305
   155
    /* 125 */   SDL_SCANCODE_DOWN,
slouken@2305
   156
    /* 126 */   SDL_SCANCODE_UP,
slouken@2305
   157
    /* 127 */   SDL_SCANCODE_POWER
slouken@2305
   158
};
slouken@2305
   159
/* *INDENT-ON* */