Remapping functions to keys...
by Mike Daly · in Torque Game Engine · 11/08/2007 (3:46 pm) · 3 replies
I'm having an issue with key bindings and I'm not sure if this is code or script based.
I have my 'w' key set to the generic engine-based moveForward function. If I enter a trigger, I'd like to remap the 'w' key to do something different (ex. move up in the z direction rather than in the forward direction).
The problem that I am encountering is.. if the player is holding the 'w' key when he enters a trigger that remaps to a different function, the function that gets remapped to the 'w' isn't called until 'w' is released and pressed again. (All this is scripting, not C++)
I just need to be pointed in the right direction.
Thanks,
Mike
I have my 'w' key set to the generic engine-based moveForward function. If I enter a trigger, I'd like to remap the 'w' key to do something different (ex. move up in the z direction rather than in the forward direction).
The problem that I am encountering is.. if the player is holding the 'w' key when he enters a trigger that remaps to a different function, the function that gets remapped to the 'w' isn't called until 'w' is released and pressed again. (All this is scripting, not C++)
I just need to be pointed in the right direction.
Thanks,
Mike
#2
Rather than changing the key binding, you could try pushing a new key map.
Just a little description of what is happening:
1. key is pressed
2. Original key binding is called setting a global movement variable
3. key binding is changed
4. key is still pressed
5. Global variable has not changed
We need to insert a way to force the actionmap to send the keyup AND keydown events when the binding is changed.
I'm hoping that pushing a new actionmap will do this automatically.
11/11/2007 (3:28 am)
This is a problem with how the keys are handled overall. Rather than changing the key binding, you could try pushing a new key map.
Just a little description of what is happening:
1. key is pressed
2. Original key binding is called setting a global movement variable
3. key binding is changed
4. key is still pressed
5. Global variable has not changed
We need to insert a way to force the actionmap to send the keyup AND keydown events when the binding is changed.
I'm hoping that pushing a new actionmap will do this automatically.
#3
Also, if there is some way to change the C++ code so that you can detect between the different states (rather than 1 = down, 0 = up; maybe 2 = held) so that we could check for a held key. I don't know how this would screw up other functions using the binary 0,1 for keypresses, but just a thought.
Mike Daly
11/11/2007 (6:07 pm)
Thanks Brian. That's pretty much the line of thinking I was going through. I haven't tried pushing a new actionmap, yet. I did pop the default keymapping, then push it back on with no success. I'll give this a try.Also, if there is some way to change the C++ code so that you can detect between the different states (rather than 1 = down, 0 = up; maybe 2 = held) so that we could check for a held key. I don't know how this would screw up other functions using the binary 0,1 for keypresses, but just a thought.
Mike Daly
Torque Owner Lee Latham
Default Studio Name