irrlicht

Irrlicht : can't call onEvent


i'm new with irrlicht and i was trying to implement key events. I followed the irrlicht tutoriel on their website but it doesn't work.

Here's the code :

class MyEventReceiver : public irr::IEventReceiver
{
public:
  MyEventReceiver()
  {
    for (irr::u32 i = 0; i < irr::KEY_KEY_CODES_COUNT; ++i)
      KeyIsDown[i] = false;
  }

virtual bool OnEvent(const irr::SEvent& event)
  {
    std::cout << event.EventType << std::endl;
    if (event.EventType == irr::EET_KEY_INPUT_EVENT)
      KeyIsDown[event.KeyInput.Key] = event.KeyInput.PressedDown;
    return (false);
  }

  virtual bool IsKeyDown(irr::EKEY_CODE keyCode) const
  {
    return (KeyIsDown[keyCode]);
  }

private:
  bool KeyIsDown[irr::KEY_KEY_CODES_COUNT];
};

Normally if i press a button the onEvent should be called but i can press any button i want it never calls this function. Of course i created a MyEventReceiver in the main.

Can someone who knows irrlicht help me please ?


Solution

  • I got the same problem, it's because you created it but you don't give it when you create your device: like this, IrrlichtDevice* device = createDevice(driverType, core::dimension2d<u32>(640, 480), 16, false, false, false, --->&receiver<---);