void DoInput (void *pInputState, BOOLEAN resetInput) { if (resetInput) FlushInput (); do { MENU_SOUND_FLAGS soundFlags; Async_process (); TaskSwitch (); UpdateInputState (); #if DEMO_MODE || CREATE_JOURNAL if (ArrowInput != DemoInput) #endif { #if CREATE_JOURNAL JournalInput (InputState); #endif /* CREATE_JOURNAL */ } soundFlags = MenuKeysToSoundFlags (&PulsedInputState); if (MenuSounds && (soundFlags & (sound_0 | sound_1))) { SOUND S; S = MenuSounds; if (soundFlags & sound_1) S = SetAbsSoundIndex (S, MENU_SOUND_SUCCESS); PlaySoundEffect (S, 0, NotPositional (), NULL, 0); } if (inputCallback) inputCallback (); } while (((INPUT_STATE_DESC*)pInputState)->InputFunc (pInputState)); if (resetInput) FlushInput (); }
static void ProcessInput (void) { BOOLEAN CanRunAway; size_t sideI; #ifdef NETPLAY netInput (); #endif CanRunAway = RunAwayAllowed (); for (sideI = 0; sideI < NUM_SIDES; sideI++) { HSTARSHIP hBattleShip, hNextShip; size_t cur_player = battleInputOrder[sideI]; for (hBattleShip = GetHeadLink (&race_q[cur_player]); hBattleShip != 0; hBattleShip = hNextShip) { BATTLE_INPUT_STATE InputState; STARSHIP *StarShipPtr; StarShipPtr = LockStarShip (&race_q[cur_player], hBattleShip); hNextShip = _GetSuccLink (StarShipPtr); if (StarShipPtr->hShip) { // TODO: review and see if we have to do this every frame, or // if we can do this once somewhere StarShipPtr->control = PlayerControl[cur_player]; InputState = PlayerInput[cur_player]->handlers->frameInput ( PlayerInput[cur_player], StarShipPtr); #if CREATE_JOURNAL JournalInput (InputState); #endif /* CREATE_JOURNAL */ #ifdef NETPLAY if (!(PlayerControl[cur_player] & NETWORK_CONTROL)) { BattleInputBuffer *bib = getBattleInputBuffer(cur_player); Netplay_NotifyAll_battleInput (InputState); flushPacketQueues (); BattleInputBuffer_push (bib, InputState); // Add this input to the end of the buffer. BattleInputBuffer_pop (bib, &InputState); // Get the input from the front of the buffer. } #endif StarShipPtr->ship_input_state = 0; if (StarShipPtr->RaceDescPtr->ship_info.crew_level) { if (InputState & BATTLE_LEFT) StarShipPtr->ship_input_state |= LEFT; else if (InputState & BATTLE_RIGHT) StarShipPtr->ship_input_state |= RIGHT; if (InputState & BATTLE_THRUST) StarShipPtr->ship_input_state |= THRUST; if (InputState & BATTLE_WEAPON) StarShipPtr->ship_input_state |= WEAPON; if (InputState & BATTLE_SPECIAL) StarShipPtr->ship_input_state |= SPECIAL; if (InputState & BATTLE_DOWN) StarShipPtr->ship_input_state |= DOWN; // JMS_KEYS: Down key is now in use! if (CanRunAway && cur_player == 0 && (InputState & BATTLE_ESCAPE)) DoRunAway (StarShipPtr); } } UnlockStarShip (&race_q[cur_player], hBattleShip); } } #ifdef NETPLAY flushPacketQueues (); #endif if (GLOBAL (CurrentActivity) & (CHECK_LOAD | CHECK_ABORT)) GLOBAL (CurrentActivity) &= ~IN_BATTLE; }