src/video/nacl/SDL_naclevents.c
author Ryan C. Gordon <icculus@icculus.org>
Mon, 06 Apr 2015 00:10:54 -0400
changeset 9458 543298b36b28
parent 9332 e29fec41a2c6
child 9619 b94b6d0bff0f
permissions -rw-r--r--
This function can be static.
gabomdq@8833
     1
/*
gabomdq@8833
     2
  Simple DirectMedia Layer
gabomdq@8833
     3
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
gabomdq@8833
     4
gabomdq@8833
     5
  This software is provided 'as-is', without any express or implied
gabomdq@8833
     6
  warranty.  In no event will the authors be held liable for any damages
gabomdq@8833
     7
  arising from the use of this software.
gabomdq@8833
     8
gabomdq@8833
     9
  Permission is granted to anyone to use this software for any purpose,
gabomdq@8833
    10
  including commercial applications, and to alter it and redistribute it
gabomdq@8833
    11
  freely, subject to the following restrictions:
gabomdq@8833
    12
gabomdq@8833
    13
 1. The origin of this software must not be misrepresented; you must not
gabomdq@8833
    14
     claim that you wrote the original software. If you use this software
gabomdq@8833
    15
     in a product, an acknowledgment in the product documentation would be
gabomdq@8833
    16
     appreciated but is not required.
gabomdq@8833
    17
 2. Altered source versions must be plainly marked as such, and must not be
gabomdq@8833
    18
     misrepresented as being the original software.
gabomdq@8833
    19
 3. This notice may not be removed or altered from any source distribution.
gabomdq@8833
    20
*/
gabomdq@8833
    21
#include "../../SDL_internal.h"
gabomdq@8833
    22
philipp@9332
    23
#if SDL_VIDEO_DRIVER_NACL
philipp@9332
    24
gabomdq@8833
    25
#include "SDL.h"
gabomdq@8833
    26
#include "../../events/SDL_sysevents.h"
gabomdq@8833
    27
#include "../../events/SDL_events_c.h"
gabomdq@8833
    28
#include "SDL_naclevents_c.h"
gabomdq@8833
    29
#include "SDL_naclvideo.h"
gabomdq@8833
    30
#include "ppapi_simple/ps_event.h"
gabomdq@8833
    31
gabomdq@8833
    32
/* Ref: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent */
gabomdq@8833
    33
gabomdq@8833
    34
static SDL_Scancode NACL_Keycodes[] = {
gabomdq@8833
    35
    SDL_SCANCODE_UNKNOWN,               /* 0 */
gabomdq@8833
    36
    SDL_SCANCODE_UNKNOWN,               /* 1 */
gabomdq@8833
    37
    SDL_SCANCODE_UNKNOWN,               /* 2 */
gabomdq@8833
    38
    SDL_SCANCODE_CANCEL,                /* DOM_VK_CANCEL 3 */
gabomdq@8833
    39
    SDL_SCANCODE_UNKNOWN,               /* 4 */
gabomdq@8833
    40
    SDL_SCANCODE_UNKNOWN,               /* 5 */
gabomdq@8833
    41
    SDL_SCANCODE_HELP,                  /* DOM_VK_HELP 6 */
gabomdq@8833
    42
    SDL_SCANCODE_UNKNOWN,               /* 7 */
gabomdq@8833
    43
    SDL_SCANCODE_BACKSPACE,             /* DOM_VK_BACK_SPACE 8 */
gabomdq@8833
    44
    SDL_SCANCODE_TAB,                   /* DOM_VK_TAB 9 */
gabomdq@8833
    45
    SDL_SCANCODE_UNKNOWN,               /* 10 */
gabomdq@8833
    46
    SDL_SCANCODE_UNKNOWN,               /* 11 */
gabomdq@8833
    47
    SDL_SCANCODE_CLEAR,                 /* DOM_VK_CLEAR 12 */
gabomdq@8833
    48
    SDL_SCANCODE_RETURN,                /* DOM_VK_RETURN 13 */
gabomdq@8833
    49
    SDL_SCANCODE_RETURN,                /* DOM_VK_ENTER 14 */
gabomdq@8833
    50
    SDL_SCANCODE_UNKNOWN,               /* 15 */
gabomdq@8833
    51
    SDL_SCANCODE_LSHIFT,                /* DOM_VK_SHIFT 16 */
gabomdq@8833
    52
    SDL_SCANCODE_LCTRL,                 /* DOM_VK_CONTROL 17 */
gabomdq@8833
    53
    SDL_SCANCODE_LALT,                  /* DOM_VK_ALT 18 */
gabomdq@8833
    54
    SDL_SCANCODE_UNKNOWN,               /* DOM_VK_PAUSE 19 */
gabomdq@8833
    55
    SDL_SCANCODE_CAPSLOCK,              /* DOM_VK_CAPS_LOCK 20 */
gabomdq@8833
    56
    SDL_SCANCODE_LANG1,                 /* DOM_VK_KANA  DOM_VK_HANGUL 21 */
gabomdq@8833
    57
    SDL_SCANCODE_UNKNOWN,               /* DOM_VK_EISU 22 */
gabomdq@8833
    58
    SDL_SCANCODE_UNKNOWN,               /* DOM_VK_JUNJA 23 */
gabomdq@8833
    59
    SDL_SCANCODE_UNKNOWN,               /* DOM_VK_FINAL 24 */
gabomdq@8833
    60
    SDL_SCANCODE_LANG2,                 /* DOM_VK_HANJA  DOM_VK_KANJI 25 */
gabomdq@8833
    61
    SDL_SCANCODE_UNKNOWN,               /* 26 */
gabomdq@8833
    62
    SDL_SCANCODE_ESCAPE,                /* DOM_VK_ESCAPE 27 */
gabomdq@8833
    63
    SDL_SCANCODE_UNKNOWN,               /* DOM_VK_CONVERT 28 */
gabomdq@8833
    64
    SDL_SCANCODE_UNKNOWN,               /* DOM_VK_NONCONVERT 29 */
gabomdq@8833
    65
    SDL_SCANCODE_UNKNOWN,               /* DOM_VK_ACCEPT 30 */
gabomdq@8833
    66
    SDL_SCANCODE_MODE,                  /* DOM_VK_MODECHANGE 31 */
gabomdq@8833
    67
    SDL_SCANCODE_SPACE,                 /* DOM_VK_SPACE 32 */
gabomdq@8833
    68
    SDL_SCANCODE_PAGEUP,                /* DOM_VK_PAGE_UP 33 */
gabomdq@8833
    69
    SDL_SCANCODE_PAGEDOWN,              /* DOM_VK_PAGE_DOWN 34 */
gabomdq@8833
    70
    SDL_SCANCODE_END,                   /* DOM_VK_END 35 */
gabomdq@8833
    71
    SDL_SCANCODE_HOME,                  /* DOM_VK_HOME 36 */
gabomdq@8833
    72
    SDL_SCANCODE_LEFT,                  /* DOM_VK_LEFT 37 */
gabomdq@8833
    73
    SDL_SCANCODE_UP,                    /* DOM_VK_UP 38 */
gabomdq@8833
    74
    SDL_SCANCODE_RIGHT,                 /* DOM_VK_RIGHT 39 */
gabomdq@8833
    75
    SDL_SCANCODE_DOWN,                  /* DOM_VK_DOWN 40 */
gabomdq@8833
    76
    SDL_SCANCODE_SELECT,                /* DOM_VK_SELECT 41 */
gabomdq@8833
    77
    SDL_SCANCODE_UNKNOWN,               /* DOM_VK_PRINT 42 */
gabomdq@8833
    78
    SDL_SCANCODE_EXECUTE,               /* DOM_VK_EXECUTE 43 */
gabomdq@8833
    79
    SDL_SCANCODE_PRINTSCREEN,           /* DOM_VK_PRINTSCREEN 44 */
gabomdq@8833
    80
    SDL_SCANCODE_INSERT,                /* DOM_VK_INSERT 45 */
gabomdq@8833
    81
    SDL_SCANCODE_DELETE,                /* DOM_VK_DELETE 46 */
gabomdq@8833
    82
    SDL_SCANCODE_UNKNOWN,               /* 47 */
gabomdq@8833
    83
    SDL_SCANCODE_0,                     /* DOM_VK_0 48 */
gabomdq@8833
    84
    SDL_SCANCODE_1,                     /* DOM_VK_1 49 */
gabomdq@8833
    85
    SDL_SCANCODE_2,                     /* DOM_VK_2 50 */
gabomdq@8833
    86
    SDL_SCANCODE_3,                     /* DOM_VK_3 51 */
gabomdq@8833
    87
    SDL_SCANCODE_4,                     /* DOM_VK_4 52 */
gabomdq@8833
    88
    SDL_SCANCODE_5,                     /* DOM_VK_5 53 */
gabomdq@8833
    89
    SDL_SCANCODE_6,                     /* DOM_VK_6 54 */
gabomdq@8833
    90
    SDL_SCANCODE_7,                     /* DOM_VK_7 55 */
gabomdq@8833
    91
    SDL_SCANCODE_8,                     /* DOM_VK_8 56 */
gabomdq@8833
    92
    SDL_SCANCODE_9,                     /* DOM_VK_9 57 */
gabomdq@8833
    93
    SDL_SCANCODE_KP_COLON,              /* DOM_VK_COLON 58 */
gabomdq@8833
    94
    SDL_SCANCODE_SEMICOLON,             /* DOM_VK_SEMICOLON 59 */
gabomdq@8833
    95
    SDL_SCANCODE_KP_LESS,               /* DOM_VK_LESS_THAN 60 */
gabomdq@8833
    96
    SDL_SCANCODE_EQUALS,                /* DOM_VK_EQUALS 61 */
gabomdq@8833
    97
    SDL_SCANCODE_KP_GREATER,            /* DOM_VK_GREATER_THAN 62 */
gabomdq@8833
    98
    SDL_SCANCODE_UNKNOWN,               /* DOM_VK_QUESTION_MARK 63 */
gabomdq@8833
    99
    SDL_SCANCODE_KP_AT,                 /* DOM_VK_AT 64 */
gabomdq@8833
   100
    SDL_SCANCODE_A,                     /* DOM_VK_A 65 */
gabomdq@8833
   101
    SDL_SCANCODE_B,                     /* DOM_VK_B 66 */
gabomdq@8833
   102
    SDL_SCANCODE_C,                     /* DOM_VK_C 67 */
gabomdq@8833
   103
    SDL_SCANCODE_D,                     /* DOM_VK_D 68 */
gabomdq@8833
   104
    SDL_SCANCODE_E,                     /* DOM_VK_E 69 */
gabomdq@8833
   105
    SDL_SCANCODE_F,                     /* DOM_VK_F 70 */
gabomdq@8833
   106
    SDL_SCANCODE_G,                     /* DOM_VK_G 71 */
gabomdq@8833
   107
    SDL_SCANCODE_H,                     /* DOM_VK_H 72 */
gabomdq@8833
   108
    SDL_SCANCODE_I,                     /* DOM_VK_I 73 */
gabomdq@8833
   109
    SDL_SCANCODE_J,                     /* DOM_VK_J 74 */
gabomdq@8833
   110
    SDL_SCANCODE_K,                     /* DOM_VK_K 75 */
gabomdq@8833
   111
    SDL_SCANCODE_L,                     /* DOM_VK_L 76 */
gabomdq@8833
   112
    SDL_SCANCODE_M,                     /* DOM_VK_M 77 */
gabomdq@8833
   113
    SDL_SCANCODE_N,                     /* DOM_VK_N 78 */
gabomdq@8833
   114
    SDL_SCANCODE_O,                     /* DOM_VK_O 79 */
gabomdq@8833
   115
    SDL_SCANCODE_P,                     /* DOM_VK_P 80 */
gabomdq@8833
   116
    SDL_SCANCODE_Q,                     /* DOM_VK_Q 81 */
gabomdq@8833
   117
    SDL_SCANCODE_R,                     /* DOM_VK_R 82 */
gabomdq@8833
   118
    SDL_SCANCODE_S,                     /* DOM_VK_S 83 */
gabomdq@8833
   119
    SDL_SCANCODE_T,                     /* DOM_VK_T 84 */
gabomdq@8833
   120
    SDL_SCANCODE_U,                     /* DOM_VK_U 85 */
gabomdq@8833
   121
    SDL_SCANCODE_V,                     /* DOM_VK_V 86 */
gabomdq@8833
   122
    SDL_SCANCODE_W,                     /* DOM_VK_W 87 */
gabomdq@8833
   123
    SDL_SCANCODE_X,                     /* DOM_VK_X 88 */
gabomdq@8833
   124
    SDL_SCANCODE_Y,                     /* DOM_VK_Y 89 */
gabomdq@8833
   125
    SDL_SCANCODE_Z,                     /* DOM_VK_Z 90 */
gabomdq@8833
   126
    SDL_SCANCODE_LGUI,                  /* DOM_VK_WIN 91 */
gabomdq@8833
   127
    SDL_SCANCODE_UNKNOWN,               /* 92 */
gabomdq@8833
   128
    SDL_SCANCODE_APPLICATION,           /* DOM_VK_CONTEXT_MENU 93 */
gabomdq@8833
   129
    SDL_SCANCODE_UNKNOWN,               /* 94 */
gabomdq@8833
   130
    SDL_SCANCODE_SLEEP,                 /* DOM_VK_SLEEP 95 */
gabomdq@8833
   131
    SDL_SCANCODE_KP_0,                  /* DOM_VK_NUMPAD0 96 */
gabomdq@8833
   132
    SDL_SCANCODE_KP_1,                  /* DOM_VK_NUMPAD1 97 */
gabomdq@8833
   133
    SDL_SCANCODE_KP_2,                  /* DOM_VK_NUMPAD2 98 */
gabomdq@8833
   134
    SDL_SCANCODE_KP_3,                  /* DOM_VK_NUMPAD3 99 */
gabomdq@8833
   135
    SDL_SCANCODE_KP_4,                  /* DOM_VK_NUMPAD4 100 */
gabomdq@8833
   136
    SDL_SCANCODE_KP_5,                  /* DOM_VK_NUMPAD5 101 */
gabomdq@8833
   137
    SDL_SCANCODE_KP_6,                  /* DOM_VK_NUMPAD6 102 */
gabomdq@8833
   138
    SDL_SCANCODE_KP_7,                  /* DOM_VK_NUMPAD7 103 */
gabomdq@8833
   139
    SDL_SCANCODE_KP_8,                  /* DOM_VK_NUMPAD8 104 */
gabomdq@8833
   140
    SDL_SCANCODE_KP_9,                  /* DOM_VK_NUMPAD9 105 */
gabomdq@8833
   141
    SDL_SCANCODE_KP_MULTIPLY,           /* DOM_VK_MULTIPLY 106 */
gabomdq@8833
   142
    SDL_SCANCODE_KP_PLUS,               /* DOM_VK_ADD 107 */
gabomdq@8833
   143
    SDL_SCANCODE_KP_COMMA,              /* DOM_VK_SEPARATOR 108 */
gabomdq@8833
   144
    SDL_SCANCODE_KP_MINUS,              /* DOM_VK_SUBTRACT 109 */
gabomdq@8833
   145
    SDL_SCANCODE_KP_PERIOD,             /* DOM_VK_DECIMAL 110 */
gabomdq@8833
   146
    SDL_SCANCODE_KP_DIVIDE,             /* DOM_VK_DIVIDE 111 */
gabomdq@8833
   147
    SDL_SCANCODE_F1,                    /* DOM_VK_F1 112 */
gabomdq@8833
   148
    SDL_SCANCODE_F2,                    /* DOM_VK_F2 113 */
gabomdq@8833
   149
    SDL_SCANCODE_F3,                    /* DOM_VK_F3 114 */
gabomdq@8833
   150
    SDL_SCANCODE_F4,                    /* DOM_VK_F4 115 */
gabomdq@8833
   151
    SDL_SCANCODE_F5,                    /* DOM_VK_F5 116 */
gabomdq@8833
   152
    SDL_SCANCODE_F6,                    /* DOM_VK_F6 117 */
gabomdq@8833
   153
    SDL_SCANCODE_F7,                    /* DOM_VK_F7 118 */
gabomdq@8833
   154
    SDL_SCANCODE_F8,                    /* DOM_VK_F8 119 */
gabomdq@8833
   155
    SDL_SCANCODE_F9,                    /* DOM_VK_F9 120 */
gabomdq@8833
   156
    SDL_SCANCODE_F10,                   /* DOM_VK_F10 121 */
gabomdq@8833
   157
    SDL_SCANCODE_F11,                   /* DOM_VK_F11 122 */
gabomdq@8833
   158
    SDL_SCANCODE_F12,                   /* DOM_VK_F12 123 */
gabomdq@8833
   159
    SDL_SCANCODE_F13,                   /* DOM_VK_F13 124 */
gabomdq@8833
   160
    SDL_SCANCODE_F14,                   /* DOM_VK_F14 125 */
gabomdq@8833
   161
    SDL_SCANCODE_F15,                   /* DOM_VK_F15 126 */
gabomdq@8833
   162
    SDL_SCANCODE_F16,                   /* DOM_VK_F16 127 */
gabomdq@8833
   163
    SDL_SCANCODE_F17,                   /* DOM_VK_F17 128 */
gabomdq@8833
   164
    SDL_SCANCODE_F18,                   /* DOM_VK_F18 129 */
gabomdq@8833
   165
    SDL_SCANCODE_F19,                   /* DOM_VK_F19 130 */
gabomdq@8833
   166
    SDL_SCANCODE_F20,                   /* DOM_VK_F20 131 */
gabomdq@8833
   167
    SDL_SCANCODE_F21,                   /* DOM_VK_F21 132 */
gabomdq@8833
   168
    SDL_SCANCODE_F22,                   /* DOM_VK_F22 133 */
gabomdq@8833
   169
    SDL_SCANCODE_F23,                   /* DOM_VK_F23 134 */
gabomdq@8833
   170
    SDL_SCANCODE_F24,                   /* DOM_VK_F24 135 */
gabomdq@8833
   171
    SDL_SCANCODE_UNKNOWN,               /* 136 */
gabomdq@8833
   172
    SDL_SCANCODE_UNKNOWN,               /* 137 */
gabomdq@8833
   173
    SDL_SCANCODE_UNKNOWN,               /* 138 */
gabomdq@8833
   174
    SDL_SCANCODE_UNKNOWN,               /* 139 */
gabomdq@8833
   175
    SDL_SCANCODE_UNKNOWN,               /* 140 */
gabomdq@8833
   176
    SDL_SCANCODE_UNKNOWN,               /* 141 */
gabomdq@8833
   177
    SDL_SCANCODE_UNKNOWN,               /* 142 */
gabomdq@8833
   178
    SDL_SCANCODE_UNKNOWN,               /* 143 */
gabomdq@8833
   179
    SDL_SCANCODE_NUMLOCKCLEAR,          /* DOM_VK_NUM_LOCK 144 */
gabomdq@8833
   180
    SDL_SCANCODE_SCROLLLOCK,            /* DOM_VK_SCROLL_LOCK 145 */
gabomdq@8833
   181
    SDL_SCANCODE_UNKNOWN,               /* DOM_VK_WIN_OEM_FJ_JISHO 146 */
gabomdq@8833
   182
    SDL_SCANCODE_UNKNOWN,               /* DOM_VK_WIN_OEM_FJ_MASSHOU 147 */
gabomdq@8833
   183
    SDL_SCANCODE_UNKNOWN,               /* DOM_VK_WIN_OEM_FJ_TOUROKU 148 */
gabomdq@8833
   184
    SDL_SCANCODE_UNKNOWN,               /* DOM_VK_WIN_OEM_FJ_LOYA 149 */
gabomdq@8833
   185
    SDL_SCANCODE_UNKNOWN,               /* DOM_VK_WIN_OEM_FJ_ROYA 150 */
gabomdq@8833
   186
    SDL_SCANCODE_UNKNOWN,               /* 151 */
gabomdq@8833
   187
    SDL_SCANCODE_UNKNOWN,               /* 152 */
gabomdq@8833
   188
    SDL_SCANCODE_UNKNOWN,               /* 153 */
gabomdq@8833
   189
    SDL_SCANCODE_UNKNOWN,               /* 154 */
gabomdq@8833
   190
    SDL_SCANCODE_UNKNOWN,               /* 155 */
gabomdq@8833
   191
    SDL_SCANCODE_UNKNOWN,               /* 156 */
gabomdq@8833
   192
    SDL_SCANCODE_UNKNOWN,               /* 157 */
gabomdq@8833
   193
    SDL_SCANCODE_UNKNOWN,               /* 158 */
gabomdq@8833
   194
    SDL_SCANCODE_UNKNOWN,               /* 159 */
gabomdq@8833
   195
    SDL_SCANCODE_GRAVE,                 /* DOM_VK_CIRCUMFLEX 160 */
gabomdq@8833
   196
    SDL_SCANCODE_KP_EXCLAM,             /* DOM_VK_EXCLAMATION 161 */
gabomdq@8833
   197
    SDL_SCANCODE_UNKNOWN,               /* DOM_VK_DOUBLE_QUOTE 162 */
gabomdq@8833
   198
    SDL_SCANCODE_KP_HASH,               /* DOM_VK_HASH 163 */
gabomdq@8833
   199
    SDL_SCANCODE_CURRENCYUNIT,          /* DOM_VK_DOLLAR 164 */
gabomdq@8833
   200
    SDL_SCANCODE_KP_PERCENT,            /* DOM_VK_PERCENT 165 */
gabomdq@8833
   201
    SDL_SCANCODE_KP_AMPERSAND,          /* DOM_VK_AMPERSAND 166 */
gabomdq@8833
   202
    SDL_SCANCODE_UNKNOWN,               /* DOM_VK_UNDERSCORE 167 */
gabomdq@8833
   203
    SDL_SCANCODE_KP_LEFTPAREN,          /* DOM_VK_OPEN_PAREN 168 */
gabomdq@8833
   204
    SDL_SCANCODE_KP_RIGHTPAREN,         /* DOM_VK_CLOSE_PAREN 169 */
gabomdq@8833
   205
    SDL_SCANCODE_KP_MULTIPLY,           /* DOM_VK_ASTERISK 170 */
gabomdq@8833
   206
    SDL_SCANCODE_KP_PLUS,               /* DOM_VK_PLUS 171 */
gabomdq@8833
   207
    SDL_SCANCODE_KP_PLUS,               /* DOM_VK_PIPE 172 */
gabomdq@8833
   208
    SDL_SCANCODE_MINUS,                 /* DOM_VK_HYPHEN_MINUS 173 */
gabomdq@8833
   209
    SDL_SCANCODE_UNKNOWN,               /* DOM_VK_OPEN_CURLY_BRACKET 174 */
gabomdq@8833
   210
    SDL_SCANCODE_UNKNOWN,               /* DOM_VK_CLOSE_CURLY_BRACKET 175 */
gabomdq@8833
   211
    SDL_SCANCODE_NONUSBACKSLASH,        /* DOM_VK_TILDE 176 */
gabomdq@8833
   212
    SDL_SCANCODE_UNKNOWN,               /* 177 */
gabomdq@8833
   213
    SDL_SCANCODE_UNKNOWN,               /* 178 */
gabomdq@8833
   214
    SDL_SCANCODE_UNKNOWN,               /* 179 */
gabomdq@8833
   215
    SDL_SCANCODE_UNKNOWN,               /* 180 */
gabomdq@8833
   216
    SDL_SCANCODE_MUTE,                  /* DOM_VK_VOLUME_MUTE 181 */
gabomdq@8833
   217
    SDL_SCANCODE_VOLUMEDOWN,            /* DOM_VK_VOLUME_DOWN 182 */
gabomdq@8833
   218
    SDL_SCANCODE_VOLUMEUP,              /* DOM_VK_VOLUME_UP 183 */
gabomdq@8833
   219
    SDL_SCANCODE_UNKNOWN,               /* 184 */
gabomdq@8833
   220
    SDL_SCANCODE_UNKNOWN,               /* 185 */
gabomdq@8833
   221
    SDL_SCANCODE_UNKNOWN,               /* 186 */
gabomdq@8833
   222
    SDL_SCANCODE_UNKNOWN,               /* 187 */
gabomdq@8833
   223
    SDL_SCANCODE_COMMA,                 /* DOM_VK_COMMA 188 */
gabomdq@8833
   224
    SDL_SCANCODE_UNKNOWN,               /* 189 */
gabomdq@8833
   225
    SDL_SCANCODE_PERIOD,                /* DOM_VK_PERIOD 190 */
gabomdq@8833
   226
    SDL_SCANCODE_SLASH,                 /* DOM_VK_SLASH 191 */
gabomdq@8833
   227
    SDL_SCANCODE_UNKNOWN,               /* DOM_VK_BACK_QUOTE 192 */
gabomdq@8833
   228
    SDL_SCANCODE_UNKNOWN,               /* 193 */
gabomdq@8833
   229
    SDL_SCANCODE_UNKNOWN,               /* 194 */
gabomdq@8833
   230
    SDL_SCANCODE_UNKNOWN,               /* 195 */
gabomdq@8833
   231
    SDL_SCANCODE_UNKNOWN,               /* 196 */
gabomdq@8833
   232
    SDL_SCANCODE_UNKNOWN,               /* 197 */
gabomdq@8833
   233
    SDL_SCANCODE_UNKNOWN,               /* 198 */
gabomdq@8833
   234
    SDL_SCANCODE_UNKNOWN,               /* 199 */
gabomdq@8833
   235
    SDL_SCANCODE_UNKNOWN,               /* 200 */
gabomdq@8833
   236
    SDL_SCANCODE_UNKNOWN,               /* 201 */
gabomdq@8833
   237
    SDL_SCANCODE_UNKNOWN,               /* 202 */
gabomdq@8833
   238
    SDL_SCANCODE_UNKNOWN,               /* 203 */
gabomdq@8833
   239
    SDL_SCANCODE_UNKNOWN,               /* 204 */
gabomdq@8833
   240
    SDL_SCANCODE_UNKNOWN,               /* 205 */
gabomdq@8833
   241
    SDL_SCANCODE_UNKNOWN,               /* 206 */
gabomdq@8833
   242
    SDL_SCANCODE_UNKNOWN,               /* 207 */
gabomdq@8833
   243
    SDL_SCANCODE_UNKNOWN,               /* 208 */
gabomdq@8833
   244
    SDL_SCANCODE_UNKNOWN,               /* 209 */
gabomdq@8833
   245
    SDL_SCANCODE_UNKNOWN,               /* 210 */
gabomdq@8833
   246
    SDL_SCANCODE_UNKNOWN,               /* 211 */
gabomdq@8833
   247
    SDL_SCANCODE_UNKNOWN,               /* 212 */
gabomdq@8833
   248
    SDL_SCANCODE_UNKNOWN,               /* 213 */
gabomdq@8833
   249
    SDL_SCANCODE_UNKNOWN,               /* 214 */
gabomdq@8833
   250
    SDL_SCANCODE_UNKNOWN,               /* 215 */
gabomdq@8833
   251
    SDL_SCANCODE_UNKNOWN,               /* 216 */
gabomdq@8833
   252
    SDL_SCANCODE_UNKNOWN,               /* 217 */
gabomdq@8833
   253
    SDL_SCANCODE_UNKNOWN,               /* 218 */
gabomdq@8833
   254
    SDL_SCANCODE_LEFTBRACKET,           /* DOM_VK_OPEN_BRACKET 219 */
gabomdq@8833
   255
    SDL_SCANCODE_BACKSLASH,             /* DOM_VK_BACK_SLASH 220 */
gabomdq@8833
   256
    SDL_SCANCODE_RIGHTBRACKET,          /* DOM_VK_CLOSE_BRACKET 221 */
gabomdq@8833
   257
    SDL_SCANCODE_APOSTROPHE,            /* DOM_VK_QUOTE 222 */
gabomdq@8833
   258
    SDL_SCANCODE_UNKNOWN,               /* 223 */
gabomdq@8833
   259
    SDL_SCANCODE_RGUI,                  /* DOM_VK_META 224 */
gabomdq@8833
   260
    SDL_SCANCODE_RALT,                  /* DOM_VK_ALTGR 225 */
gabomdq@8833
   261
    SDL_SCANCODE_UNKNOWN,               /* 226 */
gabomdq@8833
   262
    SDL_SCANCODE_UNKNOWN,               /* DOM_VK_WIN_ICO_HELP 227 */
gabomdq@8833
   263
    SDL_SCANCODE_UNKNOWN,               /* DOM_VK_WIN_ICO_00 228 */
gabomdq@8833
   264
    SDL_SCANCODE_UNKNOWN,               /* 229 */
gabomdq@8833
   265
    SDL_SCANCODE_UNKNOWN,               /* DOM_VK_WIN_ICO_CLEAR 230 */
gabomdq@8833
   266
    SDL_SCANCODE_UNKNOWN,               /* 231 */
gabomdq@8833
   267
    SDL_SCANCODE_UNKNOWN,               /* 232 */
gabomdq@8833
   268
    SDL_SCANCODE_UNKNOWN,               /* DOM_VK_WIN_OEM_RESET 233 */
gabomdq@8833
   269
    SDL_SCANCODE_UNKNOWN,               /* DOM_VK_WIN_OEM_JUMP 234 */
gabomdq@8833
   270
    SDL_SCANCODE_UNKNOWN,               /* DOM_VK_WIN_OEM_PA1 235 */
gabomdq@8833
   271
    SDL_SCANCODE_UNKNOWN,               /* DOM_VK_WIN_OEM_PA2 236 */
gabomdq@8833
   272
    SDL_SCANCODE_UNKNOWN,               /* DOM_VK_WIN_OEM_PA3 237 */
gabomdq@8833
   273
    SDL_SCANCODE_UNKNOWN,               /* DOM_VK_WIN_OEM_WSCTRL 238 */
gabomdq@8833
   274
    SDL_SCANCODE_UNKNOWN,               /* DOM_VK_WIN_OEM_CUSEL 239 */
gabomdq@8833
   275
    SDL_SCANCODE_UNKNOWN,               /* DOM_VK_WIN_OEM_ATTN 240 */
gabomdq@8833
   276
    SDL_SCANCODE_UNKNOWN,               /* DOM_VK_WIN_OEM_FINISH 241 */
gabomdq@8833
   277
    SDL_SCANCODE_UNKNOWN,               /* DOM_VK_WIN_OEM_COPY 242 */
gabomdq@8833
   278
    SDL_SCANCODE_UNKNOWN,               /* DOM_VK_WIN_OEM_AUTO 243 */
gabomdq@8833
   279
    SDL_SCANCODE_UNKNOWN,               /* DOM_VK_WIN_OEM_ENLW 244 */
gabomdq@8833
   280
    SDL_SCANCODE_UNKNOWN,               /* DOM_VK_WIN_OEM_BACKTAB 245 */
gabomdq@8833
   281
    SDL_SCANCODE_UNKNOWN,               /* DOM_VK_ATTN 246 */
gabomdq@8833
   282
    SDL_SCANCODE_UNKNOWN,               /* DOM_VK_CRSEL 247 */
gabomdq@8833
   283
    SDL_SCANCODE_UNKNOWN,               /* DOM_VK_EXSEL 248 */
gabomdq@8833
   284
    SDL_SCANCODE_UNKNOWN,               /* DOM_VK_EREOF 249 */
gabomdq@8833
   285
    SDL_SCANCODE_AUDIOPLAY,             /* DOM_VK_PLAY 250 */
gabomdq@8833
   286
    SDL_SCANCODE_UNKNOWN,               /* DOM_VK_ZOOM 251 */
gabomdq@8833
   287
    SDL_SCANCODE_UNKNOWN,               /* 252 */
gabomdq@8833
   288
    SDL_SCANCODE_UNKNOWN,               /* DOM_VK_PA1 253 */
gabomdq@8833
   289
    SDL_SCANCODE_UNKNOWN,               /* DOM_VK_WIN_OEM_CLEAR 254 */
gabomdq@8833
   290
    SDL_SCANCODE_UNKNOWN,               /* 255 */
gabomdq@8833
   291
};
gabomdq@8833
   292
gabomdq@8833
   293
static Uint8 SDL_NACL_translate_mouse_button(int32_t button) {
gabomdq@8833
   294
    switch (button) {
gabomdq@8833
   295
        case PP_INPUTEVENT_MOUSEBUTTON_LEFT:
gabomdq@8833
   296
            return SDL_BUTTON_LEFT;
gabomdq@8833
   297
        case PP_INPUTEVENT_MOUSEBUTTON_MIDDLE:
gabomdq@8833
   298
            return SDL_BUTTON_MIDDLE;
gabomdq@8833
   299
        case PP_INPUTEVENT_MOUSEBUTTON_RIGHT:
gabomdq@8833
   300
            return SDL_BUTTON_RIGHT;
gabomdq@8833
   301
            
gabomdq@8833
   302
        case PP_INPUTEVENT_MOUSEBUTTON_NONE:
gabomdq@8833
   303
        default:
gabomdq@8833
   304
            return 0;
gabomdq@8833
   305
    }
gabomdq@8833
   306
}
gabomdq@8833
   307
gabomdq@8833
   308
static SDL_Scancode
gabomdq@8833
   309
SDL_NACL_translate_keycode(int keycode)
gabomdq@8833
   310
{
gabomdq@8833
   311
    SDL_Scancode scancode = SDL_SCANCODE_UNKNOWN;
gabomdq@8833
   312
gabomdq@8833
   313
    if (keycode < SDL_arraysize(NACL_Keycodes)) {
gabomdq@8833
   314
        scancode = NACL_Keycodes[keycode];
gabomdq@8833
   315
    }
gabomdq@8833
   316
    if (scancode == SDL_SCANCODE_UNKNOWN) {
philipp@8846
   317
        SDL_Log("The key you just pressed is not recognized by SDL. To help get this fixed, please report this to the SDL mailing list <sdl@libsdl.org> NACL KeyCode %d \n", keycode);
gabomdq@8833
   318
    }
gabomdq@8833
   319
    return scancode;
gabomdq@8833
   320
}
gabomdq@8833
   321
gabomdq@8833
   322
void NACL_PumpEvents(_THIS) {
gabomdq@8833
   323
  PSEvent* ps_event;
gabomdq@8833
   324
  PP_Resource event;  
gabomdq@8833
   325
  PP_InputEvent_Type type;
gabomdq@8833
   326
  PP_InputEvent_Modifier modifiers;
gabomdq@8833
   327
  struct PP_Rect rect;
gabomdq@8833
   328
  struct PP_FloatPoint fp;
gabomdq@8833
   329
  struct PP_Point location;
gabomdq@8833
   330
  struct PP_Var var;
gabomdq@8833
   331
  const char *str;
gabomdq@8833
   332
  char text[64];
gabomdq@8833
   333
  Uint32 str_len;
gabomdq@8833
   334
  SDL_VideoData *driverdata = (SDL_VideoData *) _this->driverdata;
gabomdq@8833
   335
  SDL_Mouse *mouse = SDL_GetMouse();
gabomdq@8833
   336
  
gabomdq@8833
   337
  if (driverdata->window) {
gabomdq@8833
   338
    while ((ps_event = PSEventTryAcquire()) != NULL) {
gabomdq@8833
   339
        event = ps_event->as_resource;
gabomdq@8833
   340
        switch(ps_event->type) {
gabomdq@8833
   341
            /* From DidChangeView, contains a view resource */
gabomdq@8833
   342
            case PSE_INSTANCE_DIDCHANGEVIEW:
gabomdq@8833
   343
                driverdata->ppb_view->GetRect(event, &rect);
gabomdq@8833
   344
                NACL_SetScreenResolution(rect.size.width, rect.size.height, SDL_PIXELFORMAT_UNKNOWN);
gabomdq@8833
   345
                // FIXME: Rebuild context? See life.c UpdateContext
gabomdq@8833
   346
                break;
gabomdq@8833
   347
            
gabomdq@8833
   348
            /* From HandleInputEvent, contains an input resource. */
gabomdq@8833
   349
            case PSE_INSTANCE_HANDLEINPUT: 
gabomdq@8833
   350
                type = driverdata->ppb_input_event->GetType(event);
gabomdq@8833
   351
                modifiers = driverdata->ppb_input_event->GetModifiers(event);
gabomdq@8833
   352
                switch(type) {
gabomdq@8833
   353
                    case PP_INPUTEVENT_TYPE_MOUSEDOWN:
gabomdq@8833
   354
                        SDL_SendMouseButton(mouse->focus, mouse->mouseID, SDL_PRESSED, SDL_NACL_translate_mouse_button(driverdata->ppb_mouse_input_event->GetButton(event)));
gabomdq@8833
   355
                        break;
gabomdq@8833
   356
                    case PP_INPUTEVENT_TYPE_MOUSEUP:
gabomdq@8833
   357
                        SDL_SendMouseButton(mouse->focus, mouse->mouseID, SDL_RELEASED, SDL_NACL_translate_mouse_button(driverdata->ppb_mouse_input_event->GetButton(event)));
gabomdq@8833
   358
                        break;
gabomdq@8833
   359
                    case PP_INPUTEVENT_TYPE_WHEEL:
gabomdq@8833
   360
                        /* FIXME: GetTicks provides high resolution scroll events */
gabomdq@8833
   361
                        fp = driverdata->ppb_wheel_input_event->GetDelta(event);
urkle@9257
   362
                        SDL_SendMouseWheel(mouse->focus, mouse->mouseID, (int) fp.x, (int) fp.y, SDL_MOUSEWHEEL_NORMAL);
gabomdq@8833
   363
                        break;
gabomdq@8833
   364
                        
gabomdq@8833
   365
                    case PP_INPUTEVENT_TYPE_MOUSEENTER:
gabomdq@8833
   366
                    case PP_INPUTEVENT_TYPE_MOUSELEAVE:
gabomdq@8833
   367
                        /* FIXME: Mouse Focus */
gabomdq@8833
   368
                        break;
gabomdq@8833
   369
                        
gabomdq@8833
   370
                        
gabomdq@8833
   371
                    case PP_INPUTEVENT_TYPE_MOUSEMOVE: 
gabomdq@8833
   372
                        location = driverdata->ppb_mouse_input_event->GetPosition(event);
gabomdq@8833
   373
                        SDL_SendMouseMotion(mouse->focus, mouse->mouseID, SDL_FALSE, location.x, location.y);
gabomdq@8833
   374
                        break;
gabomdq@8833
   375
                  
gabomdq@8833
   376
                    case PP_INPUTEVENT_TYPE_TOUCHSTART:
gabomdq@8833
   377
                    case PP_INPUTEVENT_TYPE_TOUCHMOVE:
gabomdq@8833
   378
                    case PP_INPUTEVENT_TYPE_TOUCHEND:
gabomdq@8833
   379
                    case PP_INPUTEVENT_TYPE_TOUCHCANCEL:
gabomdq@8833
   380
                        /* FIXME: Touch events */
gabomdq@8833
   381
                        break;
gabomdq@8833
   382
                      
gabomdq@8833
   383
                    case PP_INPUTEVENT_TYPE_KEYDOWN:
gabomdq@8833
   384
                        SDL_SendKeyboardKey(SDL_PRESSED, SDL_NACL_translate_keycode(driverdata->ppb_keyboard_input_event->GetKeyCode(event)));
gabomdq@8833
   385
                        break;
gabomdq@8833
   386
                        
gabomdq@8833
   387
                    case PP_INPUTEVENT_TYPE_KEYUP:
gabomdq@8833
   388
                        SDL_SendKeyboardKey(SDL_RELEASED, SDL_NACL_translate_keycode(driverdata->ppb_keyboard_input_event->GetKeyCode(event)));
gabomdq@8833
   389
                        break;
gabomdq@8833
   390
                        
gabomdq@8833
   391
                    case PP_INPUTEVENT_TYPE_CHAR:
gabomdq@8833
   392
                        var = driverdata->ppb_keyboard_input_event->GetCharacterText(event);
gabomdq@8833
   393
                        str = driverdata->ppb_var->VarToUtf8(var, &str_len);
gabomdq@8833
   394
                        /* str is not null terminated! */
gabomdq@8833
   395
                        if ( str_len >= SDL_arraysize(text) ) {
gabomdq@8833
   396
                            str_len = SDL_arraysize(text) - 1;
gabomdq@8833
   397
                        }
gabomdq@8833
   398
                        SDL_strlcpy(text, str, str_len );
gabomdq@8833
   399
                        text[str_len] = '\0';
gabomdq@8833
   400
                        
gabomdq@8833
   401
                        SDL_SendKeyboardText(text);
gabomdq@8833
   402
                        /* FIXME: Do we have to handle ref counting? driverdata->ppb_var->Release(var);*/
gabomdq@8833
   403
                        break;
gabomdq@8833
   404
                        
gabomdq@8833
   405
                    default:
gabomdq@8833
   406
                        break;
gabomdq@8833
   407
                }
gabomdq@8833
   408
                break;
gabomdq@8833
   409
                
gabomdq@8833
   410
        
gabomdq@8833
   411
            /* From HandleMessage, contains a PP_Var. */
gabomdq@8833
   412
            case PSE_INSTANCE_HANDLEMESSAGE:
gabomdq@8833
   413
                break;
gabomdq@8833
   414
gabomdq@8833
   415
            /* From DidChangeFocus, contains a PP_Bool with the current focus state. */
gabomdq@8833
   416
            case PSE_INSTANCE_DIDCHANGEFOCUS:
gabomdq@8833
   417
                break;
gabomdq@8833
   418
gabomdq@8833
   419
            /* When the 3D context is lost, no resource. */
gabomdq@8833
   420
            case PSE_GRAPHICS3D_GRAPHICS3DCONTEXTLOST:
gabomdq@8833
   421
                break;
gabomdq@8833
   422
                
gabomdq@8833
   423
            /* When the mouse lock is lost. */
gabomdq@8833
   424
            case PSE_MOUSELOCK_MOUSELOCKLOST:
gabomdq@8833
   425
                break;
gabomdq@8833
   426
gabomdq@8833
   427
            default:
gabomdq@8833
   428
                break;
gabomdq@8833
   429
        }
gabomdq@8833
   430
        
gabomdq@8833
   431
        PSEventRelease(ps_event);
gabomdq@8833
   432
    }
gabomdq@8833
   433
  }
gabomdq@8833
   434
}
philipp@9332
   435
philipp@9332
   436
#endif /* SDL_VIDEO_DRIVER_NACL */
philipp@9332
   437
philipp@9332
   438
/* vi: set ts=4 sw=4 expandtab: */