0 registered members (),
1,397
guests, and 7
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Key Mapping?
#374842
06/21/11 22:32
06/21/11 22:32
|
Joined: Aug 2002
Posts: 164 Houston
Nicholas
OP
Member
|
OP
Member
Joined: Aug 2002
Posts: 164
Houston
|
I am sure this has been done before, but I am looking for a refresher since I can't find any mention of it. I am looking for a way to remap my keys with as little code as possible. What's the best way to remap my keys/joystick buttons? I was thinking of using strings so I could do something like:
STRING* jump = "joy_1";
if (jump ==1){player_jump;}
this would obviously try to use joy_1 as the jump button, but since I don't think I can use a string in an if statement I'm not sure of the best way to do it. I would use a panel or ini file to remap the keys as need be, but don't want to have hundreds of if then statements inside of each other for each possible combination. Any help would be great
thanks
Black holes are where God divided by zero.
|
|
|
Re: Key Mapping?
[Re: Nicholas]
#374843
06/21/11 22:50
06/21/11 22:50
|
Joined: Aug 2009
Posts: 1,438 Spain
painkiller
Serious User
|
Serious User
Joined: Aug 2009
Posts: 1,438
Spain
|
you can't do that, try this:
#define jump joy_1
....
if (jump ==1){player_jump;}
3D Gamestudio A8 Pro AMD FX 8350 4.00 Ghz 16GB RAM Gigabyte GeForce GTX 960 4GB
|
|
|
Re: Key Mapping?
[Re: Helghast]
#374937
06/22/11 16:23
06/22/11 16:23
|
Joined: Aug 2002
Posts: 164 Houston
Nicholas
OP
Member
|
OP
Member
Joined: Aug 2002
Posts: 164
Houston
|
I've been meaning to take a look at AUM100, nice setup there with the search functions and all the downloads. I think I got it to work with keyboard and joysticks with as little code as possible. I needed to make it know if the button was held down so remapping the key to the function didn't seem to work too well, so I used a while loop in an action and just used the function part to set a var to the key pressed
var duck_v; var jump_v;
function duck_f() {duck_v = key_lastpressed; } //set duck var //joy_1 = 256, a = 30, etc function jump_f() {jump_v = key_lastpressed; } //set jump var
//use this part for the mapping:
while (key_any == 0) { wait(1); } // wait until a key is hit key_set(key_lastpressed,duck_f); // assign function to key while (key_any == 1) { wait(1); } // wait until key is released while (key_any == 0) { wait(1); } // wait until a key is hit key_set(key_lastpressed,jump_f); // assign function to key
//put the rest in a while loop somewhere"
if (key_pressed(jump_v) == 1){//jump anim/etc if (key_pressed(duck_v) == 1){//duck animation/action/sound etc...
will also know if key is held down and since key_pressed works with the 256+ numbers not just the lower ones it'll work with joysticks too.
There might be a more correct way, but this seems to work for me. I'll still take a look at the aum and see if there is anything that'll work for my application in there
Black holes are where God divided by zero.
|
|
|
|