Changeset 1323 for code/branches/input/src/core/InputHandler.h
- Timestamp:
- May 19, 2008, 10:50:09 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/input/src/core/InputHandler.h
r1293 r1323 40 40 41 41 #include "ois/OIS.h" 42 #include "util/Math.h" 42 43 #include "OrxonoxClass.h" 43 44 #include "CommandExecutor.h" … … 46 47 namespace orxonox 47 48 { 48 namespace KeybindSetting 49 { 50 enum KeybindSetting 51 { 52 None, 53 OnPress, 54 OnRelease, 55 Continuous, 56 }; 57 } 58 59 struct _CoreExport KeyBinding 49 struct _CoreExport AxisCommand 60 50 { 61 51 std::string commandStr; 62 52 CommandEvaluation evaluation; 63 }; 64 53 bool bRelative; 54 float value; 55 unsigned int nValuesAdded; 56 }; 57 58 struct _CoreExport SimpleCommand 59 { 60 // for simple binding; direct 61 std::string commandStr; 62 CommandEvaluation evaluation; 63 64 // axis binding; buffered 65 AxisCommand* axisCommand; 66 float axisModifier; 67 }; 68 69 struct _CoreExport KeyBinding 70 { 71 void clear() { commands = 0; nCommands = 0; } 72 SimpleCommand* commands; 73 unsigned int nCommands; 74 }; 75 76 struct _CoreExport KeyBindingBundle 77 { 78 KeyBinding OnPress; 79 KeyBinding OnRelease; 80 KeyBinding OnHold; 81 }; 82 83 struct _CoreExport HalfAxis 84 { 85 float rel; 86 float abs; 87 float threshold; 88 bool wasDown; 89 bool hasChanged; 90 }; 91 65 92 66 93 /** … … 75 102 76 103 bool loadBindings(); 77 void clearBindings( );104 void clearBindings(bool bInit = false); 78 105 79 106 void setConfigValues(); 80 107 81 108 private: // functions 82 83 bool executeSimpleBinding(KeyBinding &binding); 109 bool readBindings(std::string* names, std::string* bindingStrings, KeyBindingBundle* bindings, unsigned int size); 110 bool executeBinding(KeyBinding& binding, float axisRel, float axisAbs); 111 void clearBundle(KeyBindingBundle& bundle, bool bInit); 112 113 void tick(float dt); 84 114 85 115 bool keyPressed (const KeyEvent& evt); … … 87 117 bool keyHeld (const KeyEvent& evt); 88 118 89 bool mouseButtonPressed (const MouseState& state, MouseButton::Enum id); 90 bool mouseButtonReleased(const MouseState& state, MouseButton::Enum id); 91 bool mouseButtonHeld (const MouseState& state, MouseButton::Enum id); 92 bool mouseMoved (const MouseState& state); 93 bool mouseScrolled (const MouseState& state); 94 95 bool joyStickButtonPressed (const JoyStickState& state, int button); 96 bool joyStickButtonReleased(const JoyStickState& state, int button); 97 bool joyStickButtonHeld (const JoyStickState& state, int button); 98 bool joyStickAxisMoved (const JoyStickState& state, int axis) ; 99 bool joyStickSliderMoved (const JoyStickState& state, int index) ; 100 bool joyStickPovMoved (const JoyStickState& state, int index) ; 101 bool joyStickVector3Moved (const JoyStickState& state, int index) ; 119 bool mouseButtonPressed (MouseButton::Enum id); 120 bool mouseButtonReleased(MouseButton::Enum id); 121 bool mouseButtonHeld (MouseButton::Enum id); 122 bool mouseMoved (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize); 123 bool mouseScrolled (int abs, int rel); 124 125 bool joyStickButtonPressed (int joyStickID, int button); 126 bool joyStickButtonReleased(int joyStickID, int button); 127 bool joyStickButtonHeld (int joyStickID, int button); 128 bool joyStickAxisMoved (int joyStickID, int axis, int value) ; 102 129 103 130 private: // variables 104 105 131 //! denotes the number of different keys there are in OIS. 106 static const int numberOfKeys_s = 0xEE; 107 //! Array of input events for every pressed key 108 KeyBinding bindingsKeyPress_ [numberOfKeys_s]; 109 //! Array of input events for every released key 110 KeyBinding bindingsKeyRelease_[numberOfKeys_s]; 111 //! Array of input events for every held key 112 KeyBinding bindingsKeyHold_ [numberOfKeys_s]; 132 static const unsigned int nKeys_s = 0xEE; 133 //! Actual key bindings as bundle for Press, Hold and Release 134 KeyBindingBundle bindingsKeys_ [nKeys_s]; 113 135 //! Names of the keys as strings 114 std::string keyNames_[numberOfKeys_s]; 136 std::string namesKeys_ [nKeys_s]; 137 //! The configured string values 138 std::string bindingStringsKeys_[nKeys_s]; 115 139 116 140 //! denotes the number of different mouse buttons there are in OIS. 117 static const int numberOfMouseButtons_s = 8; 118 //! Array of input events for every pressed mouse button 119 KeyBinding bindingsMouseButtonPress_ [numberOfMouseButtons_s]; 120 //! Array of input events for every released mouse button 121 KeyBinding bindingsMouseButtonRelease_[numberOfMouseButtons_s]; 122 //! Array of input events for every held mouse button 123 KeyBinding bindingsMouseButtonHold_ [numberOfMouseButtons_s]; 124 //! Key binding for mouse moved event 125 KeyBinding bindingMouseMoved_; 126 //! Key binding for mouse scrolled event 127 KeyBinding bindingMouseScrolled_; 141 static const unsigned int nMouseButtons_s = 8; 142 //! Actual key bindings as bundle for Press, Hold and Release 143 KeyBindingBundle bindingsMouseButtons_ [nMouseButtons_s]; 128 144 //! Names of the mouse buttons as strings 129 std::string mouseButtonNames_[numberOfMouseButtons_s]; 145 std::string namesMouseButtons_ [nMouseButtons_s]; 146 //! The configured string values 147 std::string bindingStringsMouseButtons_[nMouseButtons_s]; 130 148 131 149 //! denotes the number of different joy stick buttons there are in OIS. 132 static const int numberOfJoyStickButtons_s = 32; 133 //! Array of input events for every pressed joy stick button 134 KeyBinding bindingsJoyStickButtonPress_ [numberOfJoyStickButtons_s]; 135 //! Array of input events for every released joy stick button 136 KeyBinding bindingsJoyStickButtonRelease_[numberOfJoyStickButtons_s]; 137 //! Array of input events for every held joy stick button 138 KeyBinding bindingsJoyStickButtonHold_ [numberOfJoyStickButtons_s]; 150 static const unsigned int nJoyStickButtons_s = 32 + 4 * 4; // 32 buttons and 4 POVs with 4 buttons 151 //! Actual key bindings as bundle for Press, Hold and Release 152 KeyBindingBundle bindingsJoyStickButtons_ [nJoyStickButtons_s]; 139 153 //! Names of the joy stick buttons as strings 140 std::string joyStickButtonNames_[numberOfJoyStickButtons_s]; 141 154 std::string namesJoyStickButtons_ [nJoyStickButtons_s]; 155 //! The configured string values 156 std::string bindingStringsJoyStickButtons_[nJoyStickButtons_s]; 157 158 //! denotes the number of half axes (every axis twice) there can be. 159 static const unsigned int nHalfAxes_s = 56; 160 /** 161 * Array with all the half axes for mouse and joy sticks. 162 * Bear in mind that the positions are fixed and that the first entry is the 163 * positive one and the second is negative. 164 * Sequence is as follows: 165 * 0 - 3: Mouse x and y 166 * 4 - 7: Mouse scroll wheels 1 and 2 (2 not yet supported) 167 * 8 - 23: joy stick (slider) axes 1 to 8 168 * 24 - 55: joy stick axes 1 - 16 169 */ 170 HalfAxis halfAxes_[nHalfAxes_s]; 171 //! Actual key bindings as bundle for Press, Hold and Release 172 KeyBindingBundle bindingsHalfAxes_ [nHalfAxes_s]; 173 //! Names of the half axes 174 std::string namesHalfAxes_ [nHalfAxes_s]; 175 //! The configured string values 176 std::string bindingStringsHalfAxes_[nHalfAxes_s]; 177 178 /** 179 * Commands that have additional parameters (axes) are executed at the end of 180 * the tick() so that all values can be buffered for single execution. 181 */ 182 std::vector<AxisCommand*> axisCommands_; 142 183 }; 143 184
Note: See TracChangeset
for help on using the changeset viewer.