+ boolean anyTextGadgetActiveOrJustFinished = anyTextGadgetActive();
+ static struct SetupKeyboardInfo custom_key;
+ static struct
+ {
+ Key *key_custom;
+ Key key_default;
+ byte action;
+ } key_info[] =
+ {
+ { &custom_key.left, DEFAULT_KEY_LEFT, JOY_LEFT },
+ { &custom_key.right, DEFAULT_KEY_RIGHT, JOY_RIGHT },
+ { &custom_key.up, DEFAULT_KEY_UP, JOY_UP },
+ { &custom_key.down, DEFAULT_KEY_DOWN, JOY_DOWN },
+ { &custom_key.snap, DEFAULT_KEY_SNAP, JOY_BUTTON_1 },
+ { &custom_key.bomb, DEFAULT_KEY_BOMB, JOY_BUTTON_2 }
+ };
+
+ if (game_status == GAME_MODE_PLAYING)
+ {
+ /* only needed for single-step tape recording mode */
+ static boolean clear_button_2[MAX_PLAYERS] = { FALSE,FALSE,FALSE,FALSE };
+ static boolean bomb_placed[MAX_PLAYERS] = { FALSE,FALSE,FALSE,FALSE };
+ int pnr;
+
+ for (pnr=0; pnr<MAX_PLAYERS; pnr++)
+ {
+ int i;
+ byte key_action = 0;
+
+ if (setup.input[pnr].use_joystick)
+ continue;
+
+ custom_key = setup.input[pnr].key;
+
+ for (i=0; i<6; i++)
+ if (key == *key_info[i].key_custom)
+ key_action |= key_info[i].action;
+
+ if (tape.single_step && clear_button_2[pnr])
+ {
+ stored_player[pnr].action &= ~KEY_BUTTON_2;
+ clear_button_2[pnr] = FALSE;
+ }
+
+ if (key_status == KEY_PRESSED)
+ stored_player[pnr].action |= key_action;
+ else
+ stored_player[pnr].action &= ~key_action;
+
+ if (tape.single_step && tape.recording && tape.pausing)
+ {
+ if (key_status == KEY_PRESSED &&
+ (key_action & (KEY_MOTION | KEY_BUTTON_1)))
+ {
+ TapeTogglePause(TAPE_TOGGLE_AUTOMATIC);
+
+ if (key_action & KEY_MOTION)
+ {
+ if (stored_player[pnr].action & KEY_BUTTON_2)
+ bomb_placed[pnr] = TRUE;
+ }
+ }
+ else if (key_status == KEY_RELEASED &&
+ (key_action & KEY_BUTTON_2))
+ {
+ if (!bomb_placed[pnr])
+ {
+ TapeTogglePause(TAPE_TOGGLE_AUTOMATIC);