Kezarus
Endless Game Maker
I am making a function that detect the gamepad on the start of a game. The thing is that it just works after some time and I don't know why.
I put the function below on an initial room on an object that initializes a bunch of things on the Create Event. It doensn't work.
Then I put that on a Room End Event. Don't work.
Then I put the same function on a button event, clicked it and it works. Does anyone knows why...? o_Ô
This is the evidence image. The function is called on the Create Event on the initializer object. After that it goes to a Menu Room and I click a button with the same function as above and now the GamePad is in the port 4.
I put the function below on an initial room on an object that initializes a bunch of things on the Create Event. It doensn't work.
Then I put that on a Room End Event. Don't work.
Then I put the same function on a button event, clicked it and it works. Does anyone knows why...? o_Ô
GML:
/// @description gamepad_detect( )
//DETECT CONTROLLER
var gp_num = gamepad_get_device_count();
var port = -1;
for (var i = 0; i < gp_num; i++;){
if( gamepad_is_connected(i) ){
port = i;
break;
}
}
if( port != -1 ){
gamepad_set_axis_deadzone(port, 0.15);
gamepad_set_button_threshold(port, 0.5);
}
global.connected_gamepad = port;
alert("*************************************** GAMEPAD ON PORT " + string(port) )
return port;