while I was working on a virtual keyboard I dicovered problems with the Alt keys (LMENU and RMENU) !!!
if you press the left Alt key it stays pressed until you press it again !!!
if you press the right Alt key also the left Ctrl key gets pressed !!!
this code shows the three keys and it's states:
Code: Select all
#include <irrlicht.h>
using namespace irr;
using namespace core;
using namespace video;
using namespace gui;
class MyEventReceiver : public IEventReceiver{
public:
virtual bool OnEvent(const SEvent& event){
if(event.EventType == irr::EET_KEY_INPUT_EVENT)
KeyIsDown[event.KeyInput.Key] = event.KeyInput.PressedDown;
return false;
}
virtual bool IsKeyDown(EKEY_CODE keyCode) const{
return KeyIsDown[keyCode];
}
MyEventReceiver(){
for (u32 i=0; i<KEY_KEY_CODES_COUNT; ++i)
KeyIsDown[i] = false;
}
private:
bool KeyIsDown[KEY_KEY_CODES_COUNT];
};
int main(){
MyEventReceiver receiver;
IrrlichtDevice* device = createDevice(EDT_DIRECT3D9, dimension2du(640, 480), 16, false, false, false, &receiver);
IVideoDriver* driver = device->getVideoDriver();
IGUIEnvironment* guienv = device->getGUIEnvironment();
IGUIFont* fnt = guienv->getBuiltInFont();
SColor col;
while(device->run()){
driver->beginScene(true, true, video::SColor(0,50,100,150));
col = receiver.IsKeyDown(KEY_LCONTROL)? SColor(255,0,255,0):SColor(255,0,0,0);
fnt->draw(L"LCONTROL", recti(50,100,100,110), col);
col = receiver.IsKeyDown(KEY_LMENU)? SColor(255,0,255,0):SColor(255,0,0,0);
fnt->draw(L"LMENU", recti(120,100,150,110), col);
col = receiver.IsKeyDown(KEY_RMENU)? SColor(255,0,255,0):SColor(255,0,0,0);
fnt->draw(L"RMENU", recti(170,100,200,110), col);
driver->endScene();
}
device->drop();
return 0;
}