i am attempting to create a small air fight game with irrlicht, and I want to use the mouse to mouve the plane, but I am facing the following issue: when the mouse come on the screen borders, no mouseup or mousedown movement is recognised... I tried to automatically recenter it, but it is taken as a mouse movement event by IEventReceiver.
Here is my code
Code: Select all
class PlayerEventReceiver : public IEventReceiver
{
public:
PlayerEventReceiver(Universe *u)
{
for (u32 i=0; i<KEY_KEY_CODES_COUNT; ++i)
KeyIsDown[i] = false;
univers = u;
lmb = false;
rmb = false;
prendreencompte=0;
}
virtual bool OnEvent(const SEvent& event)
{
if (event.EventType == irr::EET_KEY_INPUT_EVENT)
KeyIsDown[event.KeyInput.Key] = event.KeyInput.PressedDown;
mup=mdown=false;
if (event.EventType == EET_MOUSE_INPUT_EVENT)
{
switch(event.MouseInput.Event)
{
case EMIE_MOUSE_MOVED:
if(event.MouseInput.Y - mouseY > 0)
{
mup=true;
}
if(event.MouseInput.Y - mouseY < 0)
{
mdown=true;
}
mouseX = event.MouseInput.X;
mouseY = event.MouseInput.Y;
std::cout << "MOuseEve,t" << std::endl;
break;
case EMIE_LMOUSE_PRESSED_DOWN:
lmb = true;
break;
case EMIE_RMOUSE_PRESSED_DOWN:
rmb = true;
break;
case EMIE_LMOUSE_LEFT_UP:
lmb = false;
break;
case EMIE_RMOUSE_LEFT_UP:
rmb = false;
break;
}
}
return false;
}
virtual bool IsKeyDown(EKEY_CODE keyCode) const
{
return KeyIsDown[keyCode];
}
bool rmbPressed()
{
return rmb;
}
bool lmbPressed()
{
return lmb;
}
bool mMouvedDown()
{
return mdown;
}
bool mMouvedUp()
{
return mup;
}
private:
bool KeyIsDown[KEY_KEY_CODES_COUNT]; // touches clavier enfoncées
bool rmb, lmb;//bouton de la souris enfoncé
Universe *univers;
int mouseX, mouseY;//utilistaires pour mup et mdown
bool mup, mdown;
int prendreencompte;
};
Thanks !