Changeset 8036
- Timestamp:
- Mar 6, 2011, 7:12:11 PM (14 years ago)
- Location:
- code/branches/usability/src/libraries/core/input
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/usability/src/libraries/core/input/InputBuffer.cc
r8027 r8036 47 47 \\\"(){}[]<>.:,;_-+*/=!?|$&%^~#"; 48 48 49 this->keyTranslator_[KeyCode::Numpad0] = '0';50 this->keyTranslator_[KeyCode::Numpad1] = '1';51 this->keyTranslator_[KeyCode::Numpad2] = '2';52 this->keyTranslator_[KeyCode::Numpad3] = '3';53 this->keyTranslator_[KeyCode::Numpad4] = '4';54 this->keyTranslator_[KeyCode::Numpad5] = '5';55 this->keyTranslator_[KeyCode::Numpad6] = '6';56 this->keyTranslator_[KeyCode::Numpad7] = '7';57 this->keyTranslator_[KeyCode::Numpad8] = '8';58 this->keyTranslator_[KeyCode::Numpad9] = '9';59 this->keyTranslator_[KeyCode::NumpadPeriod] = '.';60 this->keyTranslator_[KeyCode::Divide] = '/';61 this->keyTranslator_[KeyCode::NumpadEnter] = '\n';62 63 49 this->lastKey_ = KeyCode::Unassigned; 64 50 this->timeSinceKeyPressed_ = 0.0f; … … 242 228 } 243 229 244 std::map<KeyCode::ByEnum, char>::iterator it = this->keyTranslator_.find(evt.getKeyCode()); 245 if (it != this->keyTranslator_.end()) 246 this->insert(it->second); 247 else 248 this->insert(static_cast<char>(evt.getText())); 230 this->insert(static_cast<char>(evt.getText())); 249 231 } 250 232 -
code/branches/usability/src/libraries/core/input/InputBuffer.h
r8027 r8036 178 178 std::list<BaseInputBufferListenerTuple*> listeners_; 179 179 std::string allowedChars_; 180 std::map<KeyCode::ByEnum, char> keyTranslator_;181 180 unsigned int maxLength_; 182 181 unsigned int cursor_; -
code/branches/usability/src/libraries/core/input/Keyboard.cc
r6422 r8036 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/branches/usability/src/libraries/core/input/Keyboard.h
r7809 r8036 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.