Changeset 1788 for code/trunk/src/core
- Timestamp:
- Sep 15, 2008, 12:40:40 PM (16 years ago)
- Location:
- code/trunk/src/core/input
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/core/input/InputManager.cc
r1770 r1788 109 109 , stateCalibrator_(0) 110 110 , stateEmpty_(0) 111 , stateMaster_(0) 111 112 , bCalibrating_(false) 112 113 , keyboardModifiers_(0) … … 201 202 buffer->registerListener(this, &InputManager::_completeCalibration, '\r', true); 202 203 stateCalibrator_->setKeyHandler(buffer); 204 205 stateMaster_ = new ExtendedInputState(); 206 stateMaster_->setName("master"); 203 207 204 208 internalState_ |= InternalsReady; … … 441 445 _destroyState((*inputStatesByPriority_.rbegin()).second); 442 446 447 // destroy the master input state. This might trigger a memory leak 448 // because the user has forgotten to destroy the KeyBinder or any Handler! 449 delete stateMaster_; 450 443 451 // destroy the devices 444 452 _destroyKeyboard(); … … 688 696 // call all the handlers for the held key events 689 697 for (unsigned int iKey = 0; iKey < keysDown_.size(); iKey++) 690 activeStatesTop_[Keyboard]->keyHeld(KeyEvent(keysDown_[iKey], keyboardModifiers_)); 698 { 699 KeyEvent kEvt(keysDown_[iKey], keyboardModifiers_); 700 activeStatesTop_[Keyboard]->keyHeld(kEvt); 701 stateMaster_->keyHeld(kEvt); 702 } 691 703 692 704 // call all the handlers for the held mouse button events 693 705 for (unsigned int iButton = 0; iButton < mouseButtonsDown_.size(); iButton++) 706 { 694 707 activeStatesTop_[Mouse]->mouseButtonHeld(mouseButtonsDown_[iButton]); 708 stateMaster_->mouseButtonHeld(mouseButtonsDown_[iButton]); 709 } 695 710 696 711 // call all the handlers for the held joy stick button events 697 712 for (unsigned int iJoyStick = 0; iJoyStick < joySticksSize_; iJoyStick++) 698 713 for (unsigned int iButton = 0; iButton < joyStickButtonsDown_[iJoyStick].size(); iButton++) 714 { 699 715 activeStatesTop_[JoyStick0 + iJoyStick] 700 716 ->joyStickButtonHeld(iJoyStick, joyStickButtonsDown_[iJoyStick][iButton]); 717 stateMaster_->joyStickButtonHeld(iJoyStick, joyStickButtonsDown_[iJoyStick][iButton]); 718 } 701 719 702 720 // tick the handlers for each active handler 703 721 for (unsigned int i = 0; i < devicesNum_; ++i) 722 { 704 723 activeStatesTop_[i]->tickInput(dt, i); 724 if (stateMaster_->isInputDeviceEnabled(i)) 725 stateMaster_->tickInput(dt, i); 726 } 705 727 706 728 // tick the handler with a general tick afterwards 707 729 for (unsigned int i = 0; i < activeStatesTicked_.size(); ++i) 708 730 activeStatesTicked_[i]->tickInput(dt); 731 stateMaster_->tickInput(dt); 709 732 } 710 733 … … 828 851 keysDown_.push_back(Key(e)); 829 852 else 853 { 854 // This happens when XAutoRepeat is set under linux. The KeyPressed event gets then sent 855 // continuously. 830 856 return true; 857 } 831 858 832 859 // update modifiers … … 838 865 keyboardModifiers_ |= KeyboardModifier::Shift; // shift key 839 866 840 activeStatesTop_[Keyboard]->keyPressed(KeyEvent(e, keyboardModifiers_)); 867 KeyEvent kEvt(e, keyboardModifiers_); 868 activeStatesTop_[Keyboard]->keyPressed(kEvt); 869 stateMaster_->keyPressed(kEvt); 841 870 842 871 return true; … … 869 898 keyboardModifiers_ &= ~KeyboardModifier::Shift; // shift key 870 899 871 activeStatesTop_[Keyboard]->keyReleased(KeyEvent(e, keyboardModifiers_)); 900 KeyEvent kEvt(e, keyboardModifiers_); 901 activeStatesTop_[Keyboard]->keyReleased(kEvt); 902 stateMaster_->keyReleased(kEvt); 872 903 873 904 return true; … … 888 919 if (e.state.X.rel != 0 || e.state.Y.rel != 0) 889 920 { 890 activeStatesTop_[Mouse]->mouseMoved(IntVector2(e.state.X.abs, e.state.Y.abs), 891 IntVector2(e.state.X.rel, e.state.Y.rel), IntVector2(e.state.width, e.state.height)); 921 IntVector2 abs(e.state.X.abs, e.state.Y.abs); 922 IntVector2 rel(e.state.X.rel, e.state.Y.rel); 923 IntVector2 clippingSize(e.state.width, e.state.height); 924 activeStatesTop_[Mouse]->mouseMoved(abs, rel, clippingSize); 925 stateMaster_->mouseMoved(abs, rel, clippingSize); 892 926 } 893 927 … … 896 930 { 897 931 activeStatesTop_[Mouse]->mouseScrolled(e.state.Z.abs, e.state.Z.rel); 932 stateMaster_->mouseScrolled(e.state.Z.abs, e.state.Z.rel); 898 933 } 899 934 … … 919 954 920 955 activeStatesTop_[Mouse]->mouseButtonPressed((MouseButton::Enum)id); 956 stateMaster_->mouseButtonPressed((MouseButton::Enum)id); 921 957 922 958 return true; … … 944 980 945 981 activeStatesTop_[Mouse]->mouseButtonReleased((MouseButton::Enum)id); 982 stateMaster_->mouseButtonReleased((MouseButton::Enum)id); 946 983 947 984 return true; … … 980 1017 981 1018 activeStatesTop_[2 + iJoyStick]->joyStickButtonPressed(iJoyStick, (JoyStickButton::Enum)button); 1019 stateMaster_->joyStickButtonPressed(iJoyStick, (JoyStickButton::Enum)button); 982 1020 983 1021 return true; … … 1000 1038 1001 1039 activeStatesTop_[2 + iJoyStick]->joyStickButtonReleased(iJoyStick, (JoyStickButton::Enum)button); 1040 stateMaster_->joyStickButtonReleased(iJoyStick, (JoyStickButton::Enum)button); 1002 1041 1003 1042 return true; … … 1027 1066 1028 1067 activeStatesTop_[2 + iJoyStick]->joyStickAxisMoved(iJoyStick, axis, fValue); 1068 stateMaster_->joyStickAxisMoved(iJoyStick, axis, fValue); 1029 1069 } 1030 1070 } -
code/trunk/src/core/input/InputManager.h
r1755 r1788 129 129 InputState* getState (const std::string& name); 130 130 InputState* getCurrentState(); 131 ExtendedInputState* getMasterInputState() { return this->stateMaster_; } 131 132 bool requestDestroyState (const std::string& name); 132 133 bool requestEnterState (const std::string& name); … … 200 201 SimpleInputState* stateCalibrator_; 201 202 SimpleInputState* stateEmpty_; 203 ExtendedInputState* stateMaster_; //!< Always active master input state 202 204 203 205 std::map<std::string, InputState*> inputStatesByName_;
Note: See TracChangeset
for help on using the changeset viewer.