overriding example application function (events for keys)

hedphelym

20-12-2010 11:24:51

I'm writing a physx example application,
I've based it on the "CameraTrack" sample.

This one uses the "Demo Example application".

I have some keyboard shortcuts that I need.

Let's say pressing P does something.

Obviously I won't add it to the "example application", I want the code
for this to be in my project.

protected virtual void HandleInput(FrameEvent evt)
{
//here's the example application stuff
}


I need to override this and put my code in my application..
How do I do this?..

smiley80

20-12-2010 11:47:22

protected override void HandleInput(FrameEvent evt)
{
base.HandleInput(evt);
if (this.inputKeyboard.IsKeyDown(KeyCode.KC_P) && (this.toggleDelay < 0f))
{
// do stuff
this.toggleDelay = 1;
}
}

Or subscribe to the inputKeyboard.KeyPressed event.

hedphelym

20-12-2010 11:56:56

thank you for the reply,
when I enter the code you posted, still nothing happens.
is there a chance that I could have missed something basic here?..

is there a chance you could help with the second example you mention too?

Or subscribe to the inputKeyboard.KeyPressed event.

smiley80

20-12-2010 12:18:02

public override bool UseBufferedInput
{
get { return true; }
}
public override void CreateInput()
{
base.CreateInput();
this.inputKeyboard.KeyPressed += new KeyListener.KeyPressedHandler(inputKeyboard_KeyPressed);
}
bool inputKeyboard_KeyPressed(KeyEvent arg)
{
if (arg.key == KeyCode.KC_P)
{
//do stuff
}

return true;
}

Both work for me in the otherwise unchanged CameraTrack sample.

hedphelym

20-12-2010 12:55:10

after some trail and error I got the first example to work.
Thank you very much, this helped me a lot today.