[Orxonox-commit 3339] r8027 - code/branches/usability/src/libraries/core/input
landauf at orxonox.net
landauf at orxonox.net
Sun Mar 6 01:16:57 CET 2011
Author: landauf
Date: 2011-03-06 01:16:56 +0100 (Sun, 06 Mar 2011)
New Revision: 8027
Modified:
code/branches/usability/src/libraries/core/input/InputBuffer.cc
code/branches/usability/src/libraries/core/input/InputBuffer.h
Log:
added translator map to InputBuffer for numpad keys - now they can also be used to type text into the ingame console
Modified: code/branches/usability/src/libraries/core/input/InputBuffer.cc
===================================================================
--- code/branches/usability/src/libraries/core/input/InputBuffer.cc 2011-03-05 22:56:20 UTC (rev 8026)
+++ code/branches/usability/src/libraries/core/input/InputBuffer.cc 2011-03-06 00:16:56 UTC (rev 8027)
@@ -46,6 +46,20 @@
0123456789 \
\\\"(){}[]<>.:,;_-+*/=!?|$&%^~#";
+ this->keyTranslator_[KeyCode::Numpad0] = '0';
+ this->keyTranslator_[KeyCode::Numpad1] = '1';
+ this->keyTranslator_[KeyCode::Numpad2] = '2';
+ this->keyTranslator_[KeyCode::Numpad3] = '3';
+ this->keyTranslator_[KeyCode::Numpad4] = '4';
+ this->keyTranslator_[KeyCode::Numpad5] = '5';
+ this->keyTranslator_[KeyCode::Numpad6] = '6';
+ this->keyTranslator_[KeyCode::Numpad7] = '7';
+ this->keyTranslator_[KeyCode::Numpad8] = '8';
+ this->keyTranslator_[KeyCode::Numpad9] = '9';
+ this->keyTranslator_[KeyCode::NumpadPeriod] = '.';
+ this->keyTranslator_[KeyCode::Divide] = '/';
+ this->keyTranslator_[KeyCode::NumpadEnter] = '\n';
+
this->lastKey_ = KeyCode::Unassigned;
this->timeSinceKeyPressed_ = 0.0f;
this->timeSinceKeyRepeated_ = 0.0f;
@@ -227,7 +241,11 @@
}
}
- this->insert(static_cast<char>(evt.getText()));
+ std::map<KeyCode::ByEnum, char>::iterator it = this->keyTranslator_.find(evt.getKeyCode());
+ if (it != this->keyTranslator_.end())
+ this->insert(it->second);
+ else
+ this->insert(static_cast<char>(evt.getText()));
}
/**
Modified: code/branches/usability/src/libraries/core/input/InputBuffer.h
===================================================================
--- code/branches/usability/src/libraries/core/input/InputBuffer.h 2011-03-05 22:56:20 UTC (rev 8026)
+++ code/branches/usability/src/libraries/core/input/InputBuffer.h 2011-03-06 00:16:56 UTC (rev 8027)
@@ -177,6 +177,7 @@
std::string buffer_;
std::list<BaseInputBufferListenerTuple*> listeners_;
std::string allowedChars_;
+ std::map<KeyCode::ByEnum, char> keyTranslator_;
unsigned int maxLength_;
unsigned int cursor_;
More information about the Orxonox-commit
mailing list