keymapping controllers?

Posted By: Nicholas

keymapping controllers? - 09/06/11 15:40

I'm trying to write my own keymapping code based off ones I have found on the forum and AUM. I got most of it to work, but I am having some issues with it reading a few things.
I am using key_lastpressed to set the key and call it forth to play the action like so:

var jump_v=57;
if(key_pressed(jump_v){run jump command}

The Key mapping in the manual doesn't have anything for the d-pad on controllers or the analog stick. Not to mention if the triggers aren't set up as buttons in the driver it won't see that either.

Is there a way to set it up easily to be able to set the key to be able to tell if triggers or d-pad buttons were used?
thanks

if I can setup the system to recognize a custom scancode of a key that'd be great. say a trigger goes above a certain threshold when it's in the recording stage or the d-pad is at one of the 4 positions the key would be set to 290 (which doesn't exist in the scancode registry) then key_pressed(trigger) would be key_pressed(290), but that won't do anything since it's not set in the scancode.
Posted By: MrGuest

Re: keymapping controllers? - 09/07/11 23:56

as key_lastpressed is read-only you will need to create a new variable for determining the new possible key presses.

you'll need to create a sort of listener to identify if the key has been pressed and then released
Code:
#define KEY_HAT 290
#define KEY_RAWX 291

var prev_joyhat = joy_hat;
VECTOR prev_joyraw;
vec_set(prev_joyraw, joy_raw);

while(1){
  if(joy_hat != prev_joyhat){
    newkey_event(KEY_HAT);
    prev_joyhat = joy_hat;
  }
  if(joy_raw.x != prev_joyraw.x){
    newkey_event(KEY_RAWX);
    prev_joyraw.x = prev_joyraw.x){
  }
//etc...
  wait(1);
}

also, should you require it, you can pass which direction was triggered too by adding additional parameters

hope this helps
© 2024 lite-C Forums