Last active
September 23, 2016 14:22
-
-
Save gnysek/791e82e54c54918bd0b78ad4508748dd to your computer and use it in GitHub Desktop.
gamepad_key
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
//on game initialization, call it only once! | |
globalvar gamepad_key, __gp; | |
gamepad_key = -1; | |
__gp[15] = gp_face1; | |
__gp[14] = gp_face2; | |
__gp[13] = gp_face3; | |
__gp[12] = gp_face4; | |
__gp[11] = gp_shoulderl; | |
__gp[10] = gp_shoulderlb; | |
__gp[9] = gp_shoulderr; | |
__gp[8] = gp_shoulderrb; | |
__gp[7] = gp_select; | |
__gp[6] = gp_start; | |
__gp[5] = gp_stickl; | |
__gp[4] = gp_stickr; | |
__gp[3] = gp_padu; | |
__gp[2] = gp_padd; | |
__gp[1] = gp_padl; | |
__gp[0] = gp_padr; | |
// on step event | |
gamepad_key = -1; | |
var i; | |
for(i=0; i<16; i++) { | |
if gamepad_button_check(0, __gp[i]) gamepad_key = i; | |
} | |
// usage: | |
switch(gamepad_key) { | |
case gp_face1: ... break; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment