00001 00002 extern ::KeyboardMap keyboardMap; 00003 00004 NAMESPACE_START 00005 00007 struct KeyboardInput { 00008 bool keysUp[256]; 00009 bool change; 00010 }; 00011 00013 class KeyboardDevice : 00014 public ::KeyboardDevice { 00015 public: 00016 KeyboardDevice(); 00017 virtual ~KeyboardDevice(); 00018 00019 inline void setKeysDown(::KEYBTN key, bool b){this->keysDown[key] = b;} 00020 inline void setKeysUp(::KEYBTN key, bool b){input[readTarget].keysUp[key] = b;} 00021 inline void setChanged(bool b){input[readTarget].change = b;} 00022 00023 inline bool getKeysDown(::KEYBTN key){return this->keysDown[key];} 00024 inline bool getKeysUp(::KEYBTN key){return input[readTarget].keysUp[key];} 00025 inline bool getChanged(void){return input[readTarget].change;} 00026 00027 inline void reset(void){ 00028 for(int i=0; i<256; i++) 00029 input[readTarget].keysUp[i] = false; 00030 input[readTarget].change = false; 00031 } 00032 00033 inline void copy(void){ 00034 for(int i=0; i<256; i++) 00035 this->keysUp[i] = input[readTarget].keysUp[i]; 00036 this->change = getChanged(); 00037 } 00038 00039 void update(bool reset); 00040 00041 ::pKeyboardDevice asKeyboardDevice(){return this;} 00042 00043 private: 00044 KeyboardInput input[2]; 00045 int writeTarget; 00046 int readTarget; 00047 }; 00048 00049 NAMESPACE_END