Mouse events in keymaps?

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
Ivo Georgiev
Posts: 27
Joined: Wed Dec 12, 2007 7:05 pm

Mouse events in keymaps?

Post by Ivo Georgiev »

Can I check if mouse right button is pressed instead of space is pressed in a keymap.That is a part of a keymap:

Code: Select all

 keyMap[8].Action = EKA_JUMP_UP;
      keyMap[8].KeyCode = KEY_SPACE ;
And I wanna check if mouse right button is pressed, instead of KEY_SPACE pressed.I've tryed this way:

Code: Select all

keyMap[8].KeyCode = EMIE_RMOUSE_LEFT_UP;
And also this way:

Code: Select all

keyMap[8].MouseEvent = EMIE_LMOUSE_LEFT_UP;
But neither of them worked...HELP, PLEASE
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

No, it only handles key events. I agree that's not ideal. You'll have to write a custom event receiver and handle mouse events explicitly. See examples 4, 5, 9, 11, 12, and the Demo example.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Ivo Georgiev
Posts: 27
Joined: Wed Dec 12, 2007 7:05 pm

Post by Ivo Georgiev »

Okay, but is there a way to call jump action?
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

I'm not sure, because I didn't try this, but there are this key codes:
KEY_LBUTTON
KEY_RBUTTON
KEY_MBUTTON
aren't they for the mouse buttons ???


EDIT: ok, I tried it and it doesn't work... :cry:
but what are these key codes for ???
That's strange, because in keycodes.h they are defined for the mouse buttons:
00013 KEY_LBUTTON = 0x01, // Left mouse button
00014 KEY_RBUTTON = 0x02, // Right mouse button
00015 KEY_CANCEL = 0x03, // Control-break processing
00016 KEY_MBUTTON = 0x04, // Middle mouse button (three-button mouse)
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Key and mouse events are handled differently (for one thing, mouse events have a position). Note that CCameraFPSSceneNode::OnEvent() only handles EET_KEY_INPUT_EVENT events.

I suppose if you're dead set on using CCameraFPSSceneNode() then you could create your own event handler, translate mouse events into appropriate key events, and then pass them on by calling myFPSCameraSceneNode->OnEvent(translatedEvent).
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Ivo Georgiev
Posts: 27
Joined: Wed Dec 12, 2007 7:05 pm

Post by Ivo Georgiev »

My camera instance is "camera"
The code I've tryed for calling the "space" button is

Code: Select all

camera->OnEvent(KEY_SPACE);
But I am a noob and I am getting something wrong again :oops:
shogun
Posts: 162
Joined: Wed Sep 05, 2007 11:02 am
Location: inside

Post by shogun »

Then you should do something right.
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

Ivo Georgiev wrote:My camera instance is "camera"
The code I've tryed for calling the "space" button is

Code: Select all

camera->OnEvent(KEY_SPACE);
But I am a noob and I am getting something wrong again :oops:
a short look at the api discovers that OnEvent doesn't take a key code like you did, but an event (SEvent) !!! ;)
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Come on chaps, play nice.

Code: Select all

SEvent keyEvent= {0};
keyEvent.EventType = EET_KEY_INPUT_EVENT;
keyEvent.KeyInput.Key = KEY_SPACE;
camera->OnEvent(keyEvent);
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Post Reply