CLICKING ON MOUSE GENERATES KEYBOARD EVENTS? UPDATED!

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.
Post Reply
Georgian
Posts: 60
Joined: Sat Mar 31, 2007 12:55 pm

CLICKING ON MOUSE GENERATES KEYBOARD EVENTS? UPDATED!

Post by Georgian »

so me again.
now i think i found a bug.
when i click the mouse Event.KEYINPUT.CHAR is " Char 950 'ζ' wchar_t
"
but Event.keyinput.Key is KEY_KEY_U

and with keyboard pressed on U
char is 'U' and Key is KEY_KEY_U
Last edited by Georgian on Fri Jul 13, 2007 2:59 pm, edited 3 times in total.
using Visual Studio 2003 , I use 3D Max 7, I love irrlicht its a really good and easy engine
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Your code :idea: :!:
omar shaaban
Posts: 616
Joined: Wed Nov 01, 2006 6:26 pm
Location: Cairo,Egypt
Contact:

Re: CLICKING ON MOUSE GENERATES KEYBOARD EVENTS? UPDATED!

Post by omar shaaban »

Georgian wrote:so me again.
now i think i found a bug.
when i click the mouse Event.KEYINPUT.CHAR is " Char 950 'ζ' wchar_t
"
but Event.keyinput.Key is KEY_KEY_U

and with keyboard pressed on U
char is 'U' and Key is KEY_KEY_U
well can u put the event code first!? as hybird said! i dont understand u really!!
Rytz
Posts: 249
Joined: Wed Oct 25, 2006 6:05 am
Location: IL, USA
Contact:

Re: CLICKING ON MOUSE GENERATES KEYBOARD EVENTS? UPDATED!

Post by Rytz »

Georgian wrote:so me again.
now i think i found a bug.
when i click the mouse Event.KEYINPUT.CHAR is " Char 950 'ζ' wchar_t
"
but Event.keyinput.Key is KEY_KEY_U

and with keyboard pressed on U
char is 'U' and Key is KEY_KEY_U
Just curious... why are you reading keyboard inputs when testing for mouse events?

The above sounds like a undefined behavior. I'll have to try this for myself and post my results.
Image
Georgian
Posts: 60
Joined: Sat Mar 31, 2007 12:55 pm

Post by Georgian »

oh the code.. well maybe because its tooo long? :D
the main.cpp file is well about 4000Lines. and the event receiver part about 1000 lines.

and i test for keys when clicking mouse because I use both mouse and keyboard together.

and well my code is very messed its my first serious project im only 17 and well its the first program in which i have 10000+ lines
and my event receiver is very very crooked i have several GAME MODES (about 10)
and i have like this
if (event.EventType==irr::EET_KEY_INPUT_EVENT||event.EventType==irr::EET_MOUSE_INPUT_EVENT)
{
if(GAMEMODE==PLAY)
{
switch(Event.keyInput.KEY)
{}
switch(event.MouseEvent.Event)
{}

}
//than
if(GAMEMODE==GuessPicture)
{
if(cursorpos.x>12&&cursorpos.x<100&&cursorpos.y>214&&cursorpos.y<555)
{}
}
if(GAMEMODE==WriteWords)
{
if(event.keyInput.KEY==KEY_KEY_X&&WordTowrite[POS]=='X')
{
}

}

}

as i said its my first large program and well my skills arnt too goood
using Visual Studio 2003 , I use 3D Max 7, I love irrlicht its a really good and easy engine
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

when i click the mouse Event.KEYINPUT.CHAR is " Char 950
If event.EventType is not EET_KEY_INPUT_EVENT, you should not access any member of event.KeyInput. The reason is that the SEvent structure is implemented as a union. The event.KeyInput data is stored in the same location as the event.MouseInput data.

Travis
Georgian
Posts: 60
Joined: Sat Mar 31, 2007 12:55 pm

Post by Georgian »

ok. thanks vitek i got it now :) ill have to add everywhere if(EVENTTYPE==MOUSE) and if(EVENTTYPE==KEY)

:D well i have a lot of IF s to write. :shock: but not now. ill go repair my car or at least try.
using Visual Studio 2003 , I use 3D Max 7, I love irrlicht its a really good and easy engine
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

If you have 1000 lines of code in your event receiver, you might want to split it up just a little. It looks like you have a primitive game state system already. You might want to split each state out into its own functions or classes. The overall number of lines will obviously increase, but it will reduce the complexity of the code significantly.

There was discussion of a state system a while back that you might want to take a look at. You can find it here.

Travis
Post Reply