src/video/emscripten/SDL_emscriptenevents.c
changeset 10629 813f1b3c63aa
parent 10541 727f7d796b8d
child 10737 3406a0f8b041
     1.1 --- a/src/video/emscripten/SDL_emscriptenevents.c	Thu Nov 17 17:03:43 2016 -0500
     1.2 +++ b/src/video/emscripten/SDL_emscriptenevents.c	Fri Nov 18 00:05:28 2016 +0100
     1.3 @@ -336,7 +336,10 @@
     1.4  Emscripten_HandleMouseButton(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData)
     1.5  {
     1.6      SDL_WindowData *window_data = userData;
     1.7 -    uint32_t sdl_button;
     1.8 +    Uint8 sdl_button;
     1.9 +    Uint8 sdl_button_state;
    1.10 +    SDL_EventType sdl_event_type;
    1.11 +
    1.12      switch (mouseEvent->button) {
    1.13          case 0:
    1.14              sdl_button = SDL_BUTTON_LEFT;
    1.15 @@ -351,8 +354,14 @@
    1.16              return 0;
    1.17      }
    1.18  
    1.19 -    SDL_EventType sdl_event_type = (eventType == EMSCRIPTEN_EVENT_MOUSEDOWN ? SDL_PRESSED : SDL_RELEASED);
    1.20 -    SDL_SendMouseButton(window_data->window, 0, sdl_event_type, sdl_button);
    1.21 +    if (eventType == EMSCRIPTEN_EVENT_MOUSEDOWN) {
    1.22 +        sdl_button_state = SDL_PRESSED;
    1.23 +        sdl_event_type = SDL_MOUSEBUTTONDOWN;
    1.24 +    } else {
    1.25 +        sdl_button_state = SDL_RELEASED;
    1.26 +        sdl_event_type = SDL_MOUSEBUTTONUP;
    1.27 +    }
    1.28 +    SDL_SendMouseButton(window_data->window, 0, sdl_button_state, sdl_button);
    1.29      return SDL_GetEventState(sdl_event_type) == SDL_ENABLE;
    1.30  }
    1.31