MacOS Trackpad fixes in SDL demos

Fix lost Trackpad events in the SDL demos, caused by compressing key/button events which shouldn't be compressed.
This commit is contained in:
cblc 2023-04-09 17:21:12 +02:00
parent 821cdf3c15
commit 7844277871
4 changed files with 20 additions and 0 deletions

View File

@ -201,6 +201,11 @@ int main(int argc, char **argv)
break;
}
/* We don't want to compress key up/down nor mouse button up/down buttons,
because MacOS generates two events per Trackpad tap, and they could be lost. */
if((event.type==SDL_MOUSEBUTTONUP)||(event.type==SDL_MOUSEBUTTONDOWN)||
(event.type==SDL_KEYUP)||(event.type==SDL_KEYDOWN)) break;
}
nk_input_end(&(context->ctx));

View File

@ -138,6 +138,11 @@ main(int argc, char *argv[])
while (SDL_PollEvent(&evt)) {
if (evt.type == SDL_QUIT) goto cleanup;
nk_sdl_handle_event(&evt);
/* We don't want to compress key up/down nor mouse button up/down buttons,
because MacOS generates two events per Trackpad tap, and they could be lost. */
if((evt.type==SDL_MOUSEBUTTONUP)||(evt.type==SDL_MOUSEBUTTONDOWN)||
(evt.type==SDL_KEYUP)||(evt.type==SDL_KEYDOWN)) break;
}
nk_input_end(ctx);

View File

@ -149,6 +149,11 @@ int main(int argc, char *argv[])
while (SDL_PollEvent(&evt)) {
if (evt.type == SDL_QUIT) goto cleanup;
nk_sdl_handle_event(&evt);
/* We don't want to compress key up/down nor mouse button up/down buttons,
because MacOS generates two events per Trackpad tap, and they could be lost. */
if((evt.type==SDL_MOUSEBUTTONUP)||(evt.type==SDL_MOUSEBUTTONDOWN)||
(evt.type==SDL_KEYUP)||(evt.type==SDL_KEYDOWN)) break;
} nk_input_end(ctx);
/* GUI */

View File

@ -176,6 +176,11 @@ main(int argc, char *argv[])
while (SDL_PollEvent(&evt)) {
if (evt.type == SDL_QUIT) goto cleanup;
nk_sdl_handle_event(&evt);
/* We don't want to compress key up/down nor mouse button up/down buttons,
because MacOS generates two events per Trackpad tap, and they could be lost. */
if((evt.type==SDL_MOUSEBUTTONUP)||(evt.type==SDL_MOUSEBUTTONDOWN)||
(evt.type==SDL_KEYUP)||(evt.type==SDL_KEYDOWN)) break;
}
nk_input_end(ctx);