Changeset 1259
- Timestamp:
- May 12, 2008, 7:06:49 PM (17 years ago)
- Location:
- code/branches/input
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/input/bin/keybindings.ini
r1219 r1259 24 24 R_6= 25 25 H_6= 26 P_7= 26 P_7="exec disco.txt" 27 27 R_7= 28 28 H_7= … … 30 30 R_8= 31 31 H_8= 32 P_9= 32 P_9="disco.txt" 33 33 R_9= 34 34 H_9= -
code/branches/input/src/core/InputBuffer.cc
r1237 r1259 37 37 namespace orxonox 38 38 { 39 InputBuffer::InputBuffer(const std::string allowedChars) 39 InputBuffer::InputBuffer(const std::string allowedChars) : 40 buffer_(""), 41 allowedChars_(allowedChars), 42 lastKey_(KeyCode::Unassigned), 43 timeSinceKeyPressed_(0.0f), 44 timeSinceKeyRepeated_(0.0f), 45 keysToRepeat_(0) 40 46 { 41 47 RegisterObject(InputBuffer); 42 48 setConfigValues(); 43 allowedChars_ = allowedChars;44 buffer_ = "";45 lastKey_ = KeyCode::Unassigned;46 timeSinceKeyPressed_ = 0.0;47 timeSinceKeyRepeated_ = 0.0;48 keysToRepeat_ = 0;49 49 } 50 50 -
code/branches/input/src/core/InputBuffer.h
r1237 r1259 98 98 { return this->buffer_; } 99 99 100 private: 100 private: // functions 101 101 bool charIsAllowed(const char& input); 102 102 … … 108 108 void tick(float dt); 109 109 110 private: // variables 110 111 std::string buffer_; 111 112 std::list<InputBufferListenerTuple> listeners_; -
code/branches/input/src/core/InputHandler.cc
r1237 r1259 229 229 230 230 std::string mouseButtonNames[] = { 231 "MouseLeft", "MouseRight", "MouseMiddle",232 "MouseButton3", "MouseButton4", "MouseButton5",233 "MouseButton6", "MouseButton7" };231 "MouseLeft", "MouseRight", "MouseMiddle", 232 "MouseButton3", "MouseButton4", "MouseButton5", 233 "MouseButton6", "MouseButton7" }; 234 234 for (int i = 0; i < numberOfMouseButtons_s; i++) 235 235 mouseButtonNames_[i] = mouseButtonNames[i]; … … 381 381 } 382 382 383 bool KeyBinder::execute Binding(KeyBinding& binding)383 bool KeyBinder::executeSimpleBinding(KeyBinding& binding) 384 384 { 385 385 if (binding.commandStr != "") … … 406 406 { 407 407 // find the appropriate key binding 408 execute Binding(bindingsKeyPress_[int(evt.key)]);408 executeSimpleBinding(bindingsKeyPress_[int(evt.key)]); 409 409 410 410 return true; … … 418 418 { 419 419 // find the appropriate key binding 420 execute Binding(bindingsKeyRelease_[int(evt.key)]);420 executeSimpleBinding(bindingsKeyRelease_[int(evt.key)]); 421 421 422 422 return true; … … 430 430 { 431 431 // find the appropriate key binding 432 execute Binding(bindingsKeyHold_[int(evt.key)]);432 executeSimpleBinding(bindingsKeyHold_[int(evt.key)]); 433 433 434 434 return true; … … 441 441 bool KeyBinder::mouseMoved(const MouseState &evt) 442 442 { 443 return true; 444 } 445 446 /** 447 @brief Event handler for the mouseWheelTurned Event. 443 /*if (bindingMouseMoved_.commandStr != "") 444 { 445 if (bindingMouseMoved_.commandStr != bindingMouseMoved_.evaluation.getCommandString()) 446 { 447 // key binding has changed, reevaluate the command string. 448 bindingMouseMoved_.evaluation = CommandExecutor::evaluate(bindingMouseMoved_.commandStr); 449 bindingMouseMoved_.commandStr = bindingMouseMoved_.evaluation.getCommandString(); 450 } 451 COUT(3) << "Executing command: " << bindingMouseMoved_.commandStr << std::endl; 452 453 bindingMouseMoved_.evaluation.setEvaluatedParameter( 454 CommandExecutor::execute(bindingMouseMoved_.commandStr); 455 }*/ 456 457 return true; 458 } 459 460 /** 461 @brief Event handler for the mouseScrolled Event. 448 462 @param e Mouse state information 449 463 */ 450 bool KeyBinder::mouse WheelTurned(const MouseState &evt)464 bool KeyBinder::mouseScrolled(const MouseState &evt) 451 465 { 452 466 return true; … … 461 475 { 462 476 // find the appropriate key binding 463 execute Binding(bindingsMouseButtonPress_[int(id)]);477 executeSimpleBinding(bindingsMouseButtonPress_[int(id)]); 464 478 465 479 return true; … … 474 488 { 475 489 // find the appropriate key binding 476 execute Binding(bindingsMouseButtonRelease_[int(id)]);490 executeSimpleBinding(bindingsMouseButtonRelease_[int(id)]); 477 491 478 492 return true; … … 487 501 { 488 502 // find the appropriate key binding 489 execute Binding(bindingsMouseButtonHold_[int(id)]);503 executeSimpleBinding(bindingsMouseButtonHold_[int(id)]); 490 504 491 505 return true; … … 495 509 { 496 510 // find the appropriate key binding 497 execute Binding(bindingsJoyStickButtonPress_[button]);511 executeSimpleBinding(bindingsJoyStickButtonPress_[button]); 498 512 499 513 return true; … … 503 517 { 504 518 // find the appropriate key binding 505 execute Binding(bindingsJoyStickButtonRelease_[button]);519 executeSimpleBinding(bindingsJoyStickButtonRelease_[button]); 506 520 507 521 return true; … … 511 525 { 512 526 // find the appropriate key binding 513 execute Binding(bindingsJoyStickButtonHold_[button]);527 executeSimpleBinding(bindingsJoyStickButtonHold_[button]); 514 528 515 529 return true; -
code/branches/input/src/core/InputHandler.h
r1237 r1259 79 79 void setConfigValues(); 80 80 81 std::string testtest;82 83 81 private: // functions 84 82 85 bool execute Binding(KeyBinding &binding);83 bool executeSimpleBinding(KeyBinding &binding); 86 84 87 85 bool keyPressed (const KeyEvent& evt); … … 93 91 bool mouseButtonHeld (const MouseState& state, MouseButton::Enum id); 94 92 bool mouseMoved (const MouseState& state); 95 bool mouse WheelTurned(const MouseState& state);93 bool mouseScrolled (const MouseState& state); 96 94 97 95 bool joyStickButtonPressed (const JoyStickState& state, int button); … … 124 122 //! Array of input events for every held mouse button 125 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_; 126 128 //! Names of the mouse buttons as strings 127 129 std::string mouseButtonNames_[numberOfMouseButtons_s]; -
code/branches/input/src/core/InputInterfaces.h
r1238 r1259 48 48 Unassigned = OIS::KC_UNASSIGNED, 49 49 Escape = OIS::KC_ESCAPE, 50 _1= OIS::KC_1,51 _2= OIS::KC_2,52 _3= OIS::KC_3,53 _4= OIS::KC_4,54 _5= OIS::KC_5,55 _6= OIS::KC_6,56 _7= OIS::KC_7,57 _8= OIS::KC_8,58 _9= OIS::KC_9,59 _0= OIS::KC_0,50 NumRow1 = OIS::KC_1, 51 NumRow2 = OIS::KC_2, 52 NumRow3 = OIS::KC_3, 53 NumRow4 = OIS::KC_4, 54 NumRow5 = OIS::KC_5, 55 NumRow6 = OIS::KC_6, 56 NumRow7 = OIS::KC_7, 57 NumRow8 = OIS::KC_8, 58 NumRow9 = OIS::KC_9, 59 NumRow0 = OIS::KC_0, 60 60 Minus = OIS::KC_MINUS, // - on main keyboard 61 61 Equals = OIS::KC_EQUALS, … … 244 244 { 245 245 public: 246 JoyStickState(const OIS::JoyStickState& state, int ID) : OIS::JoyStickState(state), JoyStickID(ID) { }246 JoyStickState(const OIS::JoyStickState& state, int ID) : OIS::JoyStickState(state), mJoyStickID(ID) { } 247 247 JoyStickState() { clear(); } 248 int JoyStickID;248 int mJoyStickID; 249 249 }; 250 250 … … 272 272 virtual bool mouseButtonHeld (const MouseState& state, MouseButton::Enum id) = 0; 273 273 virtual bool mouseMoved (const MouseState& state) = 0; 274 virtual bool mouse WheelTurned(const MouseState& state) = 0;274 virtual bool mouseScrolled (const MouseState& state) = 0; 275 275 }; 276 276 -
code/branches/input/src/core/InputManager.cc
r1239 r1259 52 52 InputManager::InputManager() : 53 53 inputSystem_(0), keyboard_(0), mouse_(0), 54 joySticksSize_(0), 54 55 state_(IS_UNINIT), stateRequest_(IS_UNINIT), 55 joySticksSize_(0)56 keyboardModifiers_(0) 56 57 { 57 58 RegisterObject(InputManager); 58 59 //this->joySticks_.reserve(5);60 //this->activeJoyStickHandlers_.reserve(10);61 this->activeKeyHandlers_.reserve(10);62 this->activeMouseHandlers_.reserve(10);63 59 } 64 60 … … 88 84 @param windowHeight The height of the render window 89 85 */ 90 bool InputManager::_initialise(const size_t windowHnd, const int windowWidth, constint windowHeight,91 const bool createKeyboard, const bool createMouse, constbool createJoySticks)86 bool InputManager::_initialise(const size_t windowHnd, int windowWidth, int windowHeight, 87 bool createKeyboard, bool createMouse, bool createJoySticks) 92 88 { 93 89 if (state_ == IS_UNINIT) … … 146 142 addKeyHandler(binder, "keybinder"); 147 143 addMouseHandler(binder, "keybinder"); 144 addJoyStickHandler(binder, "keybinder"); 148 145 149 146 // Read all the key bindings and assign them … … 267 264 } 268 265 joySticksSize_ = joySticks_.size(); 266 activeJoyStickHandlers_.resize(joySticksSize_); 267 joyStickButtonsDown_.resize(joySticksSize_); 269 268 return success; 270 269 } … … 375 374 activeKeyHandlers_.clear(); 376 375 activeMouseHandlers_.clear(); 377 activeJoyStickHandlers_.clear(); 376 for (unsigned int i = 0; i < joySticksSize_; i++) 377 activeJoyStickHandlers_[i].clear(); 378 378 379 379 switch (stateRequest_) … … 414 414 if (keyboard_) 415 415 keyboard_->capture(); 416 for (unsigned int i = 0; i < joySticksSize_; i++) 417 joySticks_[i]->capture(); 416 418 417 419 … … 428 430 // call all the handlers for the held joy stick button events 429 431 for (unsigned int iJoyStick = 0; iJoyStick < joySticksSize_; iJoyStick++) 430 for (unsigned int iButton = 0; iButton < joyStickButtonsDown_ .size(); iButton++)432 for (unsigned int iButton = 0; iButton < joyStickButtonsDown_[iJoyStick].size(); iButton++) 431 433 for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++) 432 434 activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickButtonHeld( … … 509 511 } 510 512 511 // check for mouse wheel turned event513 // check for mouse scrolled event 512 514 if (e.state.Z.rel != 0) 513 515 { 514 516 for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++) 515 activeMouseHandlers_[i]->mouse WheelTurned(e.state);517 activeMouseHandlers_[i]->mouseScrolled(e.state); 516 518 } 517 519 … … 674 676 // ################################ 675 677 676 bool InputManager::initialise(const size_t windowHnd, const int windowWidth, constint windowHeight,677 const bool createKeyboard, const bool createMouse, constbool createJoySticks)678 bool InputManager::initialise(const size_t windowHnd, int windowWidth, int windowHeight, 679 bool createKeyboard, bool createMouse, bool createJoySticks) 678 680 { 679 681 return _getSingleton()._initialise(windowHnd, windowWidth, windowHeight, -
code/branches/input/src/core/InputManager.h
r1237 r1259 39 39 40 40 #include <map> 41 #include < list>41 #include <vector> 42 42 43 43 #include "ois/OIS.h" … … 69 69 70 70 public: // static functions 71 static bool initialise(const size_t windowHnd, const int windowWidth, constint windowHeight,72 const bool createKeyboard = true, const bool createMouse = true, constbool createJoySticks = false);71 static bool initialise(const size_t windowHnd, int windowWidth, int windowHeight, 72 bool createKeyboard = true, bool createMouse = true, bool createJoySticks = false); 73 73 static bool initialiseKeyboard(); 74 74 static bool initialiseMouse(); … … 121 121 122 122 // Intenal methods 123 bool _initialise(const size_t, const int, const int, const bool, const bool, constbool);123 bool _initialise(const size_t, int, int, bool, bool, bool); 124 124 bool _initialiseKeyboard(); 125 125 bool _initialiseMouse(); … … 169 169 170 170 std::vector<Key> keysDown_; 171 std::vector<MouseButton::Enum> mouseButtonsDown_;171 std::vector<MouseButton::Enum> mouseButtonsDown_; 172 172 std::vector<std::vector<int> > joyStickButtonsDown_; 173 173 -
code/branches/input/src/core/SignalHandler.cc
r1240 r1259 65 65 66 66 // prepare for restoring XAutoKeyRepeat 67 68 69 { 70 71 72 73 74 75 76 67 Display* display; 68 if ((display = XOpenDisplay(0))) 69 { 70 XKeyboardState oldState; 71 XGetKeyboardControl(display, &oldState); 72 if (oldState.global_auto_repeat == AutoRepeatModeOn) 73 bXAutoKeyRepeatOn_ = true; 74 else 75 bXAutoKeyRepeatOn_ = false; 76 XCloseDisplay(display); 77 77 } 78 78 else -
code/branches/input/src/orxonox/Orxonox.cc
r1219 r1259 401 401 { 402 402 if (!InputManager::initialise(ogre_->getWindowHandle(), 403 ogre_->getWindowWidth(), ogre_->getWindowHeight() ))403 ogre_->getWindowWidth(), ogre_->getWindowHeight(), true, true, true)) 404 404 abortImmediateForce(); 405 405 InputManager::setInputState(InputManager::IS_NORMAL); -
code/branches/input/src/orxonox/objects/SpaceShip.h
r1236 r1259 69 69 bool mouseButtonHeld (const MouseState& state, MouseButton::Enum id) { return true; } 70 70 bool mouseMoved (const MouseState& state); 71 bool mouse WheelTurned(const MouseState& state) { return true; }71 bool mouseScrolled (const MouseState& state) { return true; } 72 72 73 73 -
code/branches/input/visual_studio/vc8/ois.vcproj
r1219 r1259 560 560 </File> 561 561 </Filter> 562 <Filter 563 Name="linux" 564 > 565 <File 566 RelativePath="..\..\src\ois\linux\EventHelpers.cpp" 567 > 568 <FileConfiguration 569 Name="Release|Win32" 570 ExcludedFromBuild="true" 571 > 572 <Tool 573 Name="VCCLCompilerTool" 574 /> 575 </FileConfiguration> 576 <FileConfiguration 577 Name="Debug|Win32" 578 ExcludedFromBuild="true" 579 > 580 <Tool 581 Name="VCCLCompilerTool" 582 /> 583 </FileConfiguration> 584 </File> 585 <File 586 RelativePath="..\..\src\ois\linux\LinuxForceFeedback.cpp" 587 > 588 <FileConfiguration 589 Name="Release|Win32" 590 ExcludedFromBuild="true" 591 > 592 <Tool 593 Name="VCCLCompilerTool" 594 /> 595 </FileConfiguration> 596 <FileConfiguration 597 Name="Debug|Win32" 598 ExcludedFromBuild="true" 599 > 600 <Tool 601 Name="VCCLCompilerTool" 602 /> 603 </FileConfiguration> 604 </File> 605 <File 606 RelativePath="..\..\src\ois\linux\LinuxInputManager.cpp" 607 > 608 <FileConfiguration 609 Name="Release|Win32" 610 ExcludedFromBuild="true" 611 > 612 <Tool 613 Name="VCCLCompilerTool" 614 /> 615 </FileConfiguration> 616 <FileConfiguration 617 Name="Debug|Win32" 618 ExcludedFromBuild="true" 619 > 620 <Tool 621 Name="VCCLCompilerTool" 622 /> 623 </FileConfiguration> 624 </File> 625 <File 626 RelativePath="..\..\src\ois\linux\LinuxJoyStickEvents.cpp" 627 > 628 <FileConfiguration 629 Name="Release|Win32" 630 ExcludedFromBuild="true" 631 > 632 <Tool 633 Name="VCCLCompilerTool" 634 /> 635 </FileConfiguration> 636 <FileConfiguration 637 Name="Debug|Win32" 638 ExcludedFromBuild="true" 639 > 640 <Tool 641 Name="VCCLCompilerTool" 642 /> 643 </FileConfiguration> 644 </File> 645 <File 646 RelativePath="..\..\src\ois\linux\LinuxKeyboard.cpp" 647 > 648 <FileConfiguration 649 Name="Release|Win32" 650 ExcludedFromBuild="true" 651 > 652 <Tool 653 Name="VCCLCompilerTool" 654 /> 655 </FileConfiguration> 656 <FileConfiguration 657 Name="Debug|Win32" 658 ExcludedFromBuild="true" 659 > 660 <Tool 661 Name="VCCLCompilerTool" 662 /> 663 </FileConfiguration> 664 </File> 665 <File 666 RelativePath="..\..\src\ois\linux\LinuxMouse.cpp" 667 > 668 <FileConfiguration 669 Name="Release|Win32" 670 ExcludedFromBuild="true" 671 > 672 <Tool 673 Name="VCCLCompilerTool" 674 /> 675 </FileConfiguration> 676 <FileConfiguration 677 Name="Debug|Win32" 678 ExcludedFromBuild="true" 679 > 680 <Tool 681 Name="VCCLCompilerTool" 682 /> 683 </FileConfiguration> 684 </File> 685 </Filter> 562 686 </Filter> 563 687 <Filter … … 650 774 <File 651 775 RelativePath="..\..\src\ois\OISInterface.h" 776 > 777 </File> 778 </Filter> 779 <Filter 780 Name="linux" 781 > 782 <File 783 RelativePath="..\..\src\ois\linux\EventHelpers.h" 784 > 785 </File> 786 <File 787 RelativePath="..\..\src\ois\linux\LinuxForceFeedback.h" 788 > 789 </File> 790 <File 791 RelativePath="..\..\src\ois\linux\LinuxInputManager.h" 792 > 793 </File> 794 <File 795 RelativePath="..\..\src\ois\linux\LinuxJoyStickEvents.h" 796 > 797 </File> 798 <File 799 RelativePath="..\..\src\ois\linux\LinuxKeyboard.h" 800 > 801 </File> 802 <File 803 RelativePath="..\..\src\ois\linux\LinuxMouse.h" 804 > 805 </File> 806 <File 807 RelativePath="..\..\src\ois\linux\LinuxPrereqs.h" 652 808 > 653 809 </File>
Note: See TracChangeset
for help on using the changeset viewer.