+int CheckPlayerButtons(int mx, int my, int button)
+{
+ int return_code = 0;
+ static int choice = -1;
+ static BOOL pressed = FALSE;
+ int player_state[4] =
+ {
+ BUTTON_PLAYER_1,
+ BUTTON_PLAYER_2,
+ BUTTON_PLAYER_3,
+ BUTTON_PLAYER_4
+ };
+
+ if (button)
+ {
+ if (!motion_status) /* Maustaste neu gedrückt */
+ {
+ if (ON_PLAYER_BUTTON(mx,my))
+ {
+ choice = PLAYER_BUTTON(mx,my);
+ pressed = TRUE;
+ DrawPlayerButton(player_state[choice] | BUTTON_PRESSED, DB_NORMAL);
+ }
+ }
+ else /* Mausbewegung bei gedrückter Maustaste */
+ {
+ if ((!ON_PLAYER_BUTTON(mx,my) || PLAYER_BUTTON(mx,my)!=choice) &&
+ choice>=0 && pressed)
+ {
+ pressed = FALSE;
+ DrawPlayerButton(player_state[choice] | BUTTON_RELEASED, DB_NORMAL);
+ }
+ else if (ON_PLAYER_BUTTON(mx,my) && PLAYER_BUTTON(mx,my)==choice && !pressed)
+ {
+ pressed = TRUE;
+ DrawPlayerButton(player_state[choice] | BUTTON_PRESSED, DB_NORMAL);
+ }
+ }
+ }
+ else /* Maustaste wieder losgelassen */
+ {
+ if (ON_PLAYER_BUTTON(mx,my) && PLAYER_BUTTON(mx,my)==choice && pressed)
+ {
+ DrawPlayerButton(player_state[choice] | BUTTON_RELEASED, DB_NORMAL);
+ return_code = player_state[choice];
+ choice = -1;
+ pressed = FALSE;
+ }
+ else
+ {
+ choice = -1;
+ pressed = FALSE;
+ }
+ }
+
+ BackToFront();
+ return(return_code);
+}
+