Event Processing With External Window ID

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
sigvatr
Posts: 9
Joined: Sat Aug 10, 2013 8:54 pm
Location: Brisbane, Australia
Contact:

Event Processing With External Window ID

Post 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.
thanhle
Posts: 325
Joined: Wed Jun 12, 2013 8:09 am

Re: Event Processing With External Window ID

Post by thanhle »

Apart from: params.EventReceiver = 0;

I think there is another option in the parameter.

params.IgnoreInput = true;

Regards,
thanh
sigvatr
Posts: 9
Joined: Sat Aug 10, 2013 8:54 pm
Location: Brisbane, Australia
Contact:

Re: Event Processing With External Window ID

Post 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.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Event Processing With External Window ID

Post 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).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
thanhle
Posts: 325
Joined: Wed Jun 12, 2013 8:09 am

Re: Event Processing With External Window ID

Post 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
sigvatr
Posts: 9
Joined: Sat Aug 10, 2013 8:54 pm
Location: Brisbane, Australia
Contact:

Re: Event Processing With External Window ID

Post 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?
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Event Processing With External Window ID

Post by CuteAlien »

Yeah, don't call run() and tick timer yourself. And even that only necessary if you need animations.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
sigvatr
Posts: 9
Joined: Sat Aug 10, 2013 8:54 pm
Location: Brisbane, Australia
Contact:

Re: Event Processing With External Window ID

Post by sigvatr »

It works, cheers.

Do you guys plan on applying some kind of patch?
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Event Processing With External Window ID

Post by CuteAlien »

No plans there at the moment.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply