Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #macro gp_lstick_up [gp_axislv, -0.1]
- #macro gp_lstick_down [gp_axislv, 0.1]
- #macro gp_lstick_left [gp_axislh, -0.1]
- #macro gp_lstick_right [gp_axislh, 0.1]
- #macro gp_rstick_up [gp_axisrv, -0.1]
- #macro gp_rstick_down [gp_axisrv, 0.1]
- #macro gp_rstick_left [gp_axisrh, -0.1]
- #macro gp_rstick_right [gp_axisrh, 0.1]
- /// @description Returns the string name for a GameMaker native key index
- /// @param _key
- function key_to_name(argument0) {
- var _key = argument0;
- if (_key == "") return "";
- #region gamepad sticks
- if (is_array(_key))
- {
- if (_key[0] == gp_axislv && sign(_key[1]) == -1)
- return "LEFT_STICK_UP";
- if (_key[0] == gp_axislv && sign(_key[1]) == 1)
- return "LEFT_STICK_DOWN";
- if (_key[0] == gp_axislh && sign(_key[1]) == -1)
- return "LEFT_STICK_LEFT";
- if (_key[0] == gp_axislh && sign(_key[1]) == 1)
- return "LEFT_STICK_RIGHT";
- if (_key[0] == gp_axisrv && sign(_key[1]) == -1)
- return "RIGHT_STICK_UP";
- if (_key[0] == gp_axisrv && sign(_key[1]) == 1)
- return "RIGHT_STICK_DOWN";
- if (_key[0] == gp_axisrh && sign(_key[1]) == -1)
- return "RIGHT_STICK_LEFT";
- if (_key[0] == gp_axisrh && sign(_key[1]) == 1)
- return "RIGHT_STICK_RIGHT";
- }
- #endregion gamepad sticks
- #region A-Z 0-9
- if ( _key >= ord("A") ) && ( _key <= ord("Z") )
- {
- var _string = chr( _key );
- if ( string_length( _string ) == 1 ) return _string;
- }
- else if ( _key >= ord("0") ) && ( _key <= ord("9") )
- {
- var _string = chr( _key );
- if ( string_length( _string ) == 1 ) return _string;
- }
- #endregion A-Z 0-9
- #region Key and button constants
- switch( _key )
- {
- case vk_escape: return "ESC"; break;
- case vk_shift: return "SHIFT"; break;
- case vk_enter: return "ENTER"; break;
- case vk_control: return "CTRL"; break;
- case vk_alt: return "ALT"; break;
- case vk_tab: return "TAB"; break;
- case vk_backspace: return "BACK"; break;
- case vk_space: return "SPACE"; break;
- case vk_delete: return "DEL"; break;
- case vk_insert: return "INS"; break;
- case vk_end: return "END"; break;
- case vk_home: return "HOME"; break;
- case vk_pagedown: return "PG DN"; break;
- case vk_pageup: return "PG UP"; break;
- case vk_up: return "UP"; break;
- case vk_down: return "DOWN"; break;
- case vk_left: return "LEFT"; break;
- case vk_right: return "RIGHT"; break;
- case vk_numpad0: return "NUM 0"; break;
- case vk_numpad1: return "NUM 1"; break;
- case vk_numpad2: return "NUM 2"; break;
- case vk_numpad3: return "NUM 3"; break;
- case vk_numpad4: return "NUM 4"; break;
- case vk_numpad5: return "NUM 5"; break;
- case vk_numpad6: return "NUM 6"; break;
- case vk_numpad7: return "NUM 7"; break;
- case vk_numpad8: return "NUM 8"; break;
- case vk_numpad9: return "NUM 9"; break;
- case vk_add: return "NUM +"; break;
- case vk_subtract: return "NUM -"; break;
- case vk_divide: return "NUM /"; break;
- case vk_multiply: return "NUM *"; break;
- case gp_padu: return "DPAD_UP"; break;
- case gp_padd: return "DPAD_DOWN"; break;
- case gp_padl: return "DPAD_LEFT"; break;
- case gp_padr: return "DPAD_RIGHT"; break;
- case gp_face1: return "FACE1"; break;
- case gp_face2: return "FACE2"; break;
- case gp_face3: return "FACE3"; break;
- case gp_face4: return "FACE4"; break;
- case gp_shoulderl: return "LEFT_SHOULDER"; break;
- case gp_shoulderlb: return "LEFT_TRIGGER"; break;
- case gp_shoulderr: return "RIGHT_SHOULDER"; break;
- case gp_shoulderrb: return "RIGHT_TRIGGER"; break;
- case gp_start: return "START"; break;
- case gp_select: return "SELECT"; break;
- case gp_stickl: return "LEFT_STICK_BUTTON"; break;
- case gp_stickr: return "RIGHT_STICK_BUTTON"; break;
- default: return ""; break;
- }
- #endregion Key and button constants
- }
- /// @description Returns the GameMaker native key index for a string name
- /// @param name
- function name_to_key(argument0) {
- var _string = string_upper( argument0 );
- if ( string_length( _string ) == 1 )
- {
- var _ord = ord( _string );
- if ( _ord >= 33 ) && ( _ord <= 126 ) return _ord else return undefined;
- }
- switch( _string )
- {
- case "ESCAPE": return vk_escape; break;
- case "ESC": return vk_escape; break;
- case "SHIFT": return vk_shift; break;
- case "RETURN": return vk_enter; break;
- case "ENTER": return vk_enter; break;
- case "CONTROL": return vk_control; break;
- case "CTRL": return vk_control; break;
- case "ALT": return vk_alt; break;
- case "TAB": return vk_tab; break;
- case "BACK": return vk_backspace; break;
- case "BACKSPACE": return vk_backspace; break;
- case "SPACE": return vk_space; break;
- case "LEFT ALT": return vk_lalt; break;
- case "LEFT CONTROL": return vk_lcontrol; break;
- case "LEFT CTRL": return vk_lcontrol; break;
- case "LEFT SHIFT": return vk_lshift; break;
- case "RIGHT ALT": return vk_ralt; break;
- case "RIGHT CONTROL": return vk_rcontrol; break;
- case "RIGHT CTRL": return vk_rcontrol; break;
- case "RIGHT SHIFT": return vk_rshift; break;
- case "DEL": return vk_delete; break;
- case "DELETE": return vk_delete; break;
- case "INS": return vk_insert; break;
- case "INSERT": return vk_insert; break;
- case "END": return vk_end; break;
- case "HOME": return vk_home; break;
- case "PG DN": return vk_pagedown; break;
- case "PAGE DOWN": return vk_pagedown; break;
- case "PG UP": return vk_pageup; break;
- case "PAGE UP": return vk_pageup; break;
- case "UP": return vk_up; break;
- case "DOWN": return vk_down; break;
- case "LEFT": return vk_left; break;
- case "RIGHT": return vk_right; break;
- case "NUMPAD0": return vk_numpad0; break;
- case "NUMPAD1": return vk_numpad1; break;
- case "NUMPAD2": return vk_numpad2; break;
- case "NUMPAD3": return vk_numpad3; break;
- case "NUMPAD4": return vk_numpad4; break;
- case "NUMPAD5": return vk_numpad5; break;
- case "NUMPAD6": return vk_numpad6; break;
- case "NUMPAD7": return vk_numpad7; break;
- case "NUMPAD8": return vk_numpad8; break;
- case "NUMPAD9": return vk_numpad9; break;
- case "NUM 0": return vk_numpad0; break;
- case "NUM 1": return vk_numpad1; break;
- case "NUM 2": return vk_numpad2; break;
- case "NUM 3": return vk_numpad3; break;
- case "NUM 4": return vk_numpad4; break;
- case "NUM 5": return vk_numpad5; break;
- case "NUM 6": return vk_numpad6; break;
- case "NUM 7": return vk_numpad7; break;
- case "NUM 8": return vk_numpad8; break;
- case "NUM 9": return vk_numpad9; break;
- case "NUM +": return vk_add; break;
- case "NUMPAD+": return vk_add; break;
- case "NUMPAD ADD": return vk_add; break;
- case "NUMPAD PLUS": return vk_add; break;
- case "NUM -": return vk_subtract; break;
- case "NUMPAD-": return vk_subtract; break;
- case "NUMPAD SUBTRACT": return vk_subtract; break;
- case "NUMPAD MINUS": return vk_subtract; break;
- case "NUM /": return vk_divide; break;
- case "NUMPAD/": return vk_divide; break;
- case "NUMPAD DIVIDE": return vk_divide; break;
- case "NUM *": return vk_multiply; break;
- case "NUMPAD*": return vk_multiply; break;
- case "NUMPAD MULTIPLY": return vk_multiply; break;
- case "DPAD_UP": return gp_padu; break;
- case "DPAD_DOWN": return gp_padd; break;
- case "DPAD_LEFT": return gp_padl; break;
- case "DPAD_RIGHT": return gp_padr; break;
- case "LEFT_STICK_UP": return gp_lstick_up; break;
- case "LEFT_STICK_DOWN": return gp_lstick_down; break;
- case "LEFT_STICK_LEFT": return gp_lstick_left; break;
- case "LEFT_STICK_RIGHT": return gp_lstick_right; break;
- case "RIGHT_STICK_UP": return gp_rstick_up; break;
- case "RIGHT_STICK_DOWN": return gp_rstick_down; break;
- case "RIGHT_STICK_LEFT": return gp_rstick_left; break;
- case "RIGHT_STICK_RIGHT": return gp_rstick_right; break;
- case "FACE1": return gp_face1; break;
- case "FACE2": return gp_face2; break;
- case "FACE3": return gp_face3; break;
- case "FACE4": return gp_face4; break;
- case "LEFT_SHOULDER": return gp_shoulderl; break;
- case "LEFT_TRIGGER": return gp_shoulderlb; break;
- case "RIGHT_SHOULDER": return gp_shoulderr; break;
- case "RIGHT_TRIGGER": return gp_shoulderrb; break;
- case "START": return gp_start; break;
- case "SELECT": return gp_select; break;
- case "LEFT_STICK_BUTTON": return gp_stickl; break;
- case "RIGHT_STICK_BUTTON": return gp_stickr; break;
- default: return ""; break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement