On android, my event loop is looping forever because SDL_PollEvent keeps returning the same event. Basically I have
Code:
SDL_Event event;
while (SDL_PollEvent(&event) == 1){
…
}
The event I keep getting is 1536, SDL_JOYAXISMOTION. So far I am just running in the emulator. I do not have to actually interact with the emulator to get this event forever.
Any idea why SDL_PollEvent is returning the same event repeatedly?
The android joystick code pushes joystick events that come from the accelerometer every time it its polled which results in a lot of events. This resulted in other events being dropped, like keys, which I depend on so I changed SDL/joystick/android/SDL_sysjoystick.c:SDL_SYS_JoystickUpdate to abort early. I don’t need the accelerometer so this is ok for me.
Code:
void
SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
{
int i;
float values[3];
return;
Android_JNI_GetAccelerometerValues(values);
for ( i = 0; i < 3; i++ ) {
SDL_PrivateJoystickAxis(joystick, i, values[i]);
}