SDL_FINGERDOWN无法正确注册

时间:2018-08-20 02:10:49

标签: c++ sdl sdl-2

我不为什么SDL_FINGERDOWN记录 甚至简单的触摸事件。就像名字所说的,它应该在滑动手指上注册,对吗?我使用android N进行测试。 这是我的代码

#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();
}

1 个答案:

答案 0 :(得分:0)

您对SDL_FINGERDOWN和SDL_FINGERUP的含义有误解。 当您将手指放在触摸屏上时,这是SDL_FINGERDOWN类型的事件。当您从触摸屏上抬起手指时,则是SDL_FINGERUP类型的事件。