+static double joystick_last_x = 0, joystick_last_y = 0;
+static int joystick_last_fire = 0;
+
+static void joystick_sdl(double x, double y, int fire)
+{
+ int left = -1, right = -1, up = -1, down = -1;
+
+ if (x <= -0.5 && joystick_last_x > -0.5)
+ left = 1;
+ if (x > -0.5 && joystick_last_x <= -0.5)
+ left = 0;
+ if (x >= 0.5 && joystick_last_x < 0.5)
+ right = 1;
+ if (x < 0.5 && joystick_last_x >= 0.5)
+ right = 0;
+ if (y <= -0.5 && joystick_last_y > -0.5)
+ up = 1;
+ if (y > -0.5 && joystick_last_y <= -0.5)
+ up = 0;
+ if (y >= 0.5 && joystick_last_y < 0.5)
+ down = 1;
+ if (y < 0.5 && joystick_last_y >= 0.5)
+ down = 0;
+ set_joystick(left, right, up, down, fire);
+ joystick_last_x = x;
+ joystick_last_y = y;
+ joystick_last_fire = fire;
+}
+