InputManager.h
Go to the documentation of this file.00001 00016 #ifndef __InputManager_H__ 00017 #define __InputManager_H__ 00018 00019 // Includes 00020 #include "Singleton.h" 00021 #include "Array.h" 00022 #include "KeyCodes.h" 00023 00024 // Forward declares 00025 class Platform_Input_MouseDevice; 00026 class Platform_Input_KeyboardDevice; 00027 00028 00029 // InputManager 00030 class InputManager:public Singleton<InputManager> 00031 { 00032 public: 00033 InputManager(); 00034 virtual ~InputManager(); 00035 00036 void Update(); 00037 00038 float GetCursorX(); 00039 00040 float GetCursorY(); 00041 00042 00043 bool IsKeyDown( 00044 KeyCode key 00045 ); 00046 00047 bool WasKeyPressed( 00048 KeyCode key 00049 ); 00050 00051 bool WasKeyReleased( 00052 KeyCode key 00053 ); 00054 00055 bool IsAnyKeyDown(); 00056 00057 bool WasAnyKeyPressed(); 00058 00059 bool WasAnyKeyReleased(); 00060 00061 bool IsCharDown( 00062 unsigned char ascii 00063 ); 00064 00065 bool WasCharPressed( 00066 unsigned char ascii 00067 ); 00068 00069 bool WasCharReleased( 00070 unsigned char ascii 00071 ); 00072 00073 00074 void ClearCharacters(); 00075 00076 int GetCharacterCount(); 00077 00078 char GetCharacter( 00079 int index 00080 ); 00081 00082 void CreateCursor(int id, const char* image, int hotspotX, int hotspotY); 00083 00084 void SetCursor(int id); 00085 00086 void ShowCursor(); 00087 00088 void HideCursor(); 00089 00090 void RestoreCursor(); 00091 00092 private: 00093 const Platform_Input_MouseDevice* mouseDevice_; 00094 const Platform_Input_KeyboardDevice* keyboardDevice_; 00095 float cursorPosX_; 00096 float cursorPosY_; 00097 bool keyStates_[KEYCODE_COUNT]; 00098 bool previousKeyStates_[KEYCODE_COUNT]; 00099 bool charStates_[256]; 00100 bool previousCharStates_[256]; 00101 00102 Array<char> characterBuffer_; 00103 00104 struct Cursor 00105 { 00106 int id; 00107 int handle; 00108 }; 00109 Array<Cursor> cursors_; 00110 int currentCursor_; 00111 bool cursorHidden_; 00112 }; 00113 00114 #define siInputManager InputManager::GetInstance() 00115 00116 00117 #endif /* __INPUTHANDLER_H__ */
Reproduction/republishing of any material on this site without permission is strictly prohibited.
