+
+ if (read(joystick_device, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
+ {
+ joystick_status = JOYSTICK_OFF;
+ goto error_out;
+ }
+
+ new_joystick_xleft = MIN(new_joystick_xleft, joy_ctrl.x);
+ new_joystick_xright = MAX(new_joystick_xright, joy_ctrl.x);
+ new_joystick_yupper = MIN(new_joystick_yupper, joy_ctrl.y);
+ new_joystick_ylower = MAX(new_joystick_ylower, joy_ctrl.y);
+
+ new_joystick_xmiddle =
+ new_joystick_xleft + (new_joystick_xright - new_joystick_xleft) / 2;
+ new_joystick_ymiddle =
+ new_joystick_yupper + (new_joystick_ylower - new_joystick_yupper) / 2;
+
+ joystick[setup.joystick_nr].xleft = new_joystick_xleft;
+ joystick[setup.joystick_nr].yupper = new_joystick_yupper;
+ joystick[setup.joystick_nr].xright = new_joystick_xright;
+ joystick[setup.joystick_nr].ylower = new_joystick_ylower;
+ joystick[setup.joystick_nr].xmiddle = new_joystick_xmiddle;
+ joystick[setup.joystick_nr].ymiddle = new_joystick_ymiddle;
+
+ CheckJoystickData();
+
+ joy = Joystick();
+
+ if (joy & JOY_BUTTON && check_remaining == 0)
+ result = 1;
+
+ x = (joy & JOY_LEFT ? -1 : joy & JOY_RIGHT ? +1 : 0);
+ y = (joy & JOY_UP ? -1 : joy & JOY_DOWN ? +1 : 0);
+
+ if (x != last_x || y != last_y)
+ {
+ DrawGraphic(xpos + last_x, ypos + last_y, GFX_KUGEL_GELB);
+ DrawGraphic(xpos + x, ypos + y, GFX_KUGEL_ROT);
+
+ last_x = x;
+ last_y = y;
+
+ if (check_remaining > 0 && !check[x+1][y+1])
+ {
+ check[x+1][y+1] = TRUE;
+ check_remaining--;
+ }
+
+#if 0
+ printf("LEFT / MIDDLE / RIGHT == %d / %d / %d\n",
+ joystick[setup.joystick_nr].xleft,
+ joystick[setup.joystick_nr].xmiddle,
+ joystick[setup.joystick_nr].xright);
+ printf("UP / MIDDLE / DOWN == %d / %d / %d\n",
+ joystick[setup.joystick_nr].yupper,
+ joystick[setup.joystick_nr].ymiddle,
+ joystick[setup.joystick_nr].ylower);
+#endif
+ }
+
+ BackToFront();
+ DoAnimation();
+
+ /* don't eat all CPU time */
+ Delay(10);