Changeset 1236 for code/branches/input/src/core/InputHandler.cc
- Timestamp:
- May 6, 2008, 2:32:19 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/input/src/core/InputHandler.cc
r1219 r1236 33 33 34 34 #include "InputHandler.h" 35 #include "util/Convert.h" 35 36 #include "Debug.h" 36 37 #include "ConfigValueIncludes.h" 37 38 #include "CoreIncludes.h" 38 #include "util/Convert.h" 39 #include "core/CommandExecutor.h" 39 #include "CommandExecutor.h" 40 40 41 41 namespace orxonox … … 267 267 switch (j) 268 268 { 269 // note: the first element in the struct is the string, so the following pointer270 // arithmetic works.271 269 case 0: 272 270 cont->getValue(&bindingsKeyPress_[i].commandStr); 273 271 break; 274 272 case 1: 275 cont->getValue( bindingsKeyRelease_ + i);273 cont->getValue(&bindingsKeyRelease_[i].commandStr); 276 274 break; 277 275 case 2: 278 cont->getValue( bindingsKeyHold_ + i);276 cont->getValue(&bindingsKeyHold_[i].commandStr); 279 277 } 280 278 } … … 295 293 { 296 294 case 0: 297 cont->getValue( bindingsMouseButtonPress_ + i);295 cont->getValue(&bindingsMouseButtonPress_[i].commandStr); 298 296 break; 299 297 case 1: 300 cont->getValue( bindingsMouseButtonRelease_ + i);298 cont->getValue(&bindingsMouseButtonRelease_[i].commandStr); 301 299 break; 302 300 case 2: 303 cont->getValue( bindingsMouseButtonHold_ + i);301 cont->getValue(&bindingsMouseButtonHold_[i].commandStr); 304 302 } 305 303 } … … 320 318 { 321 319 case 0: 322 cont->getValue( bindingsJoyStickButtonPress_ + i);320 cont->getValue(&bindingsJoyStickButtonPress_[i].commandStr); 323 321 break; 324 322 case 1: 325 cont->getValue( bindingsJoyStickButtonRelease_ + i);323 cont->getValue(&bindingsJoyStickButtonRelease_[i].commandStr); 326 324 break; 327 325 case 2: 328 cont->getValue( bindingsJoyStickButtonHold_ + i);326 cont->getValue(&bindingsJoyStickButtonHold_[i].commandStr); 329 327 } 330 328 } … … 345 343 for (int i = 0; i < numberOfMouseButtons_s; i++) 346 344 { 347 bindingsMouseButtonPress_ [i] = "";348 bindingsMouseButtonRelease_[i] = "";349 bindingsMouseButtonHold_ [i] = "";345 bindingsMouseButtonPress_ [i].commandStr = ""; 346 bindingsMouseButtonRelease_[i].commandStr = ""; 347 bindingsMouseButtonHold_ [i].commandStr = ""; 350 348 } 351 349 for (int i = 0; i < numberOfJoyStickButtons_s; i++) 352 350 { 353 bindingsJoyStickButtonPress_ [i] = "";354 bindingsJoyStickButtonRelease_[i] = "";355 bindingsJoyStickButtonHold_ [i] = "";351 bindingsJoyStickButtonPress_ [i].commandStr = ""; 352 bindingsJoyStickButtonRelease_[i].commandStr = ""; 353 bindingsJoyStickButtonHold_ [i].commandStr = ""; 356 354 } 357 355 } … … 370 368 // evaluate the key bindings 371 369 // TODO: what if binding is invalid? 372 //for (int i = 0; i < numberOfKeys_s; i++)373 //{374 //if (bindingsKeyPress_[i].commandStr != "")375 //{376 //bindingsKeyPress_[i].evaluation = CommandExecutor::evaluate(bindingsKeyPress_[i].commandStr);377 //bindingsKeyPress_[i].commandStr = bindingsKeyPress_[i].evaluation.getCommandString();378 //}379 //}370 for (int i = 0; i < numberOfKeys_s; i++) 371 { 372 if (bindingsKeyPress_[i].commandStr != "") 373 { 374 bindingsKeyPress_[i].evaluation = CommandExecutor::evaluate(bindingsKeyPress_[i].commandStr); 375 bindingsKeyPress_[i].commandStr = bindingsKeyPress_[i].evaluation.getCommandString(); 376 } 377 } 380 378 381 379 COUT(ORX_DEBUG) << "KeyBinder: Loading key bindings done." << std::endl; … … 387 385 if (binding.commandStr != "") 388 386 { 389 //if (binding.commandStr != binding.evaluation.getCommandString())390 //{391 //// key binding has changed, reevaluate the command string.392 //binding.evaluation = CommandExecutor::evaluate(binding.commandStr);393 //binding.commandStr = binding.evaluation.getCommandString();394 //}387 if (binding.commandStr != binding.evaluation.getCommandString()) 388 { 389 // key binding has changed, reevaluate the command string. 390 binding.evaluation = CommandExecutor::evaluate(binding.commandStr); 391 binding.commandStr = binding.evaluation.getCommandString(); 392 } 395 393 COUT(3) << "Executing command: " << binding.commandStr << std::endl; 396 394 CommandExecutor::execute(binding.commandStr); … … 405 403 @param e Event information 406 404 */ 407 bool KeyBinder::keyPressed(const OIS::KeyEvent &e) 408 { 409 COUT(3) << "Key: " << e.key << std::endl; 410 // find the appropriate key binding 411 executeBinding(bindingsKeyPress_[int(e.key)]); 412 405 bool KeyBinder::keyPressed(const KeyEvent& evt) 406 { 407 // find the appropriate key binding 408 executeBinding(bindingsKeyPress_[int(evt.key)]); 409 413 410 return true; 414 411 } … … 418 415 @param e Event information 419 416 */ 420 bool KeyBinder::keyReleased(const OIS::KeyEvent &e)421 { 422 // find the appropriate key binding 423 executeBinding(bindingsKeyRelease_[int(e .key)]);417 bool KeyBinder::keyReleased(const KeyEvent& evt) 418 { 419 // find the appropriate key binding 420 executeBinding(bindingsKeyRelease_[int(evt.key)]); 424 421 425 422 return true; … … 428 425 /** 429 426 @brief Event handler for the keyHeld Event. 430 @param e Eventinformation431 */ 432 bool KeyBinder::keyHeld(const OIS::KeyEvent &e)433 { 434 // find the appropriate key binding 435 executeBinding(bindingsKeyHold_[int(e .key)]);427 @param e Mouse state information 428 */ 429 bool KeyBinder::keyHeld(const KeyEvent& evt) 430 { 431 // find the appropriate key binding 432 executeBinding(bindingsKeyHold_[int(evt.key)]); 436 433 437 434 return true; … … 440 437 /** 441 438 @brief Event handler for the mouseMoved Event. 442 @param e Event information 443 */ 444 bool KeyBinder::mouseMoved(const OIS::MouseEvent &e) 439 @param e Mouse state information 440 */ 441 bool KeyBinder::mouseMoved(const MouseState &evt) 442 { 443 return true; 444 } 445 446 /** 447 @brief Event handler for the mouseWheelTurned Event. 448 @param e Mouse state information 449 */ 450 bool KeyBinder::mouseWheelTurned(const MouseState &evt) 445 451 { 446 452 return true; … … 452 458 @param id The ID of the mouse button 453 459 */ 454 bool KeyBinder::mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id) 455 { 456 // find the appropriate key binding 457 std::string cmdStr = bindingsMouseButtonPress_[int(id)]; 458 if (cmdStr != "") 459 { 460 CommandExecutor::execute(cmdStr); 461 COUT(3) << "Executing command: " << cmdStr << std::endl; 462 } 460 bool KeyBinder::mouseButtonPressed(const MouseState& state, MouseButton::Enum id) 461 { 462 // find the appropriate key binding 463 executeBinding(bindingsMouseButtonPress_[int(id)]); 463 464 464 465 return true; … … 470 471 @param id The ID of the mouse button 471 472 */ 472 bool KeyBinder::mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id) 473 { 474 // find the appropriate key binding 475 std::string cmdStr = bindingsMouseButtonRelease_[int(id)]; 476 if (cmdStr != "") 477 { 478 CommandExecutor::execute(cmdStr); 479 COUT(3) << "Executing command: " << cmdStr << std::endl; 480 } 473 bool KeyBinder::mouseButtonReleased(const MouseState& state, MouseButton::Enum id) 474 { 475 // find the appropriate key binding 476 executeBinding(bindingsMouseButtonRelease_[int(id)]); 481 477 482 478 return true; … … 488 484 @param id The ID of the mouse button 489 485 */ 490 bool KeyBinder::mouseHeld(const OIS::MouseEvent &e, OIS::MouseButtonID id) 491 { 492 // find the appropriate key binding 493 std::string cmdStr = bindingsMouseButtonHold_[int(id)]; 494 if (cmdStr != "") 495 { 496 CommandExecutor::execute(cmdStr); 497 COUT(3) << "Executing command: " << cmdStr << std::endl; 498 } 499 500 return true; 501 } 502 503 bool KeyBinder::buttonPressed(int joyStickID, const OIS::JoyStickEvent &arg, int button) 504 { 505 // find the appropriate key binding 506 std::string cmdStr = bindingsJoyStickButtonPress_[button]; 507 if (cmdStr != "") 508 { 509 CommandExecutor::execute(cmdStr); 510 COUT(3) << "Executing command: " << cmdStr << std::endl; 511 } 512 513 return true; 514 } 515 516 bool KeyBinder::buttonReleased(int joyStickID, const OIS::JoyStickEvent &arg, int button) 517 { 518 // find the appropriate key binding 519 std::string cmdStr = bindingsJoyStickButtonRelease_[button]; 520 if (cmdStr != "") 521 { 522 CommandExecutor::execute(cmdStr); 523 COUT(3) << "Executing command: " << cmdStr << std::endl; 524 } 525 526 return true; 527 } 528 529 bool KeyBinder::buttonHeld(int joyStickID, const OIS::JoyStickEvent &arg, int button) 530 { 531 // find the appropriate key binding 532 std::string cmdStr = bindingsJoyStickButtonHold_[button]; 533 if (cmdStr != "") 534 { 535 CommandExecutor::execute(cmdStr); 536 COUT(3) << "Executing command: " << cmdStr << std::endl; 537 } 538 539 return true; 540 } 541 542 bool KeyBinder::axisMoved(int joyStickID, const OIS::JoyStickEvent &arg, int axis) 543 { 544 return true; 545 } 546 547 bool KeyBinder::sliderMoved(int joyStickID, const OIS::JoyStickEvent &arg, int id) 548 { 549 return true; 550 } 551 552 bool KeyBinder::povMoved(int joyStickID, const OIS::JoyStickEvent &arg, int id) 553 { 554 return true; 555 } 556 557 bool KeyBinder::vector3Moved(int joyStickID, const OIS::JoyStickEvent &arg, int id) 486 bool KeyBinder::mouseButtonHeld(const MouseState& state, MouseButton::Enum id) 487 { 488 // find the appropriate key binding 489 executeBinding(bindingsMouseButtonHold_[int(id)]); 490 491 return true; 492 } 493 494 bool KeyBinder::joyStickButtonPressed(const JoyStickState& state, int button) 495 { 496 // find the appropriate key binding 497 executeBinding(bindingsJoyStickButtonPress_[button]); 498 499 return true; 500 } 501 502 bool KeyBinder::joyStickButtonReleased(const JoyStickState& state, int button) 503 { 504 // find the appropriate key binding 505 executeBinding(bindingsJoyStickButtonRelease_[button]); 506 507 return true; 508 } 509 510 bool KeyBinder::joyStickButtonHeld(const JoyStickState& state, int button) 511 { 512 // find the appropriate key binding 513 executeBinding(bindingsJoyStickButtonHold_[button]); 514 515 return true; 516 } 517 518 bool KeyBinder::joyStickAxisMoved(const JoyStickState& state, int axis) 519 { 520 return true; 521 } 522 523 bool KeyBinder::joyStickSliderMoved(const JoyStickState& state, int index) 524 { 525 return true; 526 } 527 528 bool KeyBinder::joyStickPovMoved(const JoyStickState& state, int index) 529 { 530 return true; 531 } 532 533 bool KeyBinder::joyStickVector3Moved(const JoyStickState& state, int index) 558 534 { 559 535 return true; … … 616 592 // @param id The ID of the mouse button 617 593 //*/ 618 //bool GUIInputHandler::mousePressed(const OIS::MouseEvent &e, OIS::MouseButton IDid)594 //bool GUIInputHandler::mousePressed(const OIS::MouseEvent &e, OIS::MouseButton id) 619 595 //{ 620 596 ////CEGUI::System::getSingleton().injectMouseButtonDown(convertOISMouseButtonToCegui(id)); … … 627 603 // @param id The ID of the mouse button 628 604 //*/ 629 //bool GUIInputHandler::mouseReleased(const OIS::MouseEvent &e, OIS::MouseButton IDid)605 //bool GUIInputHandler::mouseReleased(const OIS::MouseEvent &e, OIS::MouseButton id) 630 606 //{ 631 607 ////CEGUI::System::getSingleton().injectMouseButtonUp(convertOISMouseButtonToCegui(id));
Note: See TracChangeset
for help on using the changeset viewer.