IrrEventManager v1.8.4 FINAL!

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
kh_
Posts: 78
Joined: Fri May 19, 2006 4:29 pm

IrrEventManager v1.8.4 FINAL!

Post by kh_ »

IrrEventManager is a event system to allow using callbacks to handle irrlicht events including GUI events.(No need to create your own event receiver).
You can also use traditional function calls like KeyDown() for key and mouse events.

irrEventManager has only been tested on the irrWin32Device with OpenGL and DX9.
irrEventManager Now Does require recompiling irrlicht!
Use at your own risk.please report any bugs or ask for help here.

zlib license.

1/2019
The pcloud account got deleted,got a new link here.
I haven't used this in a while, I believe this is the final zipped project:

https://my.pcloud.com/publink/show?code ... rXLBbRmHny


LATEST CHANGES:
2-24-2018

This should be the final release. Next version (if any) will be fully integrated into irrlicht

Renamed to "irrEventManager184_FINAL" since it has been last tested with Irrlcht 1.8.4 now (should still work with SVN)

ADDED visual studio (2012) files.

changed:
in IGUIElement.h, changed getReceiverCount() to be more accurate

Remember that you must edit the original IGUIElement.h yourself.(see reference.txt)


these EventManager methods now return wchar_t*

/**get name from type-- for debugging --*/
virtual const wchar_t* getNameFromGuiEventType(gui::EGUI_EVENT_TYPE)=0;


/**get name from last event receiver to return true*/
virtual const wchar_t* getNameFromLastCalledGuiEvent()=0;

/**should return name of eventtype of last called gui receiver that returned true */
virtual const wchar_t* getNameFromLastHandledGuiEvent()=0;


added To IEventManager:

/**get the receiver array so you can add remove etc. yourself*/
virtual core::array<IEventRecEx*>& getReceivers()=0;



changed the examples to use stringw instead of wchar_t[] and swprintf() ect.


see reference.txt for more details.


download



make sure you have the latest version


2-20-2018
This is the latest copy, working with OpenGL. Made a few minor improvements.
version 1.9.2


There is going to be a delay with the visual studio projects.




Bugfix!
I got it working in mingw+DX now.
It appears the crashing was due to my bad string handling.
It worked fine in OGL but barfs in DX. I was passing char* to stringw+ .
In example 1, look around line 569 >>> line 579

Code: Select all

 
          fontY += fontSpace;   ///replace code after here          
 
          stringw stmp(L"GUI last event called...");
 
            stmp+=em->getNameFromLastCalledGuiEvent(); ///returns c8*, seems to work
            font->draw(stmp.c_str(),rec,fontColor);
 
 
            fontY += fontSpace;
 
            stmp = L"GUI last Handled Gui event...";
            stmp+=em->getNameFromLastHandledGuiEvent();
            font->draw(stmp.c_str(),rec,fontColor);
 
 
change to

Code: Select all

 
 
            static stringw wstring;
            static stringc stmp;
 
            stmp = "GUI last event called... ";
            stmp += em->getNameFromLastCalledGuiEvent();
 
            core::multibyteToWString(wstring, stmp.c_str());
            font->draw(wstring.c_str(),rec,fontColor);
 
 
            fontY += fontSpace;
 
            stmp = "GUI last Handled Gui event...";
            stmp += em->getNameFromLastCalledGuiEvent();
            core::multibyteToWString(wstring, stmp.c_str());
 
            font->draw(wstring.c_str(),rec,fontColor);
 
 

As you can see,I guess I should have used core::multibyteToWString(); (not a unicode fan)
In the next release,I'll change the function to return wchar_t*.

You'll have to look at the other tests to see if they have the same bug.
I should have the Visual Studio projects done soon, so I'll upload the fixes then.




2-19-2018
Have a small fix.
there was a function added to the EventManager at the last minute.It's not even in the docs.
It should have returned a reference:

core::array<IEventRecEx*>& getReceivers()

this has the 2 files needed to fix it (or you can easily do it yourself).

download:



The issues I was having appear to be with my IrrlichtDX dll.
Everything is working fine in OpenGl .
I'm uploading the latest just in case.

2-18-2018

download:





*********************************************************************
LATEST CHANGES:
2-11-2018
New version 1.9

BIG CHANGES!
Returned back to DLL with interfaces.
I finally bit the bullet and intgrated it into the Irrlicht engine.
This removed about %50 of the code.The manager now only stores receivers for non gui events .
All Gui event receivers are stored within the gui element itself.

The only changes are to IGuiElement.h.
I'm including my modified copy of IGuiElement.h in the main folder and explain how to change it in reference.txt.
You will need to recompile Irrlicht now.

Note that I add a 'd' to the end of my Irrlicht Debug dll name >> Irrlichtd.dll

Changed handling of IGUIContextMenu. Manager NO LONGER sets the command id .You must do this in your code, with same command id to both the contextmenu item and the receiver to handle it.See Demo 2.

SEventRecEx has major changes. Constructors are not backward compatible.

I came up with a system to check if the gui is active or not.

Added methods to get last gui event sent and last gui event processed by manager as string and a "guiActive"flag.

Added support for joysticks. This is experimental. I only have 1 joystick to test it with.

(note: there was a problem with missing include folder, fixed now.

P.S. not sure if I gave credit,but the joystick demo is borrowed from the Irrlicht example.

2-4-17
1.84c


One big change is there is no longer an IEventManager interface, just use CEventManger now.
should have previous bugs fixed
<removed download new version>


2-3-17
new version ,1 big change,several smaller ones
see the reference file for changes
changed version to 184b

<removed download new version>


2-2-2017

<removed download new version>

1-31-2017
New Version!!

version 1.84
I see a few people on the forum looking for something like this,so I'm rushing this out now.


This has been changed to a static library, You will need to compile it. No more custom bs. Removed a ton of junk code and files.
I have included my CodeBlocks projects (set for 32 bit).These will require a global variable for irrlicht $(#irr).If you don't have one it will ask when you open a project. I also add global include and lib for irrlicht.

I'll try to come up with better documentation over the next few days.


Use at your own risk!
Yesterday I uploaded it with a minor flaw, make sure yours starts with irr.
2-1-17
Just uploaded with docs and another very minor correction (see bottom of docs)
THis is in a zip file now not 7z
<removed download new version>


hope you find it useful, feel free to mirror it.
Make sure you document any changes if you mod it and re-distribute it.



12-15-09
version 16a
added the multiple mouse clicks
added VC8 projects

10-29-09
New version 1.6 for Irrlicht 1.6
some of the changes:

On the suggestion of "Ulf" I have changed the key and mse click() functions.
Now if you call these functions they will only return true 1 time.

Totally reworked test2.

experimental:
added:
IEventManager::mouseMoved();
IEventManager::getMouseMultiClick();

experimental:
With a custom build of irrlicht, it is now possible to get left and right alt key down as well as left and right control and shift.
Last edited by kh_ on Sat Jan 12, 2019 1:40 am, edited 119 times in total.
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Wow, theres even an Irrlicht Calling Convention, nice. The gui event stuff is definately useful.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
kh_
Posts: 78
Joined: Fri May 19, 2006 4:29 pm

Post by kh_ »

Thanks, just put a new version up (minor changes). should have an irr1.5 version in a day or 2.
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

BlindSide wrote:Wow, theres even an Irrlicht Calling Convention, nice. The gui event stuff is definately useful.
Why does it needs an Irrlicht calling convention?
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
kh_
Posts: 78
Joined: Fri May 19, 2006 4:29 pm

Post by kh_ »

MasterGod wrote: Why does it needs an Irrlicht calling convention?
[EDIT] calling convention isn't needed anymore
Last edited by kh_ on Fri Oct 30, 2009 12:29 am, edited 1 time in total.
kh_
Posts: 78
Joined: Fri May 19, 2006 4:29 pm

Post by kh_ »

new version uploaded
kh_
Posts: 78
Joined: Fri May 19, 2006 4:29 pm

Post by kh_ »

new version for irrlicht 1.5 uploaded
FuzzYspo0N
Posts: 914
Joined: Fri Aug 03, 2007 12:43 pm
Location: South Africa
Contact:

Post by FuzzYspo0N »

Hey man, thanks for the effort for the community, this is a great resource
kh_
Posts: 78
Joined: Fri May 19, 2006 4:29 pm

Post by kh_ »

Thanks, wish I had more time to work on it.
JFT
Posts: 11
Joined: Mon Feb 02, 2009 5:32 pm

Post by JFT »

Hi,
Thanks for your nice Eventmanager.
Is there a function like:
evm->Mousemoved();
or something like that?

Thanks again!

JFT

Sorry for bad english
kh_
Posts: 78
Joined: Fri May 19, 2006 4:29 pm

Post by kh_ »

JFT wrote: Is there a function like:
evm->Mousemoved();
or something like that?
Thanks JFT,good idea. I'll try to add it asap. Until then you should be able to add a receiver to the mouse event with evm->getMouseEvent()->addReceiver(yourReceiver)
then test for a mouse_moved event in the receiver.
kh_
Posts: 78
Joined: Fri May 19, 2006 4:29 pm

Post by kh_ »

OK,I made a quick fix for it. I haven't had time to test it yet,so let me know if there's any problem.
Last edited by kh_ on Thu Feb 02, 2017 1:41 am, edited 1 time in total.
Adler1337
Posts: 471
Joined: Sat Aug 09, 2008 6:10 pm
Location: In your base.

Post by Adler1337 »

Looks cool, but i believe there is something already like this. Its called MastEventReceiver.
multum in parvo
kh_
Posts: 78
Joined: Fri May 19, 2006 4:29 pm

Post by kh_ »

Adler1337 wrote:Looks cool, but i believe there is something already like this. Its called MastEventReceiver.
F.Y.I. This beast is very different from the Mast Receiver, which I've known about long before you joined this forum.
This is clearly not for you. :roll:
Last edited by kh_ on Wed Jun 17, 2009 2:47 am, edited 1 time in total.
Ulf
Posts: 281
Joined: Mon Jun 15, 2009 8:53 am
Location: Australia

questions

Post by Ulf »

I've just started looking at this code so please forgive me if don't have a broad view.

What is the purpose of using bits in this case?

Is this:
#ifdef _IRREVENTMANAGER_USEBITS
Keys[event.KeyInput.Key] |= 1;

faster than this?:
#endif
chr = event.KeyInput.Char;

I don't see the purpose unless there are many math operations. Not just when you are setting a value. Or am I wrong?

I don't understand the delay. Why return the char when dt==1 and when dt>delay? (code below). Seems strange!

wchar_t CEventManager::keyChar()
{
if (chr)
{
if (dt <= delay)
dt++;
if (dt==1 || dt > delay)
return chr;
}
return 0;
}

//
When not using bits, what is all this KeysOld and KeysOld2? Why have 3 versions? Keeping the last 3 pressed? Or what is going on? (below)

bool CEventManager::keyClick(EKEY_CODE key)
{
if (Keys[key])
{
if (!KeysOld[key])
{
return KeysOld2[key] = KeysOld[key] = true;
}

}
else
KeysOld[key] = false;

return KeysOld2[key];
}

Also, if the using bits does really increase the speed which it doesn't look like it will!, it would be nicer if it was more readable with constants and defines, rather than seeing this:

if (Keys[key] & 1<<0 )//keys[key])
{
if (! ( Keys[key] & (1<<1) ) )//keysOld[key])
{
//Keys[key] |= (1<<2); // 00100
// Keys[key] |= (1<<1); // 00010
Keys[key] |= 0x06;//(3<<1); // 011 == 3
return true;
}

}
else
Keys[key] &= 0x0D ;//~(1<<1);// keysOld[key] = false; ~0010 = 1101 =0x0D

return (Keys[key] & 0x04);//(1<<2)); // = 0100 = 0x04

Regardless, it looks like you have done a lot of work and taken many things into consideration. I hope you keep improving it. I am starting my own event manager for a game engine. I'll post it one of these days..just started using irrlicht..
Post Reply