I'm working on an Android project and there are some letters (such as :, ;, /, |, *, etc.) that aren't supported by default with the touchscreen.
In order to make them work, I use the following code:
Code: Select all
void MyEventReceiver::SendKeyEvent( irr::EKEY_CODE key_, bool pressedDown_, wchar_t character_)
{
if ( Game::device && Game::device->getGUIEnvironment() )
{
SEvent irrEvent;
irrEvent.EventType = irr::EET_KEY_INPUT_EVENT;
irrEvent.KeyInput.PressedDown = pressedDown_;
irrEvent.KeyInput.Control = false;
irrEvent.KeyInput.Shift = false;
irrEvent.KeyInput.Char = character_;
irrEvent.KeyInput.Key = key_;
//Game::receiver.OnEvent(irrEvent);
Game::device->getGUIEnvironment()->postEventFromUser(irrEvent);
}
}
bool MyEventReceiver::OnEvent(const SEvent& event)
{
// ...
if (event.EventType == irr::EET_KEY_INPUT_EVENT)
{
#ifdef _IRR_ANDROID_PLATFORM_
int SystemKeyCode = event.KeyInput.SystemKeyCode;
if (SystemKeyCode == 17)
MyEventReceiver::SendKeyEvent((irr::EKEY_CODE)17,true,'*');
else if (SystemKeyCode == 75)
if (event.KeyInput.Shift)
MyEventReceiver::SendKeyEvent((irr::EKEY_CODE)75,true,'\"');
else
MyEventReceiver::SendKeyEvent((irr::EKEY_CODE)75,true,'\'');
else if (SystemKeyCode == 74)
if (event.KeyInput.Shift)
MyEventReceiver::SendKeyEvent((irr::EKEY_CODE)74,true,':');
else
MyEventReceiver::SendKeyEvent((irr::EKEY_CODE)74,true,';');
else if (SystemKeyCode == 76)
if (event.KeyInput.Shift)
MyEventReceiver::SendKeyEvent((irr::EKEY_CODE)76,true,'?');
else
MyEventReceiver::SendKeyEvent((irr::EKEY_CODE)76,true,'/');
else if (SystemKeyCode == 73)
if (event.KeyInput.Shift)
MyEventReceiver::SendKeyEvent((irr::EKEY_CODE)73,true,'|');
else
MyEventReceiver::SendKeyEvent((irr::EKEY_CODE)73,true,'\\');
else if (SystemKeyCode == 70)
MyEventReceiver::SendKeyEvent((irr::EKEY_CODE)70,true,'=');
else if (SystemKeyCode == 71)
if (event.KeyInput.Shift)
MyEventReceiver::SendKeyEvent((irr::EKEY_CODE)71,true,'{');
else
MyEventReceiver::SendKeyEvent((irr::EKEY_CODE)71,true,'[');
else if (SystemKeyCode == 72)
if (event.KeyInput.Shift)
MyEventReceiver::SendKeyEvent((irr::EKEY_CODE)72,true,'}');
else
MyEventReceiver::SendKeyEvent((irr::EKEY_CODE)72,true,']');
#endif // _IRR_ANDROID_PLATFORM_
// ...
}
I.E entering [ will put [[ in an editbox in Android.
I checked in the event receiver, and one letter is being caught. One for PressedDown and one for !PressedDown.