[SOLVED]OIS::KeyEvent::text does not work for me

Nyran

11-05-2011 21:49:35

Good evening, anyone who's reading this,
I've got a problem and can't manage to solve it, though I read some topics about it.
It is particularly about the OIS::KeyEvent in connection with the MyGUI-AddOn.

I use a keylistener in a MyGUI class, and the overwritten keyReleased function with an OIS::keyEvent reference as parameter.
It looks like this:


bool MyGUIManager::keyReleased( const OIS::KeyEvent &e )
{

std::cout<<e.text<<"\n";

...
}


But all I get as console output is "0", as if it couldn't convert the keycode. If I use a switch for the e.key statement it is recognized, therefore I can handle Input like


switch(e.key)
{
case OIS::KC_A :m_editEingabe->insertText("a",m_cursorPosition);
break;
case OIS::KC_B : m_editEingabe->insertText("b",m_cursorPosition);
break;
case OIS::KC_C : m_editEingabe->insertText("c",m_cursorPosition);
break;
case OIS::KC_D : m_editEingabe->insertText("d",m_cursorPosition);
break;

(where m_editEingabe is an MyGUI::Edit object)
, but with this method I can't write special characters like "äöü" or something like that.

I also set the textranslationmode to Unicode for my OIS::Keyboard object, after creating it.

Therefore I would like to know if there's a known and working method to get unicode characters that I can use in the edit field out of the OIS::KeyEvent (or some MyGUI-InputEvent, it doesn't matter, as long as it works).

Thank you for your help. =)

Altren

11-05-2011 22:56:22

This is question to OIS developers :) I guess you initialise OIS keyboard in mode that doesn't return text at all.

Nyran

12-05-2011 09:06:11

Excuse the post into this Thread, but I did it with the intention to get some information about a MyGUI::InputManager solution, if my approach seems to be not working, so this one seemed to fit my needs. =)

Thanks for the assume Altren, but I think there's not that many ways to initialise an OIS::Keyboard (please tell me if I'm wrong).

In my opinion there's only the type of of OIS::Object you want to create, a boolean for having buffered mode (or not :o) and a string for determining a vendor (don't know what this exactly means, but shouldn't be necessary for getting some text out of a keyevent, should it?).

My initialisation seems like this =)

if (mInputSystem->getNumberOfDevices(OIS::OISKeyboard) > 0) {
mKeyboard = static_cast<OIS::Keyboard*>( mInputSystem->createInputObject( OIS::OISKeyboard, true) );


mKeyboard->setTextTranslation(OIS::Keyboard::Unicode);
mKeyboard->setEventCallback( this );


By the way, if I'm asking for the type of TextTranslationMode from my InputManager class (getting the keyboard trough a Singleton of my OIS::InputManager class) it fits with the OIS::Keyboard::Unicode type, so I'm wondering if it's just a question of compiler settings or something like that.

Altren

12-05-2011 16:09:14

We don't use OIS::Keyboard::Unicode in our demos, but still have Unicode input. We do manual text conversion, because OIS fails in some cases.
Common/Input/OIS/InputManager.cpp in MyGUI sources.

Nyran

12-05-2011 17:32:11

Thank you so much Altren!

Though i found the Source-File trough a search-engine I did not notice the important part about the Win32-conversion. Adding the translatingWin32Text-method to my code everything seems to work.

I owe you one :D

Nyran