Do you sync() after saving?
Use SDL_GetTicks() to time the last button press and after a certain time trigger the action again.
I made a Joystick class in gmenu2x for this purpose, you may take a look at it if you're interested.
Reading battery status is very unreliable.
I managed to get a...