Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __SP_UTILITY_INPUTSERVICE_H__
00009 #define __SP_UTILITY_INPUTSERVICE_H__
00010
00011
00012 #include "Base/spStandard.hpp"
00013
00014 #ifdef SP_COMPILE_WITH_INPUTSERVICE
00015
00016
00017 #include "Base/spInputOutputControl.hpp"
00018
00019 #include <map>
00020
00021
00022 namespace sp
00023 {
00024 namespace tool
00025 {
00026
00027
00086 class SP_EXPORT InputService
00087 {
00088
00089 public:
00090
00091
00092
00094 struct SP_EXPORT SEvent
00095 {
00096 SEvent();
00097 ~SEvent();
00098
00099
00100 bool operator == (const SEvent &Other) const;
00101
00102
00103 io::EInputTypes Type;
00104 s32 KeyCode;
00105
00106 #ifdef SP_COMPILE_WITH_XBOX360GAMEPAD
00107 s32 Number;
00108 #endif
00109 };
00110
00111 typedef std::vector<SEvent> TEventEntry;
00112
00113
00114
00115 InputService();
00116 virtual ~InputService();
00117
00118
00119
00121 void setMaxInputCount(u32 Count);
00122
00124 void addEvent(s32 EventID);
00126 void addEvent(s32 EventID, const io::EKeyCodes KeyCode);
00128 void addEvent(s32 EventID, const io::EMouseKeyCodes MouseKeyCode);
00130 void addEvent(s32 EventID, const io::EMouseWheelMotions MouseWheelMotion);
00132 void addEvent(s32 EventID, const io::EJoystickKeyCodes JoystickKeyCode);
00133
00134 #ifdef SP_COMPILE_WITH_XBOX360GAMEPAD
00135
00136 void addEvent(s32 EventID, const io::EGamePadButtons GamePadKeyCode, s32 Number);
00137 #endif
00138
00147 bool addEventKeyBinding(s32 EventID, s32 Flags = io::INPUTTYPE_ANY);
00148
00150 void resetEvent(s32 EventID);
00152 void removeEvent(s32 EventID);
00153
00155 bool down(s32 EventID);
00157 bool hit(s32 EventID);
00159 bool released(s32 EventID);
00160
00162 TEventEntry getEventEntryList(s32 EventID) const;
00163
00164 protected:
00165
00166
00167
00168 void addEventEntry(s32 EventID, const SEvent &EventEntry);
00169
00170 bool checkForKeyBinding(s32 EventID, s32 FirstIndex, s32 LastIndex);
00171
00172
00173
00174 inline TEventEntry* getEvent(s32 EventID)
00175 {
00176 return &(EventEntryMap_[EventID]);
00177 }
00178
00179
00180
00181 u32 MaxInputCount_;
00182
00183 std::map<s32, TEventEntry> EventEntryMap_;
00184
00185 };
00186
00187
00188 }
00189
00190 }
00191
00192
00193 #endif
00194
00195 #endif
00196
00197
00198
00199