class blablabla
{
public:
blablabla() :
joystic_left_forward_down(true)
joystic_left_forward_up(false)
{
}
virtual bool blablabla::OnEvent(const SEvent& event)
{
if(event.EventType == irr::EET_KEY_INPUT_EVENT)
{
if(event.KeyInput.Key == irr::KEY_KEY_A)
{
player->forward(event.KeyInput.PressedDown);
}
}
if(event.EventType == irr::EET_JOYSTICK_INPUT_EVENT)
{
if(event.JoystickEvent.Axis[1] < -5000)
{
// single emit
if(joystic_left_forward_down)
{
irr::SEvent event;
event.EventType = EET_KEY_INPUT_EVENT;
event.KeyInput.Key = irr::KEY_KEY_A;
event.KeyInput.PressedDown = true;
device->postEventFromUser(event);
joystic_left_forward_up = true;
joystic_left_forward_down = false;
}
}
else
{
// single emit
if(joystic_left_forward_up)
{
irr::SEvent event;
event.EventType = EET_KEY_INPUT_EVENT;
event.KeyInput.Key = irr::KEY_KEY_A;
event.KeyInput.PressedDown = false;
device->postEventFromUser(event);
joystic_left_forward_up = false;
joystic_left_forward_down = true;
}
}
}
}
private:
bool joystic_left_forward_up;
bool joystic_left_forward_down;
};