src/video/emscripten/SDL_emscriptenevents.c
author Philipp Wiesemann <philipp.wiesemann@arcor.de>
Sun, 15 Feb 2015 21:44:36 +0100
changeset 9352 2cbf791a601c
parent 9278 8900afb78a19
child 9377 4c29dc2baaa8
permissions -rw-r--r--
Emscripten: Changed return type of callback implementations from int to EM_BOOL. The prototypes are declared with EM_BOOL (which is currently an int) in html5.h.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     1
/*
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     2
  Simple DirectMedia Layer
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     3
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     4
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     5
  This software is provided 'as-is', without any express or implied
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     6
  warranty.  In no event will the authors be held liable for any damages
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     7
  arising from the use of this software.
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     8
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     9
  Permission is granted to anyone to use this software for any purpose,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    10
  including commercial applications, and to alter it and redistribute it
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    11
  freely, subject to the following restrictions:
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    12
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    13
  1. The origin of this software must not be misrepresented; you must not
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    14
     claim that you wrote the original software. If you use this software
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    15
     in a product, an acknowledgment in the product documentation would be
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    16
     appreciated but is not required.
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    17
  2. Altered source versions must be plainly marked as such, and must not be
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    18
     misrepresented as being the original software.
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    19
  3. This notice may not be removed or altered from any source distribution.
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    20
*/
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    21
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    22
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    23
#include "../../SDL_internal.h"
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    24
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    25
#if SDL_VIDEO_DRIVER_EMSCRIPTEN
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    26
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    27
#include <emscripten/html5.h>
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    28
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    29
#include "../../events/SDL_events_c.h"
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    30
#include "../../events/SDL_keyboard_c.h"
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    31
#include "../../events/SDL_touch_c.h"
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    32
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    33
#include "SDL_emscriptenevents.h"
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    34
#include "SDL_emscriptenvideo.h"
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    35
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    36
#include "SDL_hints.h"
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    37
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    38
#define FULLSCREEN_MASK ( SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_FULLSCREEN )
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    39
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    40
/*
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    41
.which to scancode
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    42
https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Constants
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    43
*/
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    44
static const SDL_Scancode emscripten_scancode_table[] = {
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    45
    /*  0 */    SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    46
    /*  1 */    SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    47
    /*  2 */    SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    48
    /*  3 */    SDL_SCANCODE_CANCEL,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    49
    /*  4 */    SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    50
    /*  5 */    SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    51
    /*  6 */    SDL_SCANCODE_HELP,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    52
    /*  7 */    SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    53
    /*  8 */    SDL_SCANCODE_BACKSPACE,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    54
    /*  9 */    SDL_SCANCODE_TAB,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    55
    /*  10 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    56
    /*  11 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    57
    /*  12 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    58
    /*  13 */   SDL_SCANCODE_RETURN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    59
    /*  14 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    60
    /*  15 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    61
    /*  16 */   SDL_SCANCODE_LSHIFT,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    62
    /*  17 */   SDL_SCANCODE_LCTRL,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    63
    /*  18 */   SDL_SCANCODE_LALT,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    64
    /*  19 */   SDL_SCANCODE_PAUSE,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    65
    /*  20 */   SDL_SCANCODE_CAPSLOCK,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    66
    /*  21 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    67
    /*  22 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    68
    /*  23 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    69
    /*  24 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    70
    /*  25 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    71
    /*  26 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    72
    /*  27 */   SDL_SCANCODE_ESCAPE,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    73
    /*  28 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    74
    /*  29 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    75
    /*  30 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    76
    /*  31 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    77
    /*  32 */   SDL_SCANCODE_SPACE,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    78
    /*  33 */   SDL_SCANCODE_PAGEUP,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    79
    /*  34 */   SDL_SCANCODE_PAGEDOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    80
    /*  35 */   SDL_SCANCODE_END,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    81
    /*  36 */   SDL_SCANCODE_HOME,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    82
    /*  37 */   SDL_SCANCODE_LEFT,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    83
    /*  38 */   SDL_SCANCODE_UP,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    84
    /*  39 */   SDL_SCANCODE_RIGHT,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    85
    /*  40 */   SDL_SCANCODE_DOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    86
    /*  41 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    87
    /*  42 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    88
    /*  43 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    89
    /*  44 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    90
    /*  45 */   SDL_SCANCODE_INSERT,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    91
    /*  46 */   SDL_SCANCODE_DELETE,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    92
    /*  47 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    93
    /*  48 */   SDL_SCANCODE_0,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    94
    /*  49 */   SDL_SCANCODE_1,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    95
    /*  50 */   SDL_SCANCODE_2,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    96
    /*  51 */   SDL_SCANCODE_3,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    97
    /*  52 */   SDL_SCANCODE_4,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    98
    /*  53 */   SDL_SCANCODE_5,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    99
    /*  54 */   SDL_SCANCODE_6,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   100
    /*  55 */   SDL_SCANCODE_7,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   101
    /*  56 */   SDL_SCANCODE_8,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   102
    /*  57 */   SDL_SCANCODE_9,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   103
    /*  58 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   104
    /*  59 */   SDL_SCANCODE_SEMICOLON,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   105
    /*  60 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   106
    /*  61 */   SDL_SCANCODE_EQUALS,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   107
    /*  62 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   108
    /*  63 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   109
    /*  64 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   110
    /*  65 */   SDL_SCANCODE_A,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   111
    /*  66 */   SDL_SCANCODE_B,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   112
    /*  67 */   SDL_SCANCODE_C,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   113
    /*  68 */   SDL_SCANCODE_D,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   114
    /*  69 */   SDL_SCANCODE_E,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   115
    /*  70 */   SDL_SCANCODE_F,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   116
    /*  71 */   SDL_SCANCODE_G,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   117
    /*  72 */   SDL_SCANCODE_H,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   118
    /*  73 */   SDL_SCANCODE_I,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   119
    /*  74 */   SDL_SCANCODE_J,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   120
    /*  75 */   SDL_SCANCODE_K,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   121
    /*  76 */   SDL_SCANCODE_L,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   122
    /*  77 */   SDL_SCANCODE_M,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   123
    /*  78 */   SDL_SCANCODE_N,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   124
    /*  79 */   SDL_SCANCODE_O,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   125
    /*  80 */   SDL_SCANCODE_P,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   126
    /*  81 */   SDL_SCANCODE_Q,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   127
    /*  82 */   SDL_SCANCODE_R,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   128
    /*  83 */   SDL_SCANCODE_S,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   129
    /*  84 */   SDL_SCANCODE_T,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   130
    /*  85 */   SDL_SCANCODE_U,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   131
    /*  86 */   SDL_SCANCODE_V,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   132
    /*  87 */   SDL_SCANCODE_W,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   133
    /*  88 */   SDL_SCANCODE_X,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   134
    /*  89 */   SDL_SCANCODE_Y,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   135
    /*  90 */   SDL_SCANCODE_Z,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   136
    /*  91 */   SDL_SCANCODE_LGUI,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   137
    /*  92 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   138
    /*  93 */   SDL_SCANCODE_APPLICATION,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   139
    /*  94 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   140
    /*  95 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   141
    /*  96 */   SDL_SCANCODE_KP_0,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   142
    /*  97 */   SDL_SCANCODE_KP_1,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   143
    /*  98 */   SDL_SCANCODE_KP_2,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   144
    /*  99 */   SDL_SCANCODE_KP_3,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   145
    /* 100 */   SDL_SCANCODE_KP_4,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   146
    /* 101 */   SDL_SCANCODE_KP_5,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   147
    /* 102 */   SDL_SCANCODE_KP_6,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   148
    /* 103 */   SDL_SCANCODE_KP_7,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   149
    /* 104 */   SDL_SCANCODE_KP_8,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   150
    /* 105 */   SDL_SCANCODE_KP_9,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   151
    /* 106 */   SDL_SCANCODE_KP_MULTIPLY,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   152
    /* 107 */   SDL_SCANCODE_KP_PLUS,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   153
    /* 108 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   154
    /* 109 */   SDL_SCANCODE_KP_MINUS,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   155
    /* 110 */   SDL_SCANCODE_KP_PERIOD,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   156
    /* 111 */   SDL_SCANCODE_KP_DIVIDE,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   157
    /* 112 */   SDL_SCANCODE_F1,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   158
    /* 113 */   SDL_SCANCODE_F2,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   159
    /* 114 */   SDL_SCANCODE_F3,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   160
    /* 115 */   SDL_SCANCODE_F4,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   161
    /* 116 */   SDL_SCANCODE_F5,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   162
    /* 117 */   SDL_SCANCODE_F6,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   163
    /* 118 */   SDL_SCANCODE_F7,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   164
    /* 119 */   SDL_SCANCODE_F8,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   165
    /* 120 */   SDL_SCANCODE_F9,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   166
    /* 121 */   SDL_SCANCODE_F10,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   167
    /* 122 */   SDL_SCANCODE_F11,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   168
    /* 123 */   SDL_SCANCODE_F12,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   169
    /* 124 */   SDL_SCANCODE_F13,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   170
    /* 125 */   SDL_SCANCODE_F14,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   171
    /* 126 */   SDL_SCANCODE_F15,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   172
    /* 127 */   SDL_SCANCODE_F16,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   173
    /* 128 */   SDL_SCANCODE_F17,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   174
    /* 129 */   SDL_SCANCODE_F18,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   175
    /* 130 */   SDL_SCANCODE_F19,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   176
    /* 131 */   SDL_SCANCODE_F20,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   177
    /* 132 */   SDL_SCANCODE_F21,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   178
    /* 133 */   SDL_SCANCODE_F22,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   179
    /* 134 */   SDL_SCANCODE_F23,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   180
    /* 135 */   SDL_SCANCODE_F24,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   181
    /* 136 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   182
    /* 137 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   183
    /* 138 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   184
    /* 139 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   185
    /* 140 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   186
    /* 141 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   187
    /* 142 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   188
    /* 143 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   189
    /* 144 */   SDL_SCANCODE_NUMLOCKCLEAR,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   190
    /* 145 */   SDL_SCANCODE_SCROLLLOCK,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   191
    /* 146 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   192
    /* 147 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   193
    /* 148 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   194
    /* 149 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   195
    /* 150 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   196
    /* 151 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   197
    /* 152 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   198
    /* 153 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   199
    /* 154 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   200
    /* 155 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   201
    /* 156 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   202
    /* 157 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   203
    /* 158 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   204
    /* 159 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   205
    /* 160 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   206
    /* 161 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   207
    /* 162 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   208
    /* 163 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   209
    /* 164 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   210
    /* 165 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   211
    /* 166 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   212
    /* 167 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   213
    /* 168 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   214
    /* 169 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   215
    /* 170 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   216
    /* 171 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   217
    /* 172 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   218
    /* 173 */   SDL_SCANCODE_MINUS, /*FX*/
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   219
    /* 174 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   220
    /* 175 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   221
    /* 176 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   222
    /* 177 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   223
    /* 178 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   224
    /* 179 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   225
    /* 180 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   226
    /* 181 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   227
    /* 182 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   228
    /* 183 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   229
    /* 184 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   230
    /* 185 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   231
    /* 186 */   SDL_SCANCODE_SEMICOLON, /*IE, Chrome, D3E legacy*/
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   232
    /* 187 */   SDL_SCANCODE_EQUALS, /*IE, Chrome, D3E legacy*/
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   233
    /* 188 */   SDL_SCANCODE_COMMA,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   234
    /* 189 */   SDL_SCANCODE_MINUS, /*IE, Chrome, D3E legacy*/
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   235
    /* 190 */   SDL_SCANCODE_PERIOD,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   236
    /* 191 */   SDL_SCANCODE_SLASH,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   237
    /* 192 */   SDL_SCANCODE_GRAVE, /*FX, D3E legacy (SDL_SCANCODE_APOSTROPHE in IE/Chrome)*/
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   238
    /* 193 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   239
    /* 194 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   240
    /* 195 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   241
    /* 196 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   242
    /* 197 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   243
    /* 198 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   244
    /* 199 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   245
    /* 200 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   246
    /* 201 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   247
    /* 202 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   248
    /* 203 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   249
    /* 204 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   250
    /* 205 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   251
    /* 206 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   252
    /* 207 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   253
    /* 208 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   254
    /* 209 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   255
    /* 210 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   256
    /* 211 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   257
    /* 212 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   258
    /* 213 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   259
    /* 214 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   260
    /* 215 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   261
    /* 216 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   262
    /* 217 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   263
    /* 218 */   SDL_SCANCODE_UNKNOWN,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   264
    /* 219 */   SDL_SCANCODE_LEFTBRACKET,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   265
    /* 220 */   SDL_SCANCODE_BACKSLASH,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   266
    /* 221 */   SDL_SCANCODE_RIGHTBRACKET,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   267
    /* 222 */   SDL_SCANCODE_APOSTROPHE, /*FX, D3E legacy*/
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   268
};
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   269
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   270
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   271
/* "borrowed" from SDL_windowsevents.c */
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   272
int
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   273
Emscripten_ConvertUTF32toUTF8(Uint32 codepoint, char * text)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   274
{
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   275
    if (codepoint <= 0x7F) {
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   276
        text[0] = (char) codepoint;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   277
        text[1] = '\0';
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   278
    } else if (codepoint <= 0x7FF) {
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   279
        text[0] = 0xC0 | (char) ((codepoint >> 6) & 0x1F);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   280
        text[1] = 0x80 | (char) (codepoint & 0x3F);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   281
        text[2] = '\0';
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   282
    } else if (codepoint <= 0xFFFF) {
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   283
        text[0] = 0xE0 | (char) ((codepoint >> 12) & 0x0F);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   284
        text[1] = 0x80 | (char) ((codepoint >> 6) & 0x3F);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   285
        text[2] = 0x80 | (char) (codepoint & 0x3F);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   286
        text[3] = '\0';
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   287
    } else if (codepoint <= 0x10FFFF) {
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   288
        text[0] = 0xF0 | (char) ((codepoint >> 18) & 0x0F);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   289
        text[1] = 0x80 | (char) ((codepoint >> 12) & 0x3F);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   290
        text[2] = 0x80 | (char) ((codepoint >> 6) & 0x3F);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   291
        text[3] = 0x80 | (char) (codepoint & 0x3F);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   292
        text[4] = '\0';
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   293
    } else {
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   294
        return SDL_FALSE;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   295
    }
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   296
    return SDL_TRUE;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   297
}
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   298
9352
2cbf791a601c Emscripten: Changed return type of callback implementations from int to EM_BOOL.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 9278
diff changeset
   299
EM_BOOL
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   300
Emscripten_HandleMouseMove(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   301
{
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   302
    SDL_WindowData *window_data = userData;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   303
    int mx = mouseEvent->canvasX, my = mouseEvent->canvasY;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   304
    EmscriptenPointerlockChangeEvent pointerlock_status;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   305
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   306
    /* check for pointer lock */
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   307
    emscripten_get_pointerlock_status(&pointerlock_status);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   308
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   309
    if (pointerlock_status.isActive) {
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   310
        mx = mouseEvent->movementX;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   311
        my = mouseEvent->movementY;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   312
    }
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   313
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   314
    /* rescale (in case canvas is being scaled)*/
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   315
    double client_w, client_h;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   316
    emscripten_get_element_css_size(NULL, &client_w, &client_h);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   317
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   318
    mx = mx * (window_data->window->w / (client_w * window_data->pixel_ratio));
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   319
    my = my * (window_data->window->h / (client_h * window_data->pixel_ratio));
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   320
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   321
    SDL_SendMouseMotion(window_data->window, 0, pointerlock_status.isActive, mx, my);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   322
    return 0;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   323
}
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   324
9352
2cbf791a601c Emscripten: Changed return type of callback implementations from int to EM_BOOL.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 9278
diff changeset
   325
EM_BOOL
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   326
Emscripten_HandleMouseButton(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   327
{
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   328
    SDL_WindowData *window_data = userData;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   329
    uint32_t sdl_button;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   330
    switch (mouseEvent->button) {
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   331
        case 0:
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   332
            sdl_button = SDL_BUTTON_LEFT;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   333
            break;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   334
        case 1:
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   335
            sdl_button = SDL_BUTTON_MIDDLE;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   336
            break;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   337
        case 2:
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   338
            sdl_button = SDL_BUTTON_RIGHT;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   339
            break;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   340
        default:
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   341
            return 0;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   342
    }
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   343
    SDL_SendMouseButton(window_data->window, 0, eventType == EMSCRIPTEN_EVENT_MOUSEDOWN ? SDL_PRESSED : SDL_RELEASED, sdl_button);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   344
    return 1;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   345
}
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   346
9352
2cbf791a601c Emscripten: Changed return type of callback implementations from int to EM_BOOL.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 9278
diff changeset
   347
EM_BOOL
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   348
Emscripten_HandleMouseFocus(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   349
{
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   350
    SDL_WindowData *window_data = userData;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   351
    SDL_SendWindowEvent(window_data->window, eventType == EMSCRIPTEN_EVENT_MOUSEENTER ? SDL_WINDOWEVENT_ENTER : SDL_WINDOWEVENT_LEAVE, 0, 0);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   352
    return 1;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   353
}
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   354
9352
2cbf791a601c Emscripten: Changed return type of callback implementations from int to EM_BOOL.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 9278
diff changeset
   355
EM_BOOL
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   356
Emscripten_HandleWheel(int eventType, const EmscriptenWheelEvent *wheelEvent, void *userData)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   357
{
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   358
    SDL_WindowData *window_data = userData;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   359
    SDL_SendMouseWheel(window_data->window, 0, wheelEvent->deltaX, -wheelEvent->deltaY, SDL_MOUSEWHEEL_NORMAL);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   360
    return 1;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   361
}
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   362
9352
2cbf791a601c Emscripten: Changed return type of callback implementations from int to EM_BOOL.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 9278
diff changeset
   363
EM_BOOL
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   364
Emscripten_HandleFocus(int eventType, const EmscriptenFocusEvent *wheelEvent, void *userData)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   365
{
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   366
    SDL_WindowData *window_data = userData;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   367
    SDL_SendWindowEvent(window_data->window, eventType == EMSCRIPTEN_EVENT_FOCUS ? SDL_WINDOWEVENT_FOCUS_GAINED : SDL_WINDOWEVENT_FOCUS_LOST, 0, 0);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   368
    return 1;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   369
}
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   370
9352
2cbf791a601c Emscripten: Changed return type of callback implementations from int to EM_BOOL.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 9278
diff changeset
   371
EM_BOOL
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   372
Emscripten_HandleTouch(int eventType, const EmscriptenTouchEvent *touchEvent, void *userData)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   373
{
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   374
    /*SDL_WindowData *window_data = userData;*/
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   375
    int i;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   376
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   377
    SDL_TouchID deviceId = 0;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   378
    if (!SDL_GetTouch(deviceId)) {
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   379
        if (SDL_AddTouch(deviceId, "") < 0) {
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   380
             return 0;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   381
        }
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   382
    }
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   383
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   384
    for (i = 0; i < touchEvent->numTouches; i++) {
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   385
        long x, y, id;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   386
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   387
        if (!touchEvent->touches[i].isChanged)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   388
            continue;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   389
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   390
        id = touchEvent->touches[i].identifier;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   391
        x = touchEvent->touches[i].canvasX;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   392
        y = touchEvent->touches[i].canvasY;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   393
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   394
        if (eventType == EMSCRIPTEN_EVENT_TOUCHMOVE) {
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   395
            SDL_SendTouchMotion(deviceId, id, x, y, 1.0f);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   396
        } else if (eventType == EMSCRIPTEN_EVENT_TOUCHSTART) {
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   397
            SDL_SendTouch(deviceId, id, SDL_TRUE, x, y, 1.0f);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   398
        } else {
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   399
            SDL_SendTouch(deviceId, id, SDL_FALSE, x, y, 1.0f);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   400
        }
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   401
    }
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   402
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   403
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   404
    return 1;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   405
}
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   406
9352
2cbf791a601c Emscripten: Changed return type of callback implementations from int to EM_BOOL.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 9278
diff changeset
   407
EM_BOOL
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   408
Emscripten_HandleKey(int eventType, const EmscriptenKeyboardEvent *keyEvent, void *userData)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   409
{
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   410
    Uint32 scancode;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   411
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   412
    /* .keyCode is deprecated, but still the most reliable way to get keys */
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   413
    if (keyEvent->keyCode < SDL_arraysize(emscripten_scancode_table)) {
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   414
        scancode = emscripten_scancode_table[keyEvent->keyCode];
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   415
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   416
        if (scancode != SDL_SCANCODE_UNKNOWN) {
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   417
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   418
            if (keyEvent->location == DOM_KEY_LOCATION_RIGHT) {
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   419
                switch (scancode) {
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   420
                    case SDL_SCANCODE_LSHIFT:
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   421
                        scancode = SDL_SCANCODE_RSHIFT;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   422
                        break;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   423
                    case SDL_SCANCODE_LCTRL:
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   424
                        scancode = SDL_SCANCODE_RCTRL;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   425
                        break;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   426
                    case SDL_SCANCODE_LALT:
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   427
                        scancode = SDL_SCANCODE_RALT;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   428
                        break;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   429
                    case SDL_SCANCODE_LGUI:
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   430
                        scancode = SDL_SCANCODE_RGUI;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   431
                        break;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   432
                }
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   433
            }
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   434
            SDL_SendKeyboardKey(eventType == EMSCRIPTEN_EVENT_KEYDOWN ?
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   435
                                SDL_PRESSED : SDL_RELEASED, scancode);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   436
        }
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   437
    }
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   438
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   439
    /* if we prevent keydown, we won't get keypress
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   440
     * also we need to ALWAYS prevent backspace and tab otherwise chrome takes action and does bad navigation UX
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   441
     */
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   442
    return SDL_GetEventState(SDL_TEXTINPUT) != SDL_ENABLE || eventType != EMSCRIPTEN_EVENT_KEYDOWN
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   443
            || keyEvent->keyCode == 8 /* backspace */ || keyEvent->keyCode == 9 /* tab */;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   444
}
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   445
9352
2cbf791a601c Emscripten: Changed return type of callback implementations from int to EM_BOOL.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 9278
diff changeset
   446
EM_BOOL
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   447
Emscripten_HandleKeyPress(int eventType, const EmscriptenKeyboardEvent *keyEvent, void *userData)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   448
{
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   449
    char text[5];
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   450
    Emscripten_ConvertUTF32toUTF8(keyEvent->charCode, text);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   451
    SDL_SendKeyboardText(text);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   452
    return 1;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   453
}
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   454
9352
2cbf791a601c Emscripten: Changed return type of callback implementations from int to EM_BOOL.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 9278
diff changeset
   455
EM_BOOL
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   456
Emscripten_HandleFullscreenChange(int eventType, const EmscriptenFullscreenChangeEvent *fullscreenChangeEvent, void *userData)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   457
{
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   458
    /*make sure this is actually our element going fullscreen*/
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   459
    if(SDL_strcmp(fullscreenChangeEvent->id, "SDLFullscreenElement") != 0)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   460
        return 0;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   461
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   462
    SDL_WindowData *window_data = userData;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   463
    if(fullscreenChangeEvent->isFullscreen)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   464
    {
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   465
        SDL_bool is_desktop_fullscreen;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   466
        window_data->window->flags |= window_data->requested_fullscreen_mode;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   467
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   468
        if(!window_data->requested_fullscreen_mode)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   469
            window_data->window->flags |= SDL_WINDOW_FULLSCREEN_DESKTOP; /*we didn't reqest fullscreen*/
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   470
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   471
        window_data->requested_fullscreen_mode = 0;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   472
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   473
        is_desktop_fullscreen = (window_data->window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   474
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   475
        /*update size*/
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   476
        if(window_data->window->flags & SDL_WINDOW_RESIZABLE || is_desktop_fullscreen)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   477
        {
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   478
            emscripten_set_canvas_size(fullscreenChangeEvent->screenWidth, fullscreenChangeEvent->screenHeight);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   479
            SDL_SendWindowEvent(window_data->window, SDL_WINDOWEVENT_RESIZED, fullscreenChangeEvent->screenWidth, fullscreenChangeEvent->screenHeight);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   480
        }
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   481
        else
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   482
        {
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   483
            /*preserve ratio*/
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   484
            double w = window_data->window->w;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   485
            double h = window_data->window->h;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   486
            double factor = SDL_min(fullscreenChangeEvent->screenWidth / w, fullscreenChangeEvent->screenHeight / h);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   487
            emscripten_set_element_css_size(NULL, w * factor, h * factor);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   488
        }
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   489
    }
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   490
    else
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   491
    {
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   492
        EM_ASM({
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   493
            //un-reparent canvas (similar to Module.requestFullscreen)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   494
            var canvas = Module['canvas'];
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   495
            if(canvas.parentNode.id == "SDLFullscreenElement") {
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   496
                var canvasContainer = canvas.parentNode;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   497
                canvasContainer.parentNode.insertBefore(canvas, canvasContainer);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   498
                canvasContainer.parentNode.removeChild(canvasContainer);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   499
            }
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   500
        });
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   501
        double unscaled_w = window_data->windowed_width / window_data->pixel_ratio;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   502
        double unscaled_h = window_data->windowed_height / window_data->pixel_ratio;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   503
        emscripten_set_canvas_size(window_data->windowed_width, window_data->windowed_height);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   504
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   505
        if (!window_data->external_size && window_data->pixel_ratio != 1.0f) {
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   506
            emscripten_set_element_css_size(NULL, unscaled_w, unscaled_h);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   507
        }
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   508
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   509
        SDL_SendWindowEvent(window_data->window, SDL_WINDOWEVENT_RESIZED, unscaled_w, unscaled_h);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   510
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   511
        window_data->window->flags &= ~FULLSCREEN_MASK;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   512
    }
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   513
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   514
    return 0;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   515
}
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   516
9352
2cbf791a601c Emscripten: Changed return type of callback implementations from int to EM_BOOL.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 9278
diff changeset
   517
EM_BOOL
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   518
Emscripten_HandleResize(int eventType, const EmscriptenUiEvent *uiEvent, void *userData)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   519
{
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   520
    SDL_WindowData *window_data = userData;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   521
    if(window_data->window->flags & FULLSCREEN_MASK)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   522
    {
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   523
        SDL_bool is_desktop_fullscreen = (window_data->window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   524
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   525
        if(window_data->window->flags & SDL_WINDOW_RESIZABLE || is_desktop_fullscreen)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   526
        {
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   527
            emscripten_set_canvas_size(uiEvent->windowInnerWidth * window_data->pixel_ratio, uiEvent->windowInnerHeight * window_data->pixel_ratio);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   528
            SDL_SendWindowEvent(window_data->window, SDL_WINDOWEVENT_RESIZED, uiEvent->windowInnerWidth, uiEvent->windowInnerHeight);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   529
        }
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   530
    }
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   531
    else
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   532
    {
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   533
        /* this will only work if the canvas size is set through css */
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   534
        if(window_data->window->flags & SDL_WINDOW_RESIZABLE)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   535
        {
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   536
            double w = window_data->window->w;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   537
            double h = window_data->window->h;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   538
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   539
            if(window_data->external_size) {
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   540
                emscripten_get_element_css_size(NULL, &w, &h);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   541
            }
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   542
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   543
            emscripten_set_canvas_size(w * window_data->pixel_ratio, h * window_data->pixel_ratio);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   544
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   545
            /* set_canvas_size unsets this */
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   546
            if (!window_data->external_size && window_data->pixel_ratio != 1.0f) {
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   547
                emscripten_set_element_css_size(NULL, w, h);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   548
            }
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   549
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   550
            SDL_SendWindowEvent(window_data->window, SDL_WINDOWEVENT_RESIZED, w, h);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   551
        }
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   552
    }
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   553
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   554
    return 0;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   555
}
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   556
9352
2cbf791a601c Emscripten: Changed return type of callback implementations from int to EM_BOOL.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 9278
diff changeset
   557
EM_BOOL
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   558
Emscripten_HandleVisibilityChange(int eventType, const EmscriptenVisibilityChangeEvent *visEvent, void *userData)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   559
{
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   560
    SDL_WindowData *window_data = userData;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   561
    SDL_SendWindowEvent(window_data->window, visEvent->hidden ? SDL_WINDOWEVENT_HIDDEN : SDL_WINDOWEVENT_SHOWN, 0, 0);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   562
    return 0;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   563
}
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   564
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   565
void
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   566
Emscripten_RegisterEventHandlers(SDL_WindowData *data)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   567
{
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   568
    /* There is only one window and that window is the canvas */
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   569
    emscripten_set_mousemove_callback("#canvas", data, 0, Emscripten_HandleMouseMove);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   570
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   571
    emscripten_set_mousedown_callback("#canvas", data, 0, Emscripten_HandleMouseButton);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   572
    emscripten_set_mouseup_callback("#canvas", data, 0, Emscripten_HandleMouseButton);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   573
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   574
    emscripten_set_mouseenter_callback("#canvas", data, 0, Emscripten_HandleMouseFocus);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   575
    emscripten_set_mouseleave_callback("#canvas", data, 0, Emscripten_HandleMouseFocus);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   576
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   577
    emscripten_set_wheel_callback("#canvas", data, 0, Emscripten_HandleWheel);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   578
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   579
    emscripten_set_focus_callback("#canvas", data, 0, Emscripten_HandleFocus);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   580
    emscripten_set_blur_callback("#canvas", data, 0, Emscripten_HandleFocus);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   581
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   582
    emscripten_set_touchstart_callback("#canvas", data, 0, Emscripten_HandleTouch);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   583
    emscripten_set_touchend_callback("#canvas", data, 0, Emscripten_HandleTouch);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   584
    emscripten_set_touchmove_callback("#canvas", data, 0, Emscripten_HandleTouch);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   585
    emscripten_set_touchcancel_callback("#canvas", data, 0, Emscripten_HandleTouch);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   586
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   587
    /* Keyboard events are awkward */
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   588
    const char *keyElement = SDL_GetHint(SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   589
    if (!keyElement) keyElement = "#window";
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   590
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   591
    emscripten_set_keydown_callback(keyElement, data, 0, Emscripten_HandleKey);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   592
    emscripten_set_keyup_callback(keyElement, data, 0, Emscripten_HandleKey);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   593
    emscripten_set_keypress_callback(keyElement, data, 0, Emscripten_HandleKeyPress);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   594
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   595
    emscripten_set_fullscreenchange_callback("#document", data, 0, Emscripten_HandleFullscreenChange);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   596
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   597
    emscripten_set_resize_callback("#window", data, 0, Emscripten_HandleResize);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   598
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   599
    emscripten_set_visibilitychange_callback(data, 0, Emscripten_HandleVisibilityChange);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   600
}
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   601
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   602
void
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   603
Emscripten_UnregisterEventHandlers(SDL_WindowData *data)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   604
{
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   605
    /* only works due to having one window */
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   606
    emscripten_set_mousemove_callback("#canvas", NULL, 0, NULL);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   607
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   608
    emscripten_set_mousedown_callback("#canvas", NULL, 0, NULL);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   609
    emscripten_set_mouseup_callback("#canvas", NULL, 0, NULL);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   610
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   611
    emscripten_set_mouseenter_callback("#canvas", NULL, 0, NULL);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   612
    emscripten_set_mouseleave_callback("#canvas", NULL, 0, NULL);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   613
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   614
    emscripten_set_wheel_callback("#canvas", NULL, 0, NULL);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   615
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   616
    emscripten_set_focus_callback("#canvas", NULL, 0, NULL);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   617
    emscripten_set_blur_callback("#canvas", NULL, 0, NULL);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   618
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   619
    emscripten_set_touchstart_callback("#canvas", NULL, 0, NULL);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   620
    emscripten_set_touchend_callback("#canvas", NULL, 0, NULL);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   621
    emscripten_set_touchmove_callback("#canvas", NULL, 0, NULL);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   622
    emscripten_set_touchcancel_callback("#canvas", NULL, 0, NULL);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   623
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   624
    emscripten_set_keydown_callback("#window", NULL, 0, NULL);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   625
    emscripten_set_keyup_callback("#window", NULL, 0, NULL);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   626
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   627
    emscripten_set_keypress_callback("#window", NULL, 0, NULL);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   628
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   629
    emscripten_set_fullscreenchange_callback("#document", NULL, 0, NULL);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   630
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   631
    emscripten_set_resize_callback("#window", NULL, 0, NULL);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   632
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   633
    emscripten_set_visibilitychange_callback(NULL, 0, NULL);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   634
}
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   635
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   636
#endif /* SDL_VIDEO_DRIVER_EMSCRIPTEN */
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   637
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   638
/* vi: set ts=4 sw=4 expandtab: */