If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
hammeraxe
Posts: 9 Joined: Sun Nov 04, 2007 4:51 pm
Location: LV
Post
by hammeraxe » Wed Mar 05, 2008 7:16 pm
so for some reason my event receiver doesnt work....partly
the keyboard works, but the mouse buttons are always up...whats wrong?
Code: Select all
class MyEventReceiver : public IEventReceiver
{
public:
bool OnEvent(const SEvent& event)
{
if(event.EventType == irr::EET_KEY_INPUT_EVENT)
{
keys[event.KeyInput.Key] = event.KeyInput.PressedDown;
return true;
}
if(event.EventType == irr::EET_MOUSE_INPUT_EVENT)
{
mouse[event.MouseInput.Event]=event.MouseInput.Event;
return false;
}
return false;
}
};
then i initialise the arrays
Code: Select all
for(int q=0; q<irr::KEY_KEY_CODES_COUNT; q++) keys[q] = false;
for(int q=0; q<EMIE_COUNT; q++) mouse[q]=false;
and check for events in my while cycle
Code: Select all
if(mouse[EMIE_LMOUSE_PRESSED_DOWN ]){cout<<"L";}
if(mouse[EMIE_LMOUSE_LEFT_UP ]){cout<<"U";}
shogun
Posts: 162 Joined: Wed Sep 05, 2007 11:02 am
Location: inside
Post
by shogun » Wed Mar 05, 2008 7:27 pm
Code: Select all
mouse[event.MouseInput.Event]=event.MouseInput.Event;
That line looks strange ... shouldn't it be "= true"?
hammeraxe
Posts: 9 Joined: Sun Nov 04, 2007 4:51 pm
Location: LV
Post
by hammeraxe » Wed Mar 05, 2008 7:42 pm
well when you do this
Code: Select all
mouse[event.MouseInput.Event]=true;
you can press the mouse button once and it always remains true as if the button was kept pressed forever
dlangdev
Posts: 1324 Joined: Tue Aug 07, 2007 7:28 pm
Location: Beaverton OR
Contact:
Post
by dlangdev » Wed Mar 05, 2008 7:50 pm
Something is strange in that scope, can you tell me what's wrong with that?
Code: Select all
if(event.EventType == irr::EET_MOUSE_INPUT_EVENT)
{
mouse[event.MouseInput.Event]=event.MouseInput.Event;
return false;
}
Sylence
Posts: 725 Joined: Sat Mar 03, 2007 9:01 pm
Location: Germany
Contact:
Post
by Sylence » Wed Mar 05, 2008 8:07 pm
Maybe it should be return true; !?
Software documentation is like sex. If it's good you want more. If it's bad it's better than nothing.
Halifax
Posts: 1424 Joined: Sun Apr 29, 2007 10:40 pm
Location: $9D95
Post
by Halifax » Wed Mar 05, 2008 8:11 pm
hammeraxe wrote: well when you do this
Code: Select all
mouse[event.MouseInput.Event]=true;
you can press the mouse button once and it always remains true as if the button was kept pressed forever
Uhh...yeah about that. Your going to have to manage that yourself by writing to the variable when a change occurs. So you must maintain that.
If your having trouble, then check out the event receivers around the forums built for beginners:
MastEventReceiver
CIrrEventReceiver
TheQuestion = 2B || !2B
dlangdev
Posts: 1324 Joined: Tue Aug 07, 2007 7:28 pm
Location: Beaverton OR
Contact:
Post
by dlangdev » Wed Mar 05, 2008 8:14 pm
I wanna see more replies...
Please state your answer accurately with strong conviction. Like your reputation depends on it.
I mean if you surely know the answer, step-up and let the world know.
Halifax
Posts: 1424 Joined: Sun Apr 29, 2007 10:40 pm
Location: $9D95
Post
by Halifax » Wed Mar 05, 2008 8:27 pm
dlangdev wrote: I wanna see more replies...
Please state your answer accurately with strong conviction. Like your reputation depends on it.
I mean if you surely know the answer, step-up and let the world know.
I wrote the CIrrEventReceiver...I believe that is enough of an answer. And if he can't pool through the CIrrEventReceiver/MastEventReceiver source code and find what he needs, then whatever. It only took me 2 seconds to find the answer in the MastEventReceiver source which is posted in the topic.
Here is a small tidbit:
Code: Select all
//Left Mouse Button Rleased
if (event.MouseInput.Event == EMIE_LMOUSE_LEFT_UP)
{
//
if (mouseButtonState[0] != UP)
{
mouseButtonState[0] = RELEASED;
}
}
//Middle Mouse Button Pressed
if (event.MouseInput.Event == EMIE_MMOUSE_PRESSED_DOWN)
{
//
if (mouseButtonState[1] == UP || mouseButtonState[1] == RELEASED)
{
mouseButtonState[1] = PRESSED;
}
else
{
mouseButtonState[1] = DOWN;
}
}
TheQuestion = 2B || !2B
hammeraxe
Posts: 9 Joined: Sun Nov 04, 2007 4:51 pm
Location: LV
Post
by hammeraxe » Thu Mar 06, 2008 4:06 pm
thanks for the replies guys....