Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

Diff Revisions 315 vs 318 for /trunk/Source Code/Scenes/SceneInput.cpp

Diff revisions: vs.
  @@ -4,7 +4,9 @@
4 4 #include "Rendering/PostFX/Headers/PostFX.h"
5 5 #include "Managers/Headers/SceneManager.h"
6 6
7 - void Scene::onLostFocus(){
7 + namespace Divide {
8 +
9 + void Scene::onLostFocus() {
8 10 state().resetMovement();
9 11 #ifndef _DEBUG
10 12 _paramHandler.setParam("freezeLoopTime", true);
  @@ -49,7 +51,7 @@
49 51 // set it's state to selected
50 52 _currentSelection->setSelected(true);
51 53 #ifdef _DEBUG
52 - _lines[DEBUG_LINE_RAY_PICK].push_back(Line(startRay, endRay, vec4<U8>(0, 255, 0, 255)));
54 + _lines[DEBUG_LINE_RAY_PICK].emplace_back(startRay, endRay, vec4<U8>(0, 255, 0, 255));
53 55 #endif
54 56 }
55 57
  @@ -58,83 +60,85 @@
58 60 }
59 61 }
60 62
61 - bool Scene::mouseButtonPressed(const OIS::MouseEvent& key,OIS::MouseButtonID button){
63 + bool Scene::mouseButtonPressed(const Input::MouseEvent& key, Input::MouseButton button){
62 64 _mousePressed[button] = true;
63 65 switch (button){
64 66 default: return false;
65 67
66 - case OIS::MB_Left: break;
67 - case OIS::MB_Right: break;
68 - case OIS::MB_Middle: break;
69 - case OIS::MB_Button3: break;
70 - case OIS::MB_Button4: break;
71 - case OIS::MB_Button5: break;
72 - case OIS::MB_Button6: break;
73 - case OIS::MB_Button7: break;
68 + case Input::MouseButton::MB_Left: break;
69 + case Input::MouseButton::MB_Right: break;
70 + case Input::MouseButton::MB_Middle: break;
71 + case Input::MouseButton::MB_Button3: break;
72 + case Input::MouseButton::MB_Button4: break;
73 + case Input::MouseButton::MB_Button5: break;
74 + case Input::MouseButton::MB_Button6: break;
75 + case Input::MouseButton::MB_Button7: break;
74 76 }
75 77 return true;
76 78 }
77 79
78 - bool Scene::mouseButtonReleased(const OIS::MouseEvent& key,OIS::MouseButtonID button){
80 + bool Scene::mouseButtonReleased(const Input::MouseEvent& key, Input::MouseButton button){
79 81 _mousePressed[button] = false;
80 82 switch (button){
81 83 default: return false;
82 84
83 - case OIS::MB_Left: findSelection(key.state.X.abs, key.state.Y.abs); break;
84 - case OIS::MB_Right: break;
85 - case OIS::MB_Middle: break;
86 - case OIS::MB_Button3: break;
87 - case OIS::MB_Button4: break;
88 - case OIS::MB_Button5: break;
89 - case OIS::MB_Button6: break;
90 - case OIS::MB_Button7: break;
85 + case Input::MouseButton::MB_Left: findSelection(key.state.X.abs, key.state.Y.abs); break;
86 + case Input::MouseButton::MB_Right: break;
87 + case Input::MouseButton::MB_Middle: break;
88 + case Input::MouseButton::MB_Button3: break;
89 + case Input::MouseButton::MB_Button4: break;
90 + case Input::MouseButton::MB_Button5: break;
91 + case Input::MouseButton::MB_Button6: break;
92 + case Input::MouseButton::MB_Button7: break;
91 93 }
92 94 return true;
93 95 }
94 96
95 - bool Scene::mouseMoved(const OIS::MouseEvent& key){
97 + bool Scene::mouseMoved(const Input::MouseEvent& key){
98 + state()._mouseXDelta = _previousMousePos.x - key.state.X.abs;
99 + state()._mouseYDelta = _previousMousePos.y - key.state.Y.abs;
96 100 _previousMousePos.set(key.state.X.abs, key.state.Y.abs);
97 101 return true;
98 102 }
99 103
100 - void Scene::defaultCameraKeys(OIS::KeyCode code, bool upState){
101 -
104 + using namespace Input;
105 + void Scene::defaultCameraKeys(KeyCode code, bool upState){
102 106 if (upState){
103 107 switch (code){
104 - case OIS::KC_W: state()._moveFB = 0; break;
105 - case OIS::KC_S: state()._moveFB = 0; break;
106 - case OIS::KC_A: state()._moveLR = 0; break;
107 - case OIS::KC_D: state()._moveLR = 0; break;
108 - case OIS::KC_Q: state()._roll = 0; break;
109 - case OIS::KC_E: state()._roll = 0; break;
110 - case OIS::KC_LEFT: state()._angleLR = 0; break;
111 - case OIS::KC_RIGHT: state()._angleLR = 0; break;
112 - case OIS::KC_UP: state()._angleUD = 0; break;
113 - case OIS::KC_DOWN: state()._angleUD = 0; break;
108 + case KeyCode::KC_W: state()._moveFB = 0; break;
109 + case KeyCode::KC_S: state()._moveFB = 0; break;
110 + case KeyCode::KC_A: state()._moveLR = 0; break;
111 + case KeyCode::KC_D: state()._moveLR = 0; break;
112 + case KeyCode::KC_Q: state()._roll = 0; break;
113 + case KeyCode::KC_E: state()._roll = 0; break;
114 + case KeyCode::KC_LEFT: state()._angleLR = 0; break;
115 + case KeyCode::KC_RIGHT: state()._angleLR = 0; break;
116 + case KeyCode::KC_UP: state()._angleUD = 0; break;
117 + case KeyCode::KC_DOWN: state()._angleUD = 0; break;
114 118 }
115 - }else{
119 + } else {
116 120 switch (code){
117 - case OIS::KC_W: state()._moveFB = 1; break;
118 - case OIS::KC_S: state()._moveFB = -1; break;
119 - case OIS::KC_A: state()._moveLR = -1; break;
120 - case OIS::KC_D: state()._moveLR = 1; break;
121 - case OIS::KC_Q: state()._roll = -1; break;
122 - case OIS::KC_E: state()._roll = 1; break;
123 - case OIS::KC_LEFT: state()._angleLR = -1; break;
124 - case OIS::KC_RIGHT: state()._angleLR = 1; break;
125 - case OIS::KC_UP: state()._angleUD = -1; break;
126 - case OIS::KC_DOWN: state()._angleUD = 1; break;
121 + case KeyCode::KC_W: state()._moveFB = 1; break;
122 + case KeyCode::KC_S: state()._moveFB = -1; break;
123 + case KeyCode::KC_A: state()._moveLR = -1; break;
124 + case KeyCode::KC_D: state()._moveLR = 1; break;
125 + case KeyCode::KC_Q: state()._roll = -1; break;
126 + case KeyCode::KC_E: state()._roll = 1; break;
127 + case KeyCode::KC_LEFT: state()._angleLR = -1; break;
128 + case KeyCode::KC_RIGHT: state()._angleLR = 1; break;
129 + case KeyCode::KC_UP: state()._angleUD = -1; break;
130 + case KeyCode::KC_DOWN: state()._angleUD = 1; break;
127 131 }
128 132 }
129 133 }
130 134
131 - bool Scene::onKeyDown(const OIS::KeyEvent& key){
132 - defaultCameraKeys(key.key, false);
135 + bool Scene::onKeyDown(const Input::KeyEvent& key){
136 + defaultCameraKeys(key._key, false);
133 137
134 - switch(key.key){
138 + switch(key._key){
135 139 default: return false;
136 - case OIS::KC_END : deleteSelection(); break;
137 - case OIS::KC_ADD : {
140 + case KeyCode::KC_END : deleteSelection(); break;
141 + case KeyCode::KC_ADD : {
138 142 Camera& cam = renderState().getCamera();
139 143 F32 currentCamMoveSpeedFactor = cam.getMoveSpeedFactor();
140 144 if (currentCamMoveSpeedFactor < 50){
  @@ -142,7 +146,7 @@
142 146 cam.setTurnSpeedFactor( cam.getTurnSpeedFactor() + 1.0f);
143 147 }
144 148 }break;
145 - case OIS::KC_SUBTRACT : {
149 + case KeyCode::KC_SUBTRACT : {
146 150 Camera& cam = renderState().getCamera();
147 151 F32 currentCamMoveSpeedFactor = cam.getMoveSpeedFactor();
148 152 if (currentCamMoveSpeedFactor > 1.0f){
  @@ -155,42 +159,42 @@
155 159 return true;
156 160 }
157 161
158 - bool Scene::onKeyUp(const OIS::KeyEvent& key){
159 - defaultCameraKeys(key.key, true);
162 + bool Scene::onKeyUp(const Input::KeyEvent& key){
163 + defaultCameraKeys(key._key, true);
160 164
161 - switch( key.key ){
162 - case OIS::KC_P:
165 + switch( key._key ){
166 + case KeyCode::KC_P:
163 167 _paramHandler.setParam("freezeLoopTime", !_paramHandler.getParam("freezeLoopTime", false));
164 168 break;
165 - case OIS::KC_F2:
169 + case KeyCode::KC_F2:
166 170 renderState().toggleSkeletons();
167 171 break;
168 - case OIS::KC_F3:
172 + case KeyCode::KC_F3:
169 173 _paramHandler.setParam("postProcessing.enableDepthOfField", !_paramHandler.getParam<bool>("postProcessing.enableDepthOfField"));
170 174 break;
171 - case OIS::KC_F4:
175 + case KeyCode::KC_F4:
172 176 _paramHandler.setParam("postProcessing.enableBloom", !_paramHandler.getParam<bool>("postProcessing.enableBloom"));
173 177 break;
174 - case OIS::KC_F5:
178 + case KeyCode::KC_F5:
175 179 renderState().toggleAxisLines();
176 180 break;
177 - case OIS::KC_B:{
181 + case KeyCode::KC_B:{
178 182 renderState().toggleBoundingBoxes();
179 183 }break;
180 - case OIS::KC_F8:
184 + case KeyCode::KC_F8:
181 185 renderState().drawDebugLines(!renderState()._debugDrawLines);
182 186 break;
183 - case OIS::KC_F9:{
187 + case KeyCode::KC_F9:{
184 188 #ifdef _DEBUG
185 189 for(U8 i = 0; i < DEBUG_LINE_PLACEHOLDER; ++i)
186 190 _lines[i].clear();
187 191 #endif
188 192 }break;
189 - case OIS::KC_F10:
193 + case KeyCode::KC_F10:
190 194 LightManager::getInstance().togglePreviewShadowMaps();
191 195 GFX_DEVICE.togglePreviewDepthBuffer();
192 196 break;
193 - case OIS::KC_F7:
197 + case KeyCode::KC_F7:
194 198 GFX_DEVICE.Screenshot("screenshot_");
195 199 break;
196 200 default:
  @@ -202,9 +206,9 @@
202 206
203 207 static I32 axisDeadZone = 256;
204 208
205 - bool Scene::joystickAxisMoved(const OIS::JoyStickEvent& key,I8 axis) {
209 + bool Scene::joystickAxisMoved(const Input::JoystickEvent& key,I8 axis) {
206 210 STUBBED("ToDo: Store input from multiple joysticks in scene state! - Ionut");
207 - if (key.device->getID() != InputInterface::JOY_1) {
211 + if (key.device->getID() != Input::JOYSTICK_1) {
208 212 return false;
209 213 }
210 214 I32 axisABS = key.state.mAxes[axis].abs;
  @@ -251,7 +255,7 @@
251 255 return true;
252 256 }
253 257
254 - bool Scene::joystickPovMoved(const OIS::JoyStickEvent& key, I8 pov){
258 + bool Scene::joystickPovMoved(const Input::JoystickEvent& key, I8 pov){
255 259 if (key.state.mPOV[pov].direction & OIS::Pov::North) { //Going up
256 260 state()._moveFB = 1;
257 261 } else if (key.state.mPOV[pov].direction & OIS::Pov::South) {//Going down
  @@ -265,4 +269,6 @@
265 269 state()._moveFB = 0;
266 270 }
267 271 return true;
268 - }
272 + }
273 +
274 + };