Page 1 of 1

whats wrong with my event receiver?

Posted: Wed Mar 05, 2008 7:16 pm
by hammeraxe
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";}

Re: whats wrong with my event receiver?

Posted: Wed Mar 05, 2008 7:27 pm
by shogun

Code: Select all

        mouse[event.MouseInput.Event]=event.MouseInput.Event;
That line looks strange ... shouldn't it be "= true"?

Posted: Wed Mar 05, 2008 7:42 pm
by hammeraxe
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

Posted: Wed Mar 05, 2008 7:50 pm
by dlangdev
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; 
     } 


Posted: Wed Mar 05, 2008 8:07 pm
by Sylence
Maybe it should be return true; !?

Posted: Wed Mar 05, 2008 8:11 pm
by Halifax
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

Posted: Wed Mar 05, 2008 8:14 pm
by dlangdev
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.

Posted: Wed Mar 05, 2008 8:27 pm
by Halifax
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; 
               } 
            }

Posted: Thu Mar 06, 2008 4:06 pm
by hammeraxe
thanks for the replies guys.... :D