/* Review shim, not part of Nuked-MD. LD_PRELOADed into the stock CMake-built Nuked-MD executable; wraps SDL_PollEvent so that one SDL_KEYUP for scancode $KEY_SCANCODE is delivered KEY_AT ms after the first poll and an SDL_QUIT at QUIT_AT ms. Everything else goes to the real SDL_PollEvent. This exercises controller.c and the real F5/F7 path in the real PIE binary. */ #define _GNU_SOURCE #include #include #include #include static int (*real_poll)(SDL_Event *) = NULL; static Uint32 t0 = 0; static int key_done = 0, quit_done = 0; int SDL_PollEvent(SDL_Event *ev) { if (!real_poll) real_poll = dlsym(RTLD_NEXT, "SDL_PollEvent"); if (!t0) t0 = SDL_GetTicks(); Uint32 now = SDL_GetTicks() - t0; const char *k = getenv("KEY_SCANCODE"), *ka = getenv("KEY_AT"), *qa = getenv("QUIT_AT"); if (!key_done && k && ka && now >= (Uint32)atoi(ka)) { key_done = 1; SDL_zero(*ev); ev->type = SDL_KEYUP; ev->key.keysym.scancode = (SDL_Scancode)atoi(k); fprintf(stderr, "shim: injected KEYUP scancode %d at %u ms\n", atoi(k), now); return 1; } if (!quit_done && qa && now >= (Uint32)atoi(qa)) { quit_done = 1; SDL_zero(*ev); ev->type = SDL_QUIT; fprintf(stderr, "shim: injected QUIT at %u ms\n", now); return 1; } return real_poll(ev); }