Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,244 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
keymapping controllers? #382253
09/06/11 15:40
09/06/11 15:40
Joined: Aug 2002
Posts: 164
Houston
Nicholas Offline OP
Member
Nicholas  Offline OP
Member

Joined: Aug 2002
Posts: 164
Houston
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.


Black holes are where God divided by zero.
Re: keymapping controllers? [Re: Nicholas] #382411
09/07/11 23:56
09/07/11 23:56
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
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


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1