Is there any way to simulate a button being depressed?

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
Anteater

Is there any way to simulate a button being depressed?

Post by Anteater »

Is there any way to simulate a button being pressed/released inside of Irrlicht? E.G. "Trick" the computer into thinking the W key was released.
don_Pedro
Posts: 84
Joined: Fri Jun 10, 2005 1:34 pm
Location: Poland
Contact:

Post by don_Pedro »

There's a thing in IGUIEnvironment that probably should do that:
IGUIEnvironment::postEventFromUser ( SEvent event )
Fill SEvent structure with what you want and pass to this function, I just don't understand what would you need that for :) .
meme

Post by meme »

well maybe he wants like an onscreen typewriter or something
Midnight
Posts: 1772
Joined: Fri Jul 02, 2004 2:37 pm
Location: Wonderland

Post by Midnight »

yeah that makes sense... type key on keyboard... on screen you see a hand click a key and release even if you don't... not much purpose in that example since having the hand remain just like yours would be more realistic but I'm sure he has a reason and maybe if you were to ask he might explain.
don_Pedro
Posts: 84
Joined: Fri Jun 10, 2005 1:34 pm
Location: Poland
Contact:

Post by don_Pedro »

Yes, it was question of course, but without question mark :roll: . Anyway your explanations are good enough :) .
Anteater

Post by Anteater »

The reason for this is complicated. Anyway, here's the problem:
At one point in my game, when the FPS cam walks up to a node, the camera switches to the "Cutscene Camera" with an animator attached to it. After the cutscene is over, it switches back to the regular FPS camera, but for some reason, it seems to think that the arrow keys were never released, even though they were. Therefor, if the computer thinks that the key was pressed/released on the first frame of interaction after the cutscene, it SHOULD fix the poblem.
Anteater

Post by Anteater »

The reason for this is complicated. Anyway, here's the problem:
At one point in my game, when the FPS cam walks up to a node, the camera switches to the "Cutscene Camera" with an animator attached to it. After the cutscene is over, it switches back to the regular FPS camera, but for some reason, it seems to think that the arrow keys were never released, even though they were. Therefor, if the computer thinks that the key was pressed/released on the first frame of interaction after the cutscene, it SHOULD fix the poblem.
Anteater

HELP!!

Post by Anteater »

Ok, how exactly would i use the postEventFromUser(SEvent event) thing?
I'm trying to make it think the W key was pressed. By the way, sorry for the double-posting with my last post; it was a server error.
don_Pedro
Posts: 84
Joined: Fri Jun 10, 2005 1:34 pm
Location: Poland
Contact:

Post by don_Pedro »

For example

Code: Select all

SEvent event;
event.EventType = EET_KEY_INPUT_EVENT;
event.KeyInput.PressedDown = false;
event.KeyInput.Key = KEY_KEY_W;
GUI->postEventFromUser(event);
should cause key W left up.
don_Pedro
Posts: 84
Joined: Fri Jun 10, 2005 1:34 pm
Location: Poland
Contact:

Post by don_Pedro »

But anyway you should check once more if you haven't just a bug in your program, cuz this way is bad even if it will work.
Midnight
Posts: 1772
Joined: Fri Jul 02, 2004 2:37 pm
Location: Wonderland

Post by Midnight »

seems to me its a bug... from his description it's like the techdemo only with demo before the camera fly around... there must be a way to write it were it doesn't think the key is pressed maybe not having the cutscene start untill after its released??
Anteater

Post by Anteater »

If I waited until the player released the key, the camera could walk off the side of the world.
Post Reply