Skip to content

Instantly share code, notes, and snippets.

@Kissaki
Created January 5, 2015 23:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kissaki/b56e69bfd0bbd4a372f6 to your computer and use it in GitHub Desktop.
Save Kissaki/b56e69bfd0bbd4a372f6 to your computer and use it in GitHub Desktop.
SDL usage that causes access violation with gamepad attached
#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