Created
January 5, 2015 23:58
-
-
Save Kissaki/b56e69bfd0bbd4a372f6 to your computer and use it in GitHub Desktop.
SDL usage that causes access violation with gamepad attached
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <SDL.h> | |
int main(int argc, char* args[]) | |
{ | |
// Whether we do SDL_Init before-hand, | |
// initialize the JOYSTICK subsystem in SDL_Init, | |
// or initialize separately like as follows, | |
// ... | |
if (SDL_Init(0) < 0) { | |
std::cout << SDL_GetError(); | |
} | |
if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) < 0) { | |
std::cout << SDL_GetError(); | |
} | |
// A stdout or sleep work respectively. | |
// Without one of these and its delay, the | |
// issue does not occur. | |
//std::cout << "COUT for issue to occur.\n"; | |
SDL_Delay(10); | |
SDL_QuitSubSystem(SDL_INIT_JOYSTICK); | |
SDL_Event event; | |
// ACCESS VIOLATION | |
while (SDL_PollEvent(&event)) | |
{ | |
std::cout << "Event " << event.type << "\n"; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment