bluetrack
Member
MACOS IDE: v.2.2.5.481
Runtime: v.2.2.5.378
Hi, is there a way to select automatically one gamepad of the ones GM:S detects and set it as default? For instance on Android and specificlly on AndroidTV there are various inputs detected and put on different slots. (eg. SONY input service, mtkinp_events, TPRC, the external keyboard if present). So the slot fot the gamepad is not always the same and I need a way to automatically select it as default input.
The only solution I found so far is to have the following code in the gamepad step event:
for( var m=0; m<16; m++)
if( gamepad_button_value(m, gp_face1) )
{
global.active_gp = m;
break;
}
so when the player clicks on the face1 button then that input becomes the default one. This doesn't seem very efficient as it is run in every step event.
Here is what I have in the obj_gamepad:
===============================
CREATE_EVENT:
-------------------------
global.active_gp = 0;
global.gamepad_found = 0;
ASYNC_SYSTEM:
---------------------------
switch(async_load[? "event_type"]) // Parse the async_load map to see which event has been triggered
{
case "gamepad discovered": // A game pad has been discovered
var pad = async_load[? "pad_index"]; // Get the pad index value from the async_load map
gamepad_set_axis_deadzone(pad, 0.05); // Set the "deadzone" for the axis
gamepad_set_button_threshold(pad, 0.5); // Set the "threshold" for the triggers
audio_play_sound(snd_gamepad_connected,1,0);
global.gamepad_found = 1; // to be used to navigate with gamepad if present
global.show_virtual_keys = 0; // if gamepad detected on AndroidTV do not show virtual gamepad
break;
case "gamepad lost": // Gamepad has been removed or otherwise disabled
var pad = async_load[? "pad_index"]; // Get the pad index
audio_play_sound(snd_gamepad_disconnected,1,0);
global.gamepad_found = 0;
break;
}
Runtime: v.2.2.5.378
Hi, is there a way to select automatically one gamepad of the ones GM:S detects and set it as default? For instance on Android and specificlly on AndroidTV there are various inputs detected and put on different slots. (eg. SONY input service, mtkinp_events, TPRC, the external keyboard if present). So the slot fot the gamepad is not always the same and I need a way to automatically select it as default input.
The only solution I found so far is to have the following code in the gamepad step event:
for( var m=0; m<16; m++)
if( gamepad_button_value(m, gp_face1) )
{
global.active_gp = m;
break;
}
so when the player clicks on the face1 button then that input becomes the default one. This doesn't seem very efficient as it is run in every step event.
Here is what I have in the obj_gamepad:
===============================
CREATE_EVENT:
-------------------------
global.active_gp = 0;
global.gamepad_found = 0;
ASYNC_SYSTEM:
---------------------------
switch(async_load[? "event_type"]) // Parse the async_load map to see which event has been triggered
{
case "gamepad discovered": // A game pad has been discovered
var pad = async_load[? "pad_index"]; // Get the pad index value from the async_load map
gamepad_set_axis_deadzone(pad, 0.05); // Set the "deadzone" for the axis
gamepad_set_button_threshold(pad, 0.5); // Set the "threshold" for the triggers
audio_play_sound(snd_gamepad_connected,1,0);
global.gamepad_found = 1; // to be used to navigate with gamepad if present
global.show_virtual_keys = 0; // if gamepad detected on AndroidTV do not show virtual gamepad
break;
case "gamepad lost": // Gamepad has been removed or otherwise disabled
var pad = async_load[? "pad_index"]; // Get the pad index
audio_play_sound(snd_gamepad_disconnected,1,0);
global.gamepad_found = 0;
break;
}