Changeset 13041 for OpenSceneGraph/trunk/src/osgGA/EventQueue.cpp
- Timestamp:
- 03/21/12 18:36:20 (15 months ago)
- Files:
-
- 1 modified
-
OpenSceneGraph/trunk/src/osgGA/EventQueue.cpp (modified) (31 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osgGA/EventQueue.cpp
r12938 r13041 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 2 2 * 3 * This library is open source and may be redistributed and/or modified under 4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 3 * This library is open source and may be redistributed and/or modified under 4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 5 5 * (at your option) any later version. The full license is in LICENSE file 6 6 * included with this distribution, and on the openscenegraph.org website. 7 * 7 * 8 8 * This library is distributed in the hope that it will be useful, 9 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 11 * OpenSceneGraph Public License for more details. 12 12 */ … … 25 25 _accumulateEventState = new GUIEventAdapter(); 26 26 _accumulateEventState->setMouseYOrientation(mouseYOrientation); 27 27 28 28 _firstTouchEmulatesMouse = true; 29 29 } … … 82 82 83 83 if (ritr==_eventQueue.rend()) return false; 84 84 85 85 for(Events::iterator itr = _eventQueue.begin(); 86 86 itr != ritr.base(); … … 151 151 event->setPenPressure(pressure); 152 152 event->setTime(time); 153 153 154 154 addEvent(event); 155 155 } … … 163 163 event->setPenRotation(rotation); 164 164 event->setTime(time); 165 165 166 166 addEvent(event); 167 167 } … … 173 173 event->setTabletPointerType(pt); 174 174 event->setTime(time); 175 175 176 176 addEvent(event); 177 177 } … … 183 183 event->setScrollingMotion(sm); 184 184 event->setTime(time); 185 185 186 186 addEvent(event); 187 187 } … … 193 193 event->setScrollingMotionDelta(x,y); 194 194 event->setTime(time); 195 195 196 196 addEvent(event); 197 197 } … … 213 213 event->setEventType(event->getButtonMask() ? GUIEventAdapter::DRAG : GUIEventAdapter::MOVE); 214 214 event->setTime(time); 215 215 216 216 addEvent(event); 217 217 } … … 224 224 switch(button) 225 225 { 226 case(1): 226 case(1): 227 227 _accumulateEventState->setButtonMask(GUIEventAdapter::LEFT_MOUSE_BUTTON | _accumulateEventState->getButtonMask()); 228 228 break; 229 case(2): 229 case(2): 230 230 _accumulateEventState->setButtonMask(GUIEventAdapter::MIDDLE_MOUSE_BUTTON | _accumulateEventState->getButtonMask()); 231 231 break; 232 case(3): 232 case(3): 233 233 _accumulateEventState->setButtonMask(GUIEventAdapter::RIGHT_MOUSE_BUTTON | _accumulateEventState->getButtonMask()); 234 234 break; … … 241 241 switch(button) 242 242 { 243 case(1): 243 case(1): 244 244 event->setButton(GUIEventAdapter::LEFT_MOUSE_BUTTON); 245 245 break; 246 case(2): 246 case(2): 247 247 event->setButton(GUIEventAdapter::MIDDLE_MOUSE_BUTTON); 248 248 break; 249 case(3): 249 case(3): 250 250 event->setButton(GUIEventAdapter::RIGHT_MOUSE_BUTTON); 251 251 break; 252 252 } 253 253 254 254 addEvent(event); 255 255 } … … 262 262 switch(button) 263 263 { 264 case(1): 264 case(1): 265 265 _accumulateEventState->setButtonMask(GUIEventAdapter::LEFT_MOUSE_BUTTON | _accumulateEventState->getButtonMask()); 266 266 break; 267 case(2): 267 case(2): 268 268 _accumulateEventState->setButtonMask(GUIEventAdapter::MIDDLE_MOUSE_BUTTON | _accumulateEventState->getButtonMask()); 269 269 break; 270 case(3): 270 case(3): 271 271 _accumulateEventState->setButtonMask(GUIEventAdapter::RIGHT_MOUSE_BUTTON | _accumulateEventState->getButtonMask()); 272 272 break; … … 279 279 switch(button) 280 280 { 281 case(1): 281 case(1): 282 282 event->setButton(GUIEventAdapter::LEFT_MOUSE_BUTTON); 283 283 break; 284 case(2): 284 case(2): 285 285 event->setButton(GUIEventAdapter::MIDDLE_MOUSE_BUTTON); 286 286 break; 287 case(3): 287 case(3): 288 288 event->setButton(GUIEventAdapter::RIGHT_MOUSE_BUTTON); 289 289 break; 290 290 } 291 291 292 292 addEvent(event); 293 293 } … … 300 300 switch(button) 301 301 { 302 case(1): 302 case(1): 303 303 _accumulateEventState->setButtonMask(~GUIEventAdapter::LEFT_MOUSE_BUTTON & _accumulateEventState->getButtonMask()); 304 304 break; 305 case(2): 305 case(2): 306 306 _accumulateEventState->setButtonMask(~GUIEventAdapter::MIDDLE_MOUSE_BUTTON & _accumulateEventState->getButtonMask()); 307 307 break; 308 case(3): 308 case(3): 309 309 _accumulateEventState->setButtonMask(~GUIEventAdapter::RIGHT_MOUSE_BUTTON & _accumulateEventState->getButtonMask()); 310 310 break; … … 317 317 switch(button) 318 318 { 319 case(1): 319 case(1): 320 320 event->setButton(GUIEventAdapter::LEFT_MOUSE_BUTTON); 321 321 break; 322 case(2): 322 case(2): 323 323 event->setButton(GUIEventAdapter::MIDDLE_MOUSE_BUTTON); 324 324 break; 325 case(3): 325 case(3): 326 326 event->setButton(GUIEventAdapter::RIGHT_MOUSE_BUTTON); 327 327 break; 328 328 } 329 329 330 330 addEvent(event); 331 331 } … … 349 349 case(GUIEventAdapter::KEY_Caps_Lock): 350 350 { 351 if ((_accumulateEventState->getModKeyMask() & GUIEventAdapter::MODKEY_CAPS_LOCK)!=0) 351 if ((_accumulateEventState->getModKeyMask() & GUIEventAdapter::MODKEY_CAPS_LOCK)!=0) 352 352 _accumulateEventState->setModKeyMask(~GUIEventAdapter::MODKEY_CAPS_LOCK & _accumulateEventState->getModKeyMask()); 353 else 354 _accumulateEventState->setModKeyMask(GUIEventAdapter::MODKEY_CAPS_LOCK | _accumulateEventState->getModKeyMask()); 353 else 354 _accumulateEventState->setModKeyMask(GUIEventAdapter::MODKEY_CAPS_LOCK | _accumulateEventState->getModKeyMask()); 355 355 break; 356 356 } … … 364 364 } 365 365 default: break; 366 } 366 } 367 367 368 368 GUIEventAdapter* event = new GUIEventAdapter(*_accumulateEventState); … … 371 371 event->setUnmodifiedKey(unmodifiedKey); 372 372 event->setTime(time); 373 373 374 374 addEvent(event); 375 375 } … … 392 392 case(GUIEventAdapter::KEY_Hyper_R): _accumulateEventState->setModKeyMask(~GUIEventAdapter::MODKEY_RIGHT_HYPER & _accumulateEventState->getModKeyMask()); break; 393 393 default: break; 394 } 394 } 395 395 396 396 GUIEventAdapter* event = new GUIEventAdapter(*_accumulateEventState); … … 399 399 event->setUnmodifiedKey(unmodifiedKey); 400 400 event->setTime(time); 401 401 402 402 addEvent(event); 403 403 } … … 406 406 GUIEventAdapter* EventQueue::touchBegan(unsigned int id, GUIEventAdapter::TouchPhase phase, float x, float y, double time) 407 407 { 408 if(_firstTouchEmulatesMouse) 408 if(_firstTouchEmulatesMouse) 409 409 { 410 410 // emulate left mouse button press 411 411 412 412 _accumulateEventState->setButtonMask((1) | _accumulateEventState->getButtonMask()); 413 413 _accumulateEventState->setX(x); 414 414 _accumulateEventState->setY(y); 415 415 } 416 416 417 417 GUIEventAdapter* event = new GUIEventAdapter(*_accumulateEventState); 418 418 event->setEventType(GUIEventAdapter::PUSH); 419 419 event->setTime(time); 420 420 event->addTouchPoint(id, phase, x, y, 0); 421 422 addEvent(event); 423 421 422 addEvent(event); 423 424 424 return event; 425 425 } 426 427 426 427 428 428 GUIEventAdapter* EventQueue::touchMoved(unsigned int id, GUIEventAdapter::TouchPhase phase, float x, float y, double time) 429 429 { … … 433 433 _accumulateEventState->setY(y); 434 434 } 435 435 436 436 GUIEventAdapter* event = new GUIEventAdapter(*_accumulateEventState); 437 437 event->setEventType(GUIEventAdapter::DRAG); … … 439 439 event->addTouchPoint(id, phase, x, y, 0); 440 440 addEvent(event); 441 441 442 442 return event; 443 443 } … … 445 445 GUIEventAdapter* EventQueue::touchEnded(unsigned int id, GUIEventAdapter::TouchPhase phase, float x, float y, unsigned int tap_count, double time) 446 446 { 447 if (_firstTouchEmulatesMouse) 447 if (_firstTouchEmulatesMouse) 448 448 { 449 449 _accumulateEventState->setButtonMask(~(1) & _accumulateEventState->getButtonMask()); … … 451 451 _accumulateEventState->setY(y); 452 452 } 453 453 454 454 GUIEventAdapter* event = new GUIEventAdapter(*_accumulateEventState); 455 455 event->setEventType(GUIEventAdapter::RELEASE); … … 457 457 event->addTouchPoint(id, phase, x, y, tap_count); 458 458 addEvent(event); 459 459 460 460 return event; 461 461 } 462 462 463 463 464 464 void EventQueue::closeWindow(double time) … … 467 467 event->setEventType(GUIEventAdapter::CLOSE_WINDOW); 468 468 event->setTime(time); 469 469 470 470 addEvent(event); 471 471 } … … 476 476 event->setEventType(GUIEventAdapter::QUIT_APPLICATION); 477 477 event->setTime(time); 478 478 479 479 addEvent(event); 480 480 } … … 486 486 event->setEventType(GUIEventAdapter::FRAME); 487 487 event->setTime(time); 488 488 489 489 addEvent(event); 490 490 } … … 492 492 GUIEventAdapter* EventQueue::createEvent() 493 493 { 494 if (_accumulateEventState.valid()) return new GUIEventAdapter(*_accumulateEventState.get()); 495 else return new GUIEventAdapter(); 494 if (_accumulateEventState.valid()) return new GUIEventAdapter(*_accumulateEventState.get()); 495 else return new GUIEventAdapter(); 496 496 } 497 497 … … 502 502 event->setUserData(userEventData); 503 503 event->setTime(time); 504 505 addEvent(event); 506 } 507 508 504 505 addEvent(event); 506 } 507 508
