Emscripten: Use EMSCRIPTEN_EVENT_TARGET_*
authorCharlie Birks <charlie@daftgames.net>
Thu, 09 May 2019 12:09:45 +0100
changeset 127261db0606a7b0c
parent 12725 5ef84902d1a0
child 12727 7bbbfe01d943
Emscripten: Use EMSCRIPTEN_EVENT_TARGET_*
src/video/emscripten/SDL_emscriptenevents.c
     1.1 --- a/src/video/emscripten/SDL_emscriptenevents.c	Thu May 09 12:09:40 2019 +0100
     1.2 +++ b/src/video/emscripten/SDL_emscriptenevents.c	Thu May 09 12:09:45 2019 +0100
     1.3 @@ -643,34 +643,34 @@
     1.4      emscripten_set_mousemove_callback(data->canvas_id, data, 0, Emscripten_HandleMouseMove);
     1.5  
     1.6      emscripten_set_mousedown_callback(data->canvas_id, data, 0, Emscripten_HandleMouseButton);
     1.7 -    emscripten_set_mouseup_callback("#document", data, 0, Emscripten_HandleMouseButton);
     1.8 +    emscripten_set_mouseup_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, data, 0, Emscripten_HandleMouseButton);
     1.9  
    1.10      emscripten_set_mouseenter_callback(data->canvas_id, data, 0, Emscripten_HandleMouseFocus);
    1.11      emscripten_set_mouseleave_callback(data->canvas_id, data, 0, Emscripten_HandleMouseFocus);
    1.12  
    1.13      emscripten_set_wheel_callback(data->canvas_id, data, 0, Emscripten_HandleWheel);
    1.14  
    1.15 -    emscripten_set_focus_callback("#window", data, 0, Emscripten_HandleFocus);
    1.16 -    emscripten_set_blur_callback("#window", data, 0, Emscripten_HandleFocus);
    1.17 +    emscripten_set_focus_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, data, 0, Emscripten_HandleFocus);
    1.18 +    emscripten_set_blur_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, data, 0, Emscripten_HandleFocus);
    1.19  
    1.20      emscripten_set_touchstart_callback(data->canvas_id, data, 0, Emscripten_HandleTouch);
    1.21      emscripten_set_touchend_callback(data->canvas_id, data, 0, Emscripten_HandleTouch);
    1.22      emscripten_set_touchmove_callback(data->canvas_id, data, 0, Emscripten_HandleTouch);
    1.23      emscripten_set_touchcancel_callback(data->canvas_id, data, 0, Emscripten_HandleTouch);
    1.24  
    1.25 -    emscripten_set_pointerlockchange_callback("#document", data, 0, Emscripten_HandlePointerLockChange);
    1.26 +    emscripten_set_pointerlockchange_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, data, 0, Emscripten_HandlePointerLockChange);
    1.27  
    1.28      /* Keyboard events are awkward */
    1.29      keyElement = SDL_GetHint(SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT);
    1.30 -    if (!keyElement) keyElement = "#window";
    1.31 +    if (!keyElement) keyElement = EMSCRIPTEN_EVENT_TARGET_WINDOW;
    1.32  
    1.33      emscripten_set_keydown_callback(keyElement, data, 0, Emscripten_HandleKey);
    1.34      emscripten_set_keyup_callback(keyElement, data, 0, Emscripten_HandleKey);
    1.35      emscripten_set_keypress_callback(keyElement, data, 0, Emscripten_HandleKeyPress);
    1.36  
    1.37 -    emscripten_set_fullscreenchange_callback("#document", data, 0, Emscripten_HandleFullscreenChange);
    1.38 +    emscripten_set_fullscreenchange_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, data, 0, Emscripten_HandleFullscreenChange);
    1.39  
    1.40 -    emscripten_set_resize_callback("#window", data, 0, Emscripten_HandleResize);
    1.41 +    emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, data, 0, Emscripten_HandleResize);
    1.42  
    1.43      emscripten_set_visibilitychange_callback(data, 0, Emscripten_HandleVisibilityChange);
    1.44  }
    1.45 @@ -684,35 +684,35 @@
    1.46      emscripten_set_mousemove_callback(data->canvas_id, NULL, 0, NULL);
    1.47  
    1.48      emscripten_set_mousedown_callback(data->canvas_id, NULL, 0, NULL);
    1.49 -    emscripten_set_mouseup_callback("#document", NULL, 0, NULL);
    1.50 +    emscripten_set_mouseup_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, NULL, 0, NULL);
    1.51  
    1.52      emscripten_set_mouseenter_callback(data->canvas_id, NULL, 0, NULL);
    1.53      emscripten_set_mouseleave_callback(data->canvas_id, NULL, 0, NULL);
    1.54  
    1.55      emscripten_set_wheel_callback(data->canvas_id, NULL, 0, NULL);
    1.56  
    1.57 -    emscripten_set_focus_callback("#window", NULL, 0, NULL);
    1.58 -    emscripten_set_blur_callback("#window", NULL, 0, NULL);
    1.59 +    emscripten_set_focus_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, 0, NULL);
    1.60 +    emscripten_set_blur_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, 0, NULL);
    1.61  
    1.62      emscripten_set_touchstart_callback(data->canvas_id, NULL, 0, NULL);
    1.63      emscripten_set_touchend_callback(data->canvas_id, NULL, 0, NULL);
    1.64      emscripten_set_touchmove_callback(data->canvas_id, NULL, 0, NULL);
    1.65      emscripten_set_touchcancel_callback(data->canvas_id, NULL, 0, NULL);
    1.66  
    1.67 -    emscripten_set_pointerlockchange_callback("#document", NULL, 0, NULL);
    1.68 +    emscripten_set_pointerlockchange_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, NULL, 0, NULL);
    1.69  
    1.70      target = SDL_GetHint(SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT);
    1.71      if (!target) {
    1.72 -        target = "#window";
    1.73 +        target = EMSCRIPTEN_EVENT_TARGET_WINDOW;
    1.74      }
    1.75  
    1.76      emscripten_set_keydown_callback(target, NULL, 0, NULL);
    1.77      emscripten_set_keyup_callback(target, NULL, 0, NULL);
    1.78      emscripten_set_keypress_callback(target, NULL, 0, NULL);
    1.79  
    1.80 -    emscripten_set_fullscreenchange_callback("#document", NULL, 0, NULL);
    1.81 +    emscripten_set_fullscreenchange_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, NULL, 0, NULL);
    1.82  
    1.83 -    emscripten_set_resize_callback("#window", NULL, 0, NULL);
    1.84 +    emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, 0, NULL);
    1.85  
    1.86      emscripten_set_visibilitychange_callback(NULL, 0, NULL);
    1.87  }