Open
Description
Hi,
I'm having issues with SDL2 touch inputs on linux. Using SDL 2.30.9 touch events stops appearing after calling SDL_CaptureMouse. Originally thought this was a bug in Dear Imgui which is tracked in ocornut/imgui#8150. But it seems to be a SDL2 problem. SDL3 works. Also SDL2 works correctly on windows.
The attached test program gives the following output and nothing more. Even when there is multiple taps on the screen.
Mouse down which=-1 button=1
Mouse down which=0 button=1
Mouse up which=0 button=1
Test program, which is a distilled version of what imgui does.
#include <SDL.h>
#include <stdio.h>
int main(int argc, char** argv) {
if (SDL_Init(SDL_INIT_EVERYTHING) != 0) {
printf("SDL_Init Error: %s\n", SDL_GetError());
return 1;
}
SDL_Window* window = NULL;
SDL_Renderer* renderer = NULL;
if (SDL_CreateWindowAndRenderer(1280, 720, SDL_WINDOW_RESIZABLE, &window, &renderer) != 0) {
printf("SDL_CreateWindowAndRenderer Error: %s\n", SDL_GetError());
return 1;
}
int mousebuttons = 0;
while (true) {
SDL_Event event;
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_QUIT:
case SDL_KEYDOWN:
goto out;
case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEBUTTONUP:
printf("Mouse %s which=%d button=%d\n", event.type == SDL_MOUSEBUTTONDOWN ? "down" : "up", event.button.which, event.button.button);
mousebuttons = (event.type == SDL_MOUSEBUTTONDOWN) ? (mousebuttons | (1 << event.button.button)) : (mousebuttons & ~(1 << event.button.button));
break;
}
}
SDL_CaptureMouse(mousebuttons ? SDL_TRUE : SDL_FALSE);
SDL_RenderClear(renderer);
SDL_RenderPresent(renderer);
}
out:
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
SDL_Quit();
return 0;
}
Metadata
Metadata
Assignees
Labels
No labels