Search code examples
c++sdlsdl-2

SDL_FINGERDOWN not registering correctly


I don't why SDL_FINGERDOWN records even simple touch event. It should register on Sliding finger down as name says, right? I use android N for testing. Here is my code

#include "SDL.h"
#include <SDL2/SDL.h>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
  SDL_Init(SDL_INIT_EVERYTHING);
  int r, g, b;
  r = g = b = 0;
  SDL_Window *window;
  window = SDL_CreateWindow("S", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 720, 1320, SDL_WINDOW_RESIZABLE);
  SDL_Surface *screen = SDL_GetWindowSurface(window);
  Uint32 white = SDL_MapRGB(screen->format, 255, 255, 255);
  SDL_FillRect(screen, NULL, white);
  SDL_UpdateWindowSurface(window);
  SDL_Event event;
  bool running = true;
  while (running)
  {
    while (SDL_PollEvent(&event))
    {
      if (event.type == SDL_FINGERDOWN)
      {
        running = false;
        break;
      }
      //end if
    } //end inner while
  }
  SDL_DestroyWindow(window);
  SDL_Quit();
}

Solution

  • You have misunderstood meaning of SDL_FINGERDOWN and SDL_FINGERUP. When you land your finger on touch screen then that's event of type SDL_FINGERDOWN.When you lift up your finger from touch screen then that's event of type SDL_FINGERUP.