• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM Gamepad alternative to vk_anykey [Now- GML files of constants?]

C

ChrisMG12

Guest
I need it for setting an alarm in my game. Its similar to how Release any key event is like keyboadr_check_released(vk_anykey), but I need a gamepad alternative for making something likegamepad_button_released(alternative).
 
C

ChrisMG12

Guest
IK its not there in GMS 1.4 but is there like a script or something i can make for it
 

TheouAegis

Member
bear in mind that the co the guy came up with at the end only work for one button at a time. It will not allow you to have two buttons pressed at a time. But he should have done is had each button set a unique bit in a variable which would be returned at the end of that script. If that variable was anything other than zero, then you know any button was pressed.

Not sure what the button values are, but

var n= 0;
...
n|=pow(2,i)
...
return n;

should suffice.
 
C

ChrisMG12

Guest
I did see this one before but I don't know how to use it properly, I'm kinda new to GML.
bear in mind that the co the guy came up with at the end only work for one button at a time. It will not allow you to have two buttons pressed at a time. But he should have done is had each button set a unique bit in a variable which would be returned at the end of that script. If that variable was anything other than zero, then you know any button was pressed.

Not sure what the button values are, but

var n= 0;
...
n|=pow(2,i)
...
return n;

should suffice.
I do need that multi-button release but idk how to keep that in the script.
 
C

ChrisMG12

Guest
I want to see how GMS finds constants like vk_.., c_.. etc, is it done in GML if so is it there in a file or something like that which we can access and use for making scripts based on it. We can probably use something like this (if it is in GML form) to make a script for this issue.
 

TheouAegis

Member
Just do a series of show_debug_message() in a create event. Put every single constant for the gamepad you can find. That will tell you what range those constants occupy.
 

The-any-Key

Member
any help?
No, sorry, thought you where looking for the any key.

But if you want a script to check when any key of a gamepad is released something like this is a start:
Code:
/// gamepad_button_released_any_key(device);
var device_=argument0;
var show_debug=true;
// Loop all gamepad keys
for (i=gp_face1; i<gp_axisrv+1; i+=1)
{
    if gamepad_button_check_released(device_,i)
    {
        // Show debug
        if show_debug
        {
            // Check constants
            var pressed_key="";
            switch (i)
            {
                case gp_face1: pressed_key="gp_face1"; break;
                case gp_face2: pressed_key="gp_face2"; break;
                case gp_face3: pressed_key="gp_face3"; break;
                case gp_face4: pressed_key="gp_face4"; break;
                case gp_shoulderl: pressed_key="gp_shoulderl"; break;
                case gp_shoulderlb: pressed_key="gp_shoulderlb"; break;
                case gp_shoulderr: pressed_key="gp_shoulderr"; break;
                case gp_shoulderrb: pressed_key="gp_shoulderrb"; break;
                case gp_select: pressed_key="gp_select"; break;
                case gp_start: pressed_key="gp_start"; break;
                case gp_stickl: pressed_key="gp_stickl"; break;
                case gp_stickr: pressed_key="gp_stickr"; break;
                case gp_padu: pressed_key="gp_padu"; break;
                case gp_padd: pressed_key="gp_padd"; break;
                case gp_padl: pressed_key="gp_padl"; break;
                case gp_padr: pressed_key="gp_padr"; break;
                case gp_axislh: pressed_key="gp_axislh"; break;
                case gp_axislv: pressed_key="gp_axislv"; break;
                case gp_axisrh: pressed_key="gp_axisrh"; break;
                case gp_axisrv: pressed_key="gp_axisrv"; break;
                default: pressed_key="un-mapped key";
            }
            show_debug_message("Released gamepad button:" + pressed_key);
        }
        // Return released button
        return true;
    }
}
Also give this asset a check: https://marketplace.yoyogames.com/assets/243/input-dog
I learned most of the gamepad GML by that asset.
 
Top