src/events/SDL_touch.c
changeset 12701 3477a301a5a8
parent 12700 1223f50edde3
child 12855 ac0c65535817
equal deleted inserted replaced
12700:1223f50edde3 12701:3477a301a5a8
   255                 if (window) {
   255                 if (window) {
   256                     if (down) {
   256                     if (down) {
   257                         if (finger_touching == SDL_FALSE) {
   257                         if (finger_touching == SDL_FALSE) {
   258                             int pos_x = (int)(x * (float)window->w);
   258                             int pos_x = (int)(x * (float)window->w);
   259                             int pos_y = (int)(y * (float)window->h);
   259                             int pos_y = (int)(y * (float)window->h);
   260                             if (pos_x >= 0 && pos_y >= 0 && pos_x < window->w && pos_y < window->h) {
   260                             if (pos_x < 0) pos_x = 0;
   261                                 SDL_SendMouseMotion(window, SDL_TOUCH_MOUSEID, 0, pos_x, pos_y);
   261                             if (pos_x > window->w - 1) pos_x = window->w - 1;
   262                                 SDL_SendMouseButton(window, SDL_TOUCH_MOUSEID, SDL_PRESSED, SDL_BUTTON_LEFT);
   262                             if (pos_y < 0) pos_y = 0;
   263                             }
   263                             if (pos_y > window->h - 1) pos_y = window->h - 1;
       
   264                             SDL_SendMouseMotion(window, SDL_TOUCH_MOUSEID, 0, pos_x, pos_y);
       
   265                             SDL_SendMouseButton(window, SDL_TOUCH_MOUSEID, SDL_PRESSED, SDL_BUTTON_LEFT);
   264                         }
   266                         }
   265                     } else {
   267                     } else {
   266                         if (finger_touching == SDL_TRUE && track_touchid == id && track_fingerid == fingerid) {
   268                         if (finger_touching == SDL_TRUE && track_touchid == id && track_fingerid == fingerid) {
   267                             int pos_x = (int)(x * (float)window->w);
   269                             SDL_SendMouseButton(window, SDL_TOUCH_MOUSEID, SDL_RELEASED, SDL_BUTTON_LEFT);
   268                             int pos_y = (int)(y * (float)window->h);
       
   269                             if (pos_x >= 0 && pos_y >= 0 && pos_x < window->w && pos_y < window->h) {
       
   270                                 SDL_SendMouseButton(window, SDL_TOUCH_MOUSEID, SDL_RELEASED, SDL_BUTTON_LEFT);
       
   271                             }
       
   272                         }
   270                         }
   273                     }
   271                     }
   274                 }
   272                 }
   275                 if (down) {
   273                 if (down) {
   276                     if (finger_touching == SDL_FALSE) {
   274                     if (finger_touching == SDL_FALSE) {
   359                 SDL_Window *window = SDL_GetMouseFocus();
   357                 SDL_Window *window = SDL_GetMouseFocus();
   360                 if (window) {
   358                 if (window) {
   361                     if (finger_touching == SDL_TRUE && track_touchid == id && track_fingerid == fingerid) {
   359                     if (finger_touching == SDL_TRUE && track_touchid == id && track_fingerid == fingerid) {
   362                         int pos_x = (int)(x * (float)window->w);
   360                         int pos_x = (int)(x * (float)window->w);
   363                         int pos_y = (int)(y * (float)window->h);
   361                         int pos_y = (int)(y * (float)window->h);
   364                         if (pos_x >= 0 && pos_y >= 0 && pos_x < window->w && pos_y < window->h) {
   362                         if (pos_x < 0) pos_x = 0;
   365                             SDL_SendMouseMotion(window, SDL_TOUCH_MOUSEID, 0, pos_x, pos_y);
   363                         if (pos_x > window->w - 1) pos_x = window->w - 1;
   366                         }
   364                         if (pos_y < 0) pos_y = 0;
       
   365                         if (pos_y > window->h - 1) pos_y = window->h - 1;
       
   366                         SDL_SendMouseMotion(window, SDL_TOUCH_MOUSEID, 0, pos_x, pos_y);
   367                     }
   367                     }
   368                 }
   368                 }
   369             }
   369             }
   370         }
   370         }
   371     }
   371     }