- Timestamp:
- Mar 31, 2010, 1:05:28 AM (15 years ago)
- Location:
- code/branches/gamestates2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/gamestates2
- Property svn:mergeinfo changed
/code/branches/gamestate merged: 6621-6630,6655-6661
- Property svn:mergeinfo changed
-
code/branches/gamestates2/src/libraries/core/input/InputState.h
r6595 r6662 35 35 #include <string> 36 36 #include <vector> 37 38 #include "util/OrxEnum.h" 37 #include <boost/function.hpp> 38 #include <boost/bind.hpp> 39 39 40 #include "util/TriBool.h" 40 41 #include "InputHandler.h" 42 #include "InputManager.h" 41 43 #include "JoyStickQuantityListener.h" 44 45 #define INPUT_STATE_PUSH_CALL(deviceIndex, functionName, ...) \ 46 InputManager::getInstance().pushCall(boost::function<void ()>(boost::bind(&InputHandler::functionName, handlers_[deviceIndex], __VA_ARGS__))) 42 47 43 48 namespace orxonox 44 49 { 45 //! Enumeration wrapper for input state priorities46 struct InputStatePriority : OrxEnum<InputStatePriority>47 {48 OrxEnumConstructors(InputStatePriority);49 50 static const int Empty = -1;51 static const int Dynamic = 0;52 53 static const int HighPriority = 1000;54 static const int Console = HighPriority + 0;55 static const int Calibrator = HighPriority + 1;56 static const int Detector = HighPriority + 2;57 };58 59 60 50 /** 61 51 @brief … … 144 134 145 135 //! Generic function that distributes all 9 button events 146 template <typename EventType, class Traits>147 void buttonEvent(unsigned int device, const typename Traits::ButtonTypeParam button);136 template <typename EventType, class ButtonTypeParam> 137 void buttonEvent(unsigned int device, ButtonTypeParam button); 148 138 149 139 //! Event handler … … 190 180 for (unsigned int i = 0; i < handlers_.size(); ++i) 191 181 if (handlers_[i] != NULL) 192 handlers_[i]->allDevicesUpdated(dt);182 INPUT_STATE_PUSH_CALL(i, allDevicesUpdated, dt); 193 183 } 194 184 … … 199 189 case InputDeviceEnumerator::Keyboard: 200 190 if (handlers_[keyboardIndex_s] != NULL) 201 handlers_[keyboardIndex_s]->keyboardUpdated(dt);191 INPUT_STATE_PUSH_CALL(keyboardIndex_s, keyboardUpdated, dt); 202 192 break; 203 193 204 194 case InputDeviceEnumerator::Mouse: 205 195 if (handlers_[mouseIndex_s] != NULL) 206 handlers_[mouseIndex_s]->mouseUpdated(dt);196 INPUT_STATE_PUSH_CALL(mouseIndex_s, mouseUpdated, dt); 207 197 break; 208 198 209 199 default: // joy sticks 210 200 if (handlers_[device] != NULL) 211 handlers_[device]->joyStickUpdated(device - firstJoyStickIndex_s, dt);201 INPUT_STATE_PUSH_CALL(device, joyStickUpdated, device - firstJoyStickIndex_s, dt); 212 202 break; 213 203 } 214 204 } 215 205 216 template <typename EventType, class Traits>217 FORCEINLINE void InputState::buttonEvent(unsigned int device, const typename Traits::ButtonTypeParam button)206 template <typename EventType, class ButtonTypeParam> 207 FORCEINLINE void InputState::buttonEvent(unsigned int device, typename ButtonTypeParam button) 218 208 { 219 209 assert(device < handlers_.size()); 220 210 if (handlers_[device] != NULL) 221 handlers_[device]->buttonEvent(device, button, EventType()); 211 { 212 // We have to store the function pointer to tell the compiler about its actual type because of overloading 213 void (InputHandler::*function)(unsigned int, ButtonTypeParam, EventType) = &InputHandler::buttonEvent<ButtonTypeParam>; 214 InputManager::getInstance().pushCall(boost::function<void ()>(boost::bind(function, handlers_[device], device, button, EventType()))); 215 } 222 216 } 223 217 … … 225 219 { 226 220 if (handlers_[mouseIndex_s] != NULL) 227 handlers_[mouseIndex_s]->mouseMoved(abs, rel, clippingSize);221 INPUT_STATE_PUSH_CALL(mouseIndex_s, mouseMoved, abs, rel, clippingSize); 228 222 } 229 223 … … 231 225 { 232 226 if (handlers_[mouseIndex_s] != NULL) 233 handlers_[mouseIndex_s]->mouseScrolled(abs, rel);227 INPUT_STATE_PUSH_CALL(mouseIndex_s, mouseScrolled, abs, rel); 234 228 } 235 229 … … 238 232 assert(device < handlers_.size()); 239 233 if (handlers_[device] != NULL) 240 handlers_[device]->axisMoved(device - firstJoyStickIndex_s, axis, value);234 INPUT_STATE_PUSH_CALL(device, axisMoved, device - firstJoyStickIndex_s, axis, value); 241 235 } 242 236 }
Note: See TracChangeset
for help on using the changeset viewer.