Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00039 #ifndef _CE_INPUTCORE_IMPL_H_
00040 #define _CE_INPUTCORE_IMPL_H_ 0x1
00042 #ifndef __cplusplus
00043 #error ceInputCoreImpl.h requires C++ compilation (use a .cpp suffix)
00044 #endif
00045
00046 #if __GNUC__ >= 0x3
00047 #pragma GCC system_header
00048 #endif
00049
00050 #if _MSC_VER > 1000
00051 #pragma once
00052 #pragma warning(disable: 4100)
00053 #endif
00054
00055 #include "ceInputCore.h"
00056
00057 namespace ce {
00058
00059
00060
00061 #define CE_INPUT_VERIFY 0x1
00062
00066 template <class T>
00067 class IInputManagerImpl :
00068 protected IKeyboardEvent,
00069 protected IMouseEvent,
00070 protected IJoystickEvent
00071 {
00072 public:
00073
00074 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00075 IInputManagerImpl(void)
00076 {
00077 this -> pT = static_cast<T*>(this);
00078
00079 this -> pT -> Input = CreateInputManager();
00080 if (!this -> pT -> Input) return;
00081
00082 #ifndef CE_WITHOUT_KEYBOARD
00083 this -> pT -> Keyboard = this -> pT -> Input -> GetKeyboardDevice();
00084 this -> pT -> Keyboard -> SetKeyboardEvent(this -> pT);
00085 #endif
00086 #ifndef CE_WITHOUT_MOUSE
00087 this -> pT -> Mouse = this -> pT -> Input -> GetMouseDevice();
00088 this -> pT -> Mouse -> SetMouseEvent(this -> pT);
00089 #endif
00090 #ifndef CE_WITHOUT_JOYSTICK
00091 this -> pT -> Joystick = this -> pT -> Input -> GetJoystickDevice();
00092 this -> pT -> Joystick -> SetJoystickEvent(this -> pT);
00093 #endif
00094 };
00095
00096 virtual ~IInputManagerImpl(void)
00097 { DestroyInputManager(&this -> pT -> Input); };
00098 #endif
00099
00100 #ifdef CE_INPUT_VERIFY
00101
00105 inline const short APICALL
00106 VerifyInputManager(void) const
00107 {
00108 if (!this -> pT -> Input) return FALSE;
00109 #ifndef CE_WITHOUT_KEYBOARD
00110 if (!this -> pT -> Keyboard) return FALSE;
00111 #endif
00112 #ifndef CE_WITHOUT_MOUSE
00113 if (!this -> pT -> Mouse) return FALSE;
00114 #endif
00115 #ifndef CE_WITHOUT_JOYSTICK
00116 if (!this -> pT -> Joystick) return FALSE;
00117 #endif
00118 return TRUE;
00119 };
00120 #endif
00121
00126 inline short APICALL
00127 SetInputDriver(const EInputDriver driver = InputDriver_Null) const
00128 { return this -> pT -> Input -> SetInputDriver(driver); };
00129
00134 inline EInputDriver APICALL
00135 GetDriverType(void) const
00136 { return this -> pT -> Input -> GetDriverType(); };
00137
00141 inline IInputDevice* APICALL
00142 GetInputDevice(const EInputDevice device) const
00143 { return this -> pT -> Input -> GetInputDevice(device); };
00144
00146 inline void APICALL
00147 Update(void) const
00148 { this -> pT -> Input -> Update(); };
00149
00150 #ifndef CE_WITHOUT_KEYBOARD
00151
00155 inline IKeyboardDevice* APICALL
00156 GetKeyboardDevice(void) const
00157 { return this -> pT -> Input -> GetKeyboardDevice(); };
00158
00160 inline void APICALL
00161 UpdateKeyboar(void) const
00162 { this -> pT -> Input -> UpdateKeyboar(); };
00163 #endif
00164
00165 #ifndef CE_WITHOUT_MOUSE
00166
00170 inline IMouseDevice* APICALL
00171 GetMouseDevice(void) const
00172 { return this -> pT -> Input -> GetMouseDevice(); };
00173
00175 inline void APICALL
00176 UpdateMouse(void) const
00177 { this -> pT -> Input -> UpdateMouse(); };
00178 #endif
00179
00180 #ifndef CE_WITHOUT_JOYSTICK
00181
00185 inline IJoystickDevice* APICALL
00186 GetJoystickDevice(void) const
00187 { return this -> pT -> Input -> GetJoystickDevice(); };
00188
00190 inline void APICALL
00191 UpdateJoystick(void) const
00192 { this -> pT -> Input -> UpdateJoystick(); };
00193 #endif
00194
00195 protected:
00196
00197 IInputManager *Input;
00198
00199 #ifndef CE_WITHOUT_KEYBOARD
00200 IKeyboardDevice *Keyboard;
00201
00202 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00203 inline void APICALL
00204 OnKeyPressed(const IKeyboardDevice *Owner,
00205 const int key, const int buffer[256]) { };
00206
00207 inline void APICALL
00208 OnKeyReleased(const IKeyboardDevice *Owner,
00209 const int key, const int buffer[256]) { };
00210
00211 inline void APICALL
00212 OnKeyEvent(const IKeyboardDevice *Owner, const int buffer[256]) { };
00213 #endif // DOXYGEN_SHOULD_SKIP_THIS
00214 #endif // CE_WITHOUT_KEYBOARD
00215
00216 #ifndef CE_WITHOUT_MOUSE
00217 IMouseDevice *Mouse;
00218
00219 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00220 inline void APICALL
00221 OnButtonPressed(const IMouseDevice *Owner,
00222 const int button, const SMouseState &State) { };
00223
00224 inline void APICALL
00225 OnButtonReleased(const IMouseDevice *Owner,
00226 const int button, const SMouseState &State) { };
00227
00228 inline void APICALL
00229 OnMouseEvent(const IMouseDevice *Owner, const SMouseState &State) { };
00230 #endif // DOXYGEN_SHOULD_SKIP_THIS
00231 #endif // CE_WITHOUT_MOUSE
00232
00233 #ifndef CE_WITHOUT_JOYSTICK
00234 IJoystickDevice *Joystick;
00235
00236 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00237 inline void APICALL
00238 OnJoyButtonPressed(const IJoystickDevice *Owner, const int joyid,
00239 const unsigned int button, const SJoystickState &State) { };
00240
00241 inline void APICALL
00242 OnJoyButtonReleased(const IJoystickDevice *Owner, const int joyid,
00243 const unsigned int button, const SJoystickState &State) { };
00244
00245 inline void APICALL
00246 OnJoystickEvent(const IJoystickDevice *Owner,
00247 const int joyid, const SJoystickState &State) { };
00248 #endif // DOXYGEN_SHOULD_SKIP_THIS
00249 #endif // CE_WITHOUT_JOYSTICK
00250
00251 private:
00252
00253 T *pT;
00254
00255 DISALLOW_COPY_AND_ASSIGN(IInputManagerImpl);
00256 };
00257
00258
00259
00260 }
00261
00262 #if _MSC_VER > 1000
00263 #pragma warning(default:4100)
00264 #endif
00265
00266 #endif // _CE_INPUTCORE_IMPL_H_