Changeset 8079 for code/trunk/src/libraries/core/input
- Timestamp:
- Mar 15, 2011, 9:47:11 PM (14 years ago)
- Location:
- code/trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/libraries/core/input/InputManager.cc
r7874 r8079 641 641 state->destroy(); 642 642 } 643 644 bool InputManager::setMouseExclusive(const std::string& name, TriBool::Value value) 645 { 646 if (name == "empty") 647 { 648 COUT(2) << "InputManager: Changing the empty state is not allowed!" << std::endl; 649 return false; 650 } 651 std::map<std::string, InputState*>::iterator it = statesByName_.find(name); 652 if (it != statesByName_.end()) 653 { 654 it->second->setMouseExclusive(value); 655 return true; 656 } 657 return false; 658 } 643 659 } -
code/trunk/src/libraries/core/input/InputManager.h
r7874 r8079 163 163 */ 164 164 bool destroyState(const std::string& name); // tolua_export 165 /** 166 @brief 167 Changes the mouse mode of an input state. 168 @return 169 True if the call was successful, fals if the name was not found 170 */ 171 bool setMouseExclusive(const std::string& name, TriBool::Value value); // tolua_export 165 172 166 173 //------------------------------- -
code/trunk/src/libraries/core/input/KeyBinder.cc
r7958 r8079 431 431 // decrease counter 432 432 button->nCommands_[mode_index]--; 433 // note: we don't replace the old array - it's not one element too large, but no one cares since nCommands_ defines the size 433 // old array would not get deleted if nCommands_ is now 0 434 // otherwise: nobody cares about an array that is one element too large - nCommands_ defines the size 435 if (button->nCommands_[mode_index] == 0) 436 { 437 delete[] button->commands_[mode_index]; 438 button->commands_[mode_index] = 0; 439 } 434 440 435 441 // decrement the index since we shifted the array and continue searching for more occurrences of the command -
code/trunk/src/libraries/core/input/Keyboard.cc
r6422 r8079 36 36 { 37 37 // update modifiers 38 if (arg.key == OIS::KC_RMENU || arg.key == OIS::KC_LMENU) 39 modifiers_ |= KeyboardModifier::Alt; // alt key 40 if (arg.key == OIS::KC_RCONTROL || arg.key == OIS::KC_LCONTROL) 41 modifiers_ |= KeyboardModifier::Ctrl; // ctrl key 42 if (arg.key == OIS::KC_RSHIFT || arg.key == OIS::KC_LSHIFT) 43 modifiers_ |= KeyboardModifier::Shift; // shift key 38 switch (arg.key) 39 { 40 case OIS::KC_RMENU: 41 case OIS::KC_LMENU: 42 modifiers_ |= KeyboardModifier::Alt; // alt key 43 break; 44 case OIS::KC_RCONTROL: 45 case OIS::KC_LCONTROL: 46 modifiers_ |= KeyboardModifier::Ctrl; // ctrl key 47 break; 48 case OIS::KC_RSHIFT: 49 case OIS::KC_LSHIFT: 50 modifiers_ |= KeyboardModifier::Shift; // shift key 51 break; 52 case OIS::KC_TAB: 53 // Do not distribute the alt+tab event (messes with the operating system) 54 if ((modifiers_ & KeyboardModifier::Alt) != 0) 55 return true; 56 default:; 57 } 44 58 45 // Do not distribute the alt+tab event (messes with the operating system) 46 if ((modifiers_ & KeyboardModifier::Alt) != 0 && arg.key == OIS::KC_TAB) 47 return true; 48 49 KeyEvent evt(arg); 59 KeyEvent evt(static_cast<KeyCode::ByEnum>(arg.key), Keyboard::getKeyText(arg), 0); 50 60 super::buttonPressed(evt); 51 61 return true; … … 56 66 { 57 67 // update modifiers 58 if (arg.key == OIS::KC_RMENU || arg.key == OIS::KC_LMENU) 59 modifiers_ &= ~KeyboardModifier::Alt; // alt key 60 if (arg.key == OIS::KC_RCONTROL || arg.key == OIS::KC_LCONTROL) 61 modifiers_ &= ~KeyboardModifier::Ctrl; // ctrl key 62 if (arg.key == OIS::KC_RSHIFT || arg.key == OIS::KC_LSHIFT) 63 modifiers_ &= ~KeyboardModifier::Shift; // shift key 68 switch (arg.key) 69 { 70 case OIS::KC_RMENU: 71 case OIS::KC_LMENU: 72 modifiers_ &= ~KeyboardModifier::Alt; // alt key 73 break; 74 case OIS::KC_RCONTROL: 75 case OIS::KC_LCONTROL: 76 modifiers_ &= ~KeyboardModifier::Ctrl; // ctrl key 77 break; 78 case OIS::KC_RSHIFT: 79 case OIS::KC_LSHIFT: 80 modifiers_ &= ~KeyboardModifier::Shift; // shift key 81 break; 82 default:; 83 } 64 84 65 KeyEvent evt( arg);85 KeyEvent evt(static_cast<KeyCode::ByEnum>(arg.key), Keyboard::getKeyText(arg), 0); 66 86 super::buttonReleased(evt); 67 87 return true; 68 88 } 89 90 /// A map which returns the corresponding chars for some key codes 91 unsigned int Keyboard::getKeyText(const OIS::KeyEvent& arg) 92 { 93 switch (arg.key) 94 { 95 case OIS::KC_NUMPAD0: return static_cast<unsigned int>('0'); 96 case OIS::KC_NUMPAD1: return static_cast<unsigned int>('1'); 97 case OIS::KC_NUMPAD2: return static_cast<unsigned int>('2'); 98 case OIS::KC_NUMPAD3: return static_cast<unsigned int>('3'); 99 case OIS::KC_NUMPAD4: return static_cast<unsigned int>('4'); 100 case OIS::KC_NUMPAD5: return static_cast<unsigned int>('5'); 101 case OIS::KC_NUMPAD6: return static_cast<unsigned int>('6'); 102 case OIS::KC_NUMPAD7: return static_cast<unsigned int>('7'); 103 case OIS::KC_NUMPAD8: return static_cast<unsigned int>('8'); 104 case OIS::KC_NUMPAD9: return static_cast<unsigned int>('9'); 105 case OIS::KC_DECIMAL: return static_cast<unsigned int>('.'); 106 case OIS::KC_DIVIDE: return static_cast<unsigned int>('/'); 107 case OIS::KC_NUMPADENTER: return static_cast<unsigned int>('\n'); 108 default: return arg.text; 109 } 110 } 69 111 } -
code/trunk/src/libraries/core/input/Keyboard.h
r7809 r8079 83 83 static std::string getClassNameImpl() { return "Keyboard"; } 84 84 85 static unsigned int getKeyText(const OIS::KeyEvent& arg); 86 85 87 //! Bit mask representing keyboard modifiers 86 88 int modifiers_;
Note: See TracChangeset
for help on using the changeset viewer.