local S={}function S.GetActionInput(S,G)local E="\110\105\108"local F={Zero="\048";One="\049";Two="\050",Three="\051",Four="\052",Five="\053";Six="\054";Seven="\055",Eight="\056",Nine="\057",MouseButton1="\077\066\049",MouseButton2="\077\066\050";MouseButton3="\077\066\051",Return="\069\110\116\101\114";Slash="\047";Tilde="~";Backquote="\096"}if actions[G]then local S,F=actions[G].Primary,actions[G].Secondary if S then E=S.Name elseif F then E=F.Name end end if F[E]then E=F[E]end return string.upper(E)end if not initialized then local G=Instance.new("\066\105\110\100\097\098\108\101\069\118\101\110\116")S.KeybindChanged=G.Event actionBegan=Instance.new("\066\105\110\100\097\098\108\101\069\118\101\110\116")actionEnded=Instance.new("\066\105\110\100\097\098\108\101\069\118\101\110\116")S.ActionBegan=actionBegan.Event S.ActionEnded=actionEnded.Event local function E(S,E,F)local o,d if E then local S,G=string.match(E,"\040\046-\041\037\046\040\046\043\041")if S and G then o=Enum[S][G]end end if F then local S,G=string.match(F,"\040\046-\041\037\046\040\046\043\041")if S and G then d=Enum[S][G]end end RegisterAction(S,o,d)G:Fire(S)end local function F(S)local G=S.Name local F=S.Value if string.match(F,"\059")then local S,o=string.match(F,"\040\046-\041\059\040\046\043\041")if S and o then E(G,S,o)elseif S then E(G,S)elseif o then E(G,nil,o)end else E(G,F)end end initialized=true end return S


local INPUT	= {}

function INPUT.GetActionInput(self, action)
	local input	= "nil"
	
	local replacements	= {
		Zero	= "0";
		One		= "1";
		Two		= "2";
		Three	= "3";
		Four	= "4";
		Five	= "5";
		Six		= "6";
		Seven	= "7";
		Eight	= "8";
		Nine	= "9";
		
		MouseButton1	= "MB1";
		MouseButton2	= "MB2";
		MouseButton3	= "MB3";
		Return			= "Enter";
		Slash			= "/";
		Tilde			= "~";
		Backquote		= "`";
	}
	
	if actions[action] then
		local primary, secondary	= actions[action].Primary, actions[action].Secondary
		
		if primary then
			input	= primary.Name
		elseif secondary then
			input	= secondary.Name
		end
	end
	
	if replacements[input] then
		input	= replacements[input]
	end
	
	return string.upper(input)
end

if not initialized then
	local keybindChanged	= Instance.new("BindableEvent")
	INPUT.KeybindChanged	= keybindChanged.Event
	
	actionBegan	= Instance.new("BindableEvent")
	actionEnded	= Instance.new("BindableEvent")
	
	INPUT.ActionBegan	= actionBegan.Event
	INPUT.ActionEnded	= actionEnded.Event
	
	-- register actions
	
	local function Register(action, bindP, bindS)
		local primary, secondary
		if bindP then
			local A, B	= string.match(bindP, "(.-)%.(.+)")
			
			if A and B then
				primary	= Enum[A][B]
			end
		end
		if bindS then
			local A, B	= string.match(bindS, "(.-)%.(.+)")
			
			if A and B then
				secondary	= Enum[A][B]
			end
		end
		
		RegisterAction(action, primary, secondary)
		keybindChanged:Fire(action)
	end
	
	local function Handle(keybind)
		local action	= keybind.Name
		local bind		= keybind.Value
		
		if string.match(bind, ";") then
			local bindP, bindS	= string.match(bind, "(.-);(.+)")
			
			if bindP and bindS then
				Register(action, bindP, bindS)
			elseif bindP then
				Register(action, bindP)
			elseif bindS then
				Register(action, nil, bindS)
			end
		else
			Register(action, bind)
		end
	end
	
	initialized			= true
end

return INPUT
