Skip to content

Commit

Permalink
Commented the ugly code
Browse files Browse the repository at this point in the history
  • Loading branch information
pelya committed Sep 20, 2012
1 parent 7d04504 commit 10f6d46
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions project/jni/sdl-1.3/src/video/android/SDL_androidinput.c
Expand Up @@ -1386,11 +1386,6 @@ const char *SDL_SYS_JoystickName(int index)
return("Android accelerometer/multitouch sensor");
}

/* Function to open a joystick for use.
The joystick to open is specified by the index field of the joystick.
This should fill the nbuttons and naxes fields of the joystick structure.
It returns 0, or -1 if there is an error.
*/
int SDL_SYS_JoystickOpen(SDL_Joystick *joystick)
{
joystick->nbuttons = 0;
Expand All @@ -1410,11 +1405,6 @@ int SDL_SYS_JoystickOpen(SDL_Joystick *joystick)
return(0);
}

/* Function to update the state of a joystick - called as a device poll.
* This function shouldn't update the joystick structure directly,
* but instead should call SDL_PrivateJoystick*() to deliver events
* and update joystick device state.
*/
void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick)
{
return;
Expand Down Expand Up @@ -1454,6 +1444,18 @@ extern SDL_Window * ANDROID_CurrentWindow;

#endif

/* We need our own event queue, because Free Heroes 2 game uses
* SDL_SetEventFilter(), and it calls SDL_Flip() from inside
* it's custom filter function, and SDL_Flip() does not work
* when it's not called from the main() thread.
* So we, like, push the events into our own queue,
* read each event from that queue inside SDL_ANDROID_PumpEvents(),
* unlock the mutex, and push the event to SDL queue,
* which is then immediately read by SDL from the same thread,
* and then SDL invokes event filter function from FHeroes2.
* FHeroes2 call SDL_Flip() from inside that event filter function,
* and it works, because it is called from the main() thread.
*/
extern void SDL_ANDROID_PumpEvents()
{
static int oldMouseButtons = 0;
Expand Down

0 comments on commit 10f6d46

Please sign in to comment.