/// keyboard handling #ifndef __INPUT_H__ #define __INPUT_H__ #include "math2d.h" #include /* Add new keys here, a script will parse in the build process name default description INPUT_CONFIGKEYS left "left" "player left" up "up" "player up" right "right" "player right" down "down" "player down" button1 "space" "player button 1" button2 "left alt" "player button 2" fullscreen "f" "toggle fullscreen" quit "escape" "exit" pause "pause" "pause the game" nextFrame "return" "when paused, step by one frame" switchInterface "f10" "switch between 2D and 3D graphics" lookUp "page up" "3D look up" lookDown "page down" "3D look down" zoomIn "home" "3D zoom in" zoomOut "end" "3D zoom out" lessDetails "delete" "3D less details (faster)" moreDetails "insert" "3D more details (slower)" toggleGrid "f3" "3D toggle wire mode (see config too)" debugMode "f2" "enable DEBUG and EDIT mode" growMass "insert" "EDIT grow mass height at mouse cursor" shrinkMass "delete" "EDIT shrink mass height at mouse cursor" killMass "end" "EDIT remove mass immediately at mouse cursor" speedUpMass "page up" "EDIT make the mass faster at mouse cursor" speedDownMass "page down" "EDIT slow the mass down at mouse cursor" deepFryMass "z" "EDIT set speed = 0 and wakeOnPlayer = true" turnHeading "h" "EDIT turn mass heading clockwise" placeMass1 "1" "EDIT place a new mass of type 1 at mouse cursor" placeMass2 "2" "EDIT place a new mass of type 2 at mouse cursor" placeMass3 "3" "EDIT place a new mass of type 3 at mouse cursor" placeMass4 "4" "EDIT place a new mass of type 4 at mouse cursor" placeMass5 "5" "EDIT place a new mass of type 5 at mouse cursor" placeMass6 "6" "EDIT place a new mass of type 6 at mouse cursor" placeMass7 "7" "EDIT place a new mass of type 7 at mouse cursor" placeMass8 "8" "EDIT place a new mass of type 8 at mouse cursor" placeMass9 "9" "EDIT place a new mass of type 9 at mouse cursor" saveGame "f11" "EDIT save game now, filename save.mas" debugZin "[+]" "DEBUG zoom mass profile in" debugZout "[-]" "DEBUG zoom mass profile out" debugCycle "f3" "DEBUG cycle display mode" debugRect "f4" "DEBUG show maxRect" debugScrollLeft "a" "DEBUG scroll visible area left" debugScrollUp "w" "DEBUG scroll visible area up" debugScrollRight "d" "DEBUG scroll visible area right" debugScrollDown "s" "DEBUG scroll visible area down" debugStatistics "f9" "DEBUG print some statistics to stdout" debugParticles "f8" "DEBUG hold traces of particles while pressed" debugTest "f12" "DEBUG does something, don't hit in network game" INPUT_CONFIGKEYS */ typedef struct { // those are read/write from everywhere unsigned int hit : 1; // key is pressed down and wasn't before unsigned int pressed : 1; // key is (still) hold down now unsigned int toggled : 1; // gets inverted when hit unsigned int hits; // total keystrokes since start of the game } KeyState; extern void KeyStateSet(KeyState * p, int newState); extern void KeyStateToggle(KeyState * p); typedef struct { #include "script_keystates.inc" } KeyStates; extern KeyStates key; // Mouse typedef struct { KeyState left; KeyState middle; KeyState right; Point pos; } MouseState; extern MouseState mouse; // for main extern void InitInput(void); extern void UpdateInput(void); extern void DoneInput(void); // for config.c extern char * KeyboardConfigLine(int indent, char * name, char * value); extern void WriteKeyboardConfig(FILE * f); // all keys are set to untoggled, never hit, etc. extern void ResetKeys(void); #endif