Skip to content

Instantly share code, notes, and snippets.

@Kissaki Kissaki/Source.cpp
Created Jan 5, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.