Last active
August 14, 2018 01:00
-
-
Save PoppyWorks/4c253f200f6cf2d8ca3b0b74337509e8 to your computer and use it in GitHub Desktop.
GML Script. Knows what OS you are using, and if you are using a gamepad or keyboard/mouse. Use bootstrap after input_change(). Bootstrapper ensures that a gamepad is connected before allowing the user to swap over to gamepad input from Keyboard/mouse.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///PC users or PS4 Input | |
if os_type == os_windows || os_ps4 || os_xboxone | |
{ | |
if gamepad_button_check_any(global.gpDevice) | |
{ | |
global.KBMuser = false; | |
} | |
if keyboard_check(vk_anykey) || mouse_check_button(mb_any) | |
{ | |
global.KBMuser = true; | |
} | |
global.dp_up = vk_up; | |
global.dp_down = vk_down; | |
global.dp_left = vk_left; | |
global.dp_right = vk_right; | |
global.confirm = ord("Z"); | |
global.cancel = ord("X"); | |
global.button3 = ord("C"); | |
global.button4 = ord("V"); | |
global.start = vk_enter; | |
global.select = gp_select; | |
global.mouse = true; | |
if gamepad_is_connected(0) || gamepad_is_connected(4) | |
{ | |
global.gpadConnected = true; | |
} | |
if global.gpadConnected == true && global.KBMuser = false | |
{ | |
global.dp_up = gp_padu; | |
global.dp_down = gp_padd; | |
global.dp_left = gp_padl; | |
global.dp_right = gp_padr; | |
global.confirm = gp_face1; | |
global.cancel = gp_face2; | |
global.button3 = gp_face3; | |
global.button4 = gp_face4; | |
global.triggerr = gp_shoulderr; | |
global.bumperr = gp_shoulderrb; | |
global.triggerl = gp_shoulderl; | |
global.bumperl = gp_shoulderlb; | |
global.start = gp_start; | |
global.select = gp_select; | |
global.mouse = false; | |
} | |
} | |
///PS Vita Input | |
if os_type == os_psvita | |
{ | |
global.dp_up = gp_padu; | |
global.dp_down = gp_padd; | |
global.dp_left = gp_padl; | |
global.dp_right = gp_padr; | |
global.confirm = gp_face1; | |
global.cancel = gp_face2; | |
global.button3 = gp_face3; | |
global.button4 = gp_face4; | |
global.triggerr = gp_shoulderr; | |
global.bumperr = gp_shoulderrb; | |
global.triggerl = gp_shoulderl; | |
global.bumperl = gp_shoulderlb; | |
global.start = gp_start; | |
global.select = gp_select; | |
global.mouse = false; | |
} | |
///Japanese PlayStation | |
if (os_type == os_ps4 || os_psvita) && global.language == "ja" | |
{ | |
global.confirm = gp_face2; | |
global.cancel = gp_face1; | |
} | |
///Ouya Input | |
if os_type == os_android | |
{ | |
if global.os_ouya == true | |
{ | |
global.dp_up = "BUTTON_DPAD_UP"; | |
global.dp_down = "BUTTON_DPAD_DOWN"; | |
global.dp_left = "BUTTON_DPAD_LEFT"; | |
global.dp_right = "BUTTON_DPAD_RIGHT"; | |
global.confirm = "BUTTON_O"; | |
global.cancel = "BUTTON_A"; | |
global.button3 = "BUTTON_U"; | |
global.button4 = "BUTTON_Y"; | |
global.triggerr = gp_shoulderr; // | |
global.bumperr = "BUTTON_R1"; | |
global.triggerl = gp_shoulderl; // | |
global.bumperl = "BUTTON_L1"; | |
global.start = "BUTTON_R3"; | |
global.select = "BUTTON_L3"; | |
global.mouse = true; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///gamepad_bootstrap(device number) | |
var device = argument0; | |
if gamepad_is_connected(device) | |
{ | |
global.gpadConnected = true; | |
} | |
else | |
{ | |
global.gpadConnected = false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment