Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _GNU_SOURCE
- #include <dlfcn.h>
- #include <SDL/SDL.h>
- // pointer to the real function
- Uint8* (*real_SDL_GetKeyState) (int *numkeys) = NULL;
- void __attribute__ ((constructor)) jail_init(void)
- {
- // match the library name loaded by our binary target
- dlopen("libSDL-1.2.so.0", RTLD_LAZY);
- real_SDL_GetKeyState = dlsym(RTLD_NEXT, "SDL_GetKeyState");
- }
- // the wrapper
- Uint8* SDL_GetKeyState (int *numkeys)
- {
- Uint8* keys;
- SDL_GrabMode mode;
- keys = (*real_SDL_GetKeyState)(numkeys);
- if ((keys[SDLK_LCTRL] && keys[SDLK_SPACE])|| keys[SDLK_RCTRL])
- {
- keys[SDLK_SPACE] = 0;
- mode = SDL_WM_GrabInput(SDL_GRAB_QUERY);
- SDL_WM_GrabInput(mode == SDL_GRAB_OFF ? SDL_GRAB_ON : SDL_GRAB_OFF);
- }
- return keys;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement