I get that much and implemented it. However, I looked through the manual and all functions use a 0 to 1 input rather than a button id. Still looking around for the solution but no such luck.On a gamepad you have to check each button specifically to see if it has been pressed or not, so for a rebind you'll have to loop through all the buttons and look for one being pressed.
You're looking for the constants listed at GamePad Input, I imagine?I get that much and implemented it. However, I looked through the manual and all functions use a 0 to 1 input rather than a button id. Still looking around for the solution but no such luck.
I'm trying to make a controller profile using a ds_grid and having it saved in a *.json format. The player can load or save the inputs they remapped to the controller when the game boots up. Now I have everything set but the key to it is the button id's.You're looking for the constants listed at GamePad Input, I imagine?
if (key_change==true && alarm[1]>-1)
{
if (alarm[2]=-1)
{
for (var i=0; i<16; i++)
{
if (gamepad_button_check_pressed(0,i)) // <<< Press to change
{
global.controls[# 0, cursor_id]= // <<< The button id needed to replace the current button in the grid.
key_change=false;
alarm[1]=-1;
loop=true;
}
}
}
}
else
{
key_change=false;
}
if(gamepad_button_check_pressed(current_device, gp_face1); // Button (A) on X-Bone, (X) on PS.
global.controls[# 0, cursor_id] = gp_face1;
if(gamepad_button_check_pressed(current_device, global.controls[# 0, cursor_id])){
// gp_face1 is pressed.
}
Completed the script as suggested. I guess this topic is solved. For what it's worth I'll throw in a few more bits of information in case anyone is looking into this for help.You have to use contants Chamaeleon linked to when checking buttons, and they will return a boolean (0 or 1) depending on button state. However those constants can be saved into variables too (they're just integers AFAIK). So you must first check if a certain button is pressed using the scheme
And you can save specific buttons to your DSCode:if(gamepad_button_check_pressed(current_device, gp_face1); // Button (A) on X-Bone, (X) on PS.
And later check if given button is pressedCode:global.controls[# 0, cursor_id] = gp_face1;
I don't know what the values of those constants are, but it is best to assume they may overlap with keyboard button constants and not mix them. So when you are checking keyboard bindings, do not check them against gamepad constants, and vice versa. Meaning, continuing the above example, as global.controls[# 0, cursor_id] now contains a reference to gamepad button gp_face1, you should NOT check it with keyboard_check(). It might give a false positive, it might not. Best to not test your luck.Code:if(gamepad_button_check_pressed(current_device, global.controls[# 0, cursor_id])){ // gp_face1 is pressed. }
///@description gamepad_key
///@function
///@arg device
///@arg button
var device = argument0; // Controller
var check = argument1; // Use a for loop to find the desired gamepad button
var button=undefined; // Holds the button on return
if (gamepad_is_connected(device))
{
var key; // 1D Array
key[0]=gp_padu;
key[1]=gp_padd;
key[2]=gp_padl;
key[3]=gp_padr;
key[4]=gp_start;
key[5]=gp_select;
key[6]=gp_stickl;
key[7]=gp_stickr;
key[8]=gp_shoulderl;
key[9]=gp_shoulderr;
key[10]=gp_shoulderlb;
key[11]=gp_shoulderrb;
key[12]=gp_face1;
key[13]=gp_face2;
key[14]=gp_face3;
key[15]=gp_face4;
button=key[check];
}
else
{
button = "ERROR: Controller Not Connected!";
}
return button