src/video/emscripten/SDL_emscriptenevents.c
changeset 10266 c09f06c4e8c8
parent 9998 f67cf37e9cd4
equal deleted inserted replaced
10265:1b8594db77f1 10266:c09f06c4e8c8
   389 
   389 
   390         id = touchEvent->touches[i].identifier;
   390         id = touchEvent->touches[i].identifier;
   391         x = touchEvent->touches[i].canvasX / (float)window_data->windowed_width;
   391         x = touchEvent->touches[i].canvasX / (float)window_data->windowed_width;
   392         y = touchEvent->touches[i].canvasY / (float)window_data->windowed_height;
   392         y = touchEvent->touches[i].canvasY / (float)window_data->windowed_height;
   393 
   393 
   394         if (eventType == EMSCRIPTEN_EVENT_TOUCHMOVE) {
   394         if (eventType == EMSCRIPTEN_EVENT_TOUCHSTART) {
       
   395             if (!window_data->finger_touching) {
       
   396                 window_data->finger_touching = SDL_TRUE;
       
   397                 window_data->first_finger = id;
       
   398                 SDL_SendMouseMotion(window_data->window, SDL_TOUCH_MOUSEID, 0, x, y);
       
   399                 SDL_SendMouseButton(window_data->window, SDL_TOUCH_MOUSEID, SDL_PRESSED, SDL_BUTTON_LEFT);
       
   400             }
       
   401             SDL_SendTouch(deviceId, id, SDL_TRUE, x, y, 1.0f);
       
   402         } else if (eventType == EMSCRIPTEN_EVENT_TOUCHMOVE) {
       
   403             if ((window_data->finger_touching) && (window_data->first_finger == id)) {
       
   404                 SDL_SendMouseMotion(window_data->window, SDL_TOUCH_MOUSEID, 0, x, y);
       
   405             }
   395             SDL_SendTouchMotion(deviceId, id, x, y, 1.0f);
   406             SDL_SendTouchMotion(deviceId, id, x, y, 1.0f);
   396         } else if (eventType == EMSCRIPTEN_EVENT_TOUCHSTART) {
       
   397             SDL_SendTouch(deviceId, id, SDL_TRUE, x, y, 1.0f);
       
   398         } else {
   407         } else {
       
   408             if ((window_data->finger_touching) && (window_data->first_finger == id)) {
       
   409                 SDL_SendMouseButton(window_data->window, SDL_TOUCH_MOUSEID, SDL_RELEASED, SDL_BUTTON_LEFT);
       
   410                 window_data->finger_touching = SDL_FALSE;
       
   411             }
   399             SDL_SendTouch(deviceId, id, SDL_FALSE, x, y, 1.0f);
   412             SDL_SendTouch(deviceId, id, SDL_FALSE, x, y, 1.0f);
   400         }
   413         }
   401     }
   414     }
   402 
   415 
   403 
   416