Page 1 of 1

Event Processing With External Window ID

Posted: Wed Apr 01, 2015 3:45 am
by sigvatr
Hi there, I am creating my Irrlicht context with custom creation parameters as here:

Code: Select all

 
irr::SIrrlichtCreationParameters irr_params;
irr_params.EventReceiver = NULL;
irr_params.WindowId = reinterpret_cast<void*>( window_handle );
 
All of my window events are handled manually and process things such as window events, keyboard handling and so forth.

I found that (specifically on the win32 build, but perhaps also in other operating systems) the device run() command is still processing window events as here:

(CIrrDeviceWin32.cpp)

Code: Select all

 
bool CIrrDeviceWin32::run()
{
    os::Timer::tick();
 
    static_cast<CCursorControl*>(CursorControl)->update();
 
    handleSystemMessages();
 
    if (!Close)
        resizeIfNecessary();
 
    if(!Close && JoyControl)
        JoyControl->pollJoysticks();
 
    _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
    return !Close;
}
 
It appears that system messages and events are still being processed by Irrlicht, despite the fact that I have specified it not to do so.

I discovered this problem when keyboard events were being misinterpreted or lost in some circumstances. If I do not execute the device's run() function every frame in my game/engine, there are no problems.

Basically, Irrlicht's window message and event handling functionality is currently flawed and needs to be fixed.

I have temporarily fixed my problem by commenting over the conflicting functions in the run() function as so:

(CIrrDeviceWin32.cpp)

Code: Select all

 
bool CIrrDeviceWin32::run()
bool CIrrDeviceWin32::run()
{
    os::Timer::tick();
 
//static_cast<CCursorControl*>(CursorControl)->update();
 
//handleSystemMessages();
 
//if (!Close)
//  resizeIfNecessary();
 
//if(!Close && JoyControl)
//  JoyControl->pollJoysticks();
 
    _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
    return !Close;
}
 
I am not sure if this is going to cause unforeseen problems in the future, but for the moment it seems to be working for me with no side effects.

Thank you for your review and consideration.

Re: Event Processing With External Window ID

Posted: Wed Apr 01, 2015 4:55 am
by thanhle
Apart from: params.EventReceiver = 0;

I think there is another option in the parameter.

params.IgnoreInput = true;

Regards,
thanh

Re: Event Processing With External Window ID

Posted: Wed Apr 01, 2015 7:27 am
by sigvatr
thanhle wrote:Apart from: params.EventReceiver = 0;

I think there is another option in the parameter.

params.IgnoreInput = true;

Regards,
thanh
I already have that parameter enabled.

Re: Event Processing With External Window ID

Posted: Wed Apr 01, 2015 8:53 am
by CuteAlien
The easier workaround in this case is probably not to call IrrlichtDevice::run(). Instead just update the timer manually (you can access it through IrrlichtDevic::getTimer()).

EventReceiver is only about user-event-receiver. That is about Irrlicht events which are not the same as system events. So those things are a little related, but should be seen as 2 different things.

Interpreting the setting of a WindowId as a hint that system-messages should not be handled by Irrlicht might make sense. At least does look like that to me on first view, but unfortunately I've not worked much with such cases. I'm pretty certain the passing and handling of system events can still be improved - I run into a few problems there already. But we need a few more test-cases here than just the Win32Window example before reworking this. I haven't even tried to work with Qt+Irrlicht or wxWidget+Irrlicht or similar cases. If someone shows up with deep knowledge about those things (and preferably also experience with Linux and/or OSX) I'd be glad to consider his patches (or even add him to the team).

Re: Event Processing With External Window ID

Posted: Wed Apr 01, 2015 11:53 am
by thanhle
Ah ha,
Now I know why I don't have that issue with Qt and timer.

I used to work with .net windows form. I created my on EventReceiver to handle event. Event is manually construct though.

Regards
thanh

Re: Event Processing With External Window ID

Posted: Wed Apr 01, 2015 1:54 pm
by sigvatr
So all I need to do to avoid this problem is to get the Irrlicht device's timer and tick it each frame?

Re: Event Processing With External Window ID

Posted: Wed Apr 01, 2015 1:55 pm
by CuteAlien
Yeah, don't call run() and tick timer yourself. And even that only necessary if you need animations.

Re: Event Processing With External Window ID

Posted: Wed Apr 01, 2015 3:08 pm
by sigvatr
It works, cheers.

Do you guys plan on applying some kind of patch?

Re: Event Processing With External Window ID

Posted: Wed Apr 01, 2015 3:12 pm
by CuteAlien
No plans there at the moment.