1 /* 2 * Copyright 2006 Serge van den Boom <svdb@stack.nl> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 */ 18 19 #ifndef UQM_SUPERMELEE_NETPLAY_NETINPUT_H_ 20 #define UQM_SUPERMELEE_NETPLAY_NETINPUT_H_ 21 22 #include "../../controls.h" 23 // for BATTLE_INPUT_STATE 24 #include "../../init.h" 25 26 #if defined(__cplusplus) 27 extern "C" { 28 #endif 29 // for NUM_PLAYERS 30 31 typedef struct BattleInputBuffer { 32 BATTLE_INPUT_STATE *buf; 33 // Cyclic buffer. if 'size' > 0, then 'first' is an index to 34 // the first used entry, 'size' is the number of used 35 // entries in the buffer, and (first + size) % maxSize is the 36 // index to just past the end of the buffer. 37 size_t maxSize; 38 size_t first; 39 size_t size; 40 } BattleInputBuffer; 41 42 void setBattleInputDelay(size_t delay); 43 size_t getBattleInputDelay(void); 44 void initBattleInputBuffers(void); 45 void uninitBattleInputBuffers(void); 46 bool BattleInputBuffer_push(BattleInputBuffer *bib, 47 BATTLE_INPUT_STATE input); 48 bool BattleInputBuffer_pop(BattleInputBuffer *bib, 49 BATTLE_INPUT_STATE *input); 50 51 BattleInputBuffer *getBattleInputBuffer(size_t player); 52 53 #if defined(__cplusplus) 54 } 55 #endif 56 57 #endif /* UQM_SUPERMELEE_NETPLAY_NETINPUT_H_ */ 58