local E=require(script.Parent:WaitForChild("\066\097\115\101\067\104\097\114\097\099\116\101\114\067\111\110\116\114\111\108\108\101\114"))local R=setmetatable({},E)R.__index=R local S=Enum.UserInputType.None function R.new()local l=setmetatable(E.new(),R)l.forwardValue=0 l.backwardValue=0 l.leftValue=0 l.rightValue=0 l.activeGamepad=S l.gamepadConnectedConn=nil l.gamepadDisconnectedConn=nil return l end local l=game:GetService("\085\115\101\114\073\110\112\117\116\083\101\114\118\105\099\101")local g=Vector3.new(0,0,0)function R.Enable(E,R)if not l.GamepadEnabled then return false end if R==E.enabled then return true end E.forwardValue=0 E.backwardValue=0 E.leftValue=0 E.rightValue=0 E.moveVector=g E.isJumping=false if R then E.activeGamepad=E:GetHighestPriorityGamepad()if E.activeGamepad==S then return false end E:BindContextActions()E:ConnectGamepadConnectionListeners()else E:UnbindContextActions()E:DisconnectGamepadConnectionListeners()E.activeGamepad=S end E.enabled=R return true end function R.GetHighestPriorityGamepad(E)local R=S for E,S in pairs(l:GetConnectedGamepads())do if S.Value<R.Value then R=S end end return R end local j=game:GetService("\067\111\110\116\101\120\116\065\099\116\105\111\110\083\101\114\118\105\099\101")function R.BindContextActions(E)if E.activeGamepad==S then return false end j:BindActivate(E.activeGamepad,Enum.KeyCode.ButtonR2)j:BindAction("\106\117\109\112\065\099\116\105\111\110",function(R,S,l)E.isJumping=S==Enum.UserInputState.Begin end,false,Enum.KeyCode.ButtonA)j:BindAction("\109\111\118\101\084\104\117\109\098\115\116\105\099\107",function(R,S,l)if E.activeGamepad~=l.UserInputType then return end if l.KeyCode~=Enum.KeyCode.Thumbstick1 then return end if S==Enum.UserInputState.Cancel then E.moveVector=g return end if not(l.Position.magnitude>.2)then E.moveVector=g return end E.moveVector=Vector3.new(l.Position.X,0,-l.Position.Y)end,false,Enum.KeyCode.Thumbstick1)return true end function R.UnbindContextActions(E)if E.activeGamepad~=S then j:UnbindActivate(E.activeGamepad,Enum.KeyCode.ButtonR2)end j:UnbindAction("\109\111\118\101\084\104\117\109\098\115\116\105\099\107")j:UnbindAction("\106\117\109\112\065\099\116\105\111\110")end function R.OnNewGamepadConnected(E)local R=E:GetHighestPriorityGamepad()if R==E.activeGamepad then return end if R==S then warn("\071\097\109\101\112\097\100\058\079\110\078\101\119\071\097\109\101\112\097\100\067\111\110\110\101\099\116\101\100 \102\111\117\110\100 \110\111 \099\111\110\110\101\099\116\101\100 \103\097\109\101\112\097\100\115")E:UnbindContextActions()return end if E.activeGamepad~=S then j:UnbindActivate(E.activeGamepad,Enum.KeyCode.ButtonR2)end E.activeGamepad=R j:BindActivate(E.activeGamepad,Enum.KeyCode.ButtonR2)end function R.OnCurrentGamepadDisconnected(E)if E.activeGamepad~=S then j:UnbindActivate(E.activeGamepad,Enum.KeyCode.ButtonR2)end local R=E:GetHighestPriorityGamepad()if E.activeGamepad~=S and R==E.activeGamepad then warn("\071\097\109\101\112\097\100\058\079\110\067\117\114\114\101\110\116\071\097\109\101\112\097\100\068\105\115\099\111\110\110\101\099\116\101\100 \102\111\117\110\100 \116\104\101 \115\117\112\112\111\115\101\100\108\121 \100\105\115\099\111\110\110\101\099\116\101\100 \103\097\109\101\112\097\100 \105\110 \099\111\110\110\101\099\116\101\100\071\097\109\101\112\097\100\115\046")E:UnbindContextActions()E.activeGamepad=S return end if R==S then E:UnbindContextActions()E.activeGamepad=S return end E.activeGamepad=R j:BindActivate(E.activeGamepad,Enum.KeyCode.ButtonR2)end function R.ConnectGamepadConnectionListeners(E)E.gamepadConnectedConn=l.GamepadConnected:Connect(function(R)E:OnNewGamepadConnected()end)E.gamepadDisconnectedConn=l.GamepadDisconnected:Connect(function(R)if E.activeGamepad==R then E:OnCurrentGamepadDisconnected()end end)end function R.DisconnectGamepadConnectionListeners(E)if E.gamepadConnectedConn then E.gamepadConnectedConn:Disconnect()E.gamepadConnectedConn=nil end if E.gamepadDisconnectedConn then E.gamepadDisconnectedConn:Disconnect()E.gamepadDisconnectedConn=nil end end return R
-- Decompiled with the Synapse X Luau decompiler.

local v1 = require(script.Parent:WaitForChild("BaseCharacterController"))
local v2 = setmetatable({}, v1)
v2.__index = v2
local l__Enum_UserInputType_None__1 = Enum.UserInputType.None
function v2.new()
	local v3 = setmetatable(v1.new(), v2)
	v3.forwardValue = 0
	v3.backwardValue = 0
	v3.leftValue = 0
	v3.rightValue = 0
	v3.activeGamepad = l__Enum_UserInputType_None__1
	v3.gamepadConnectedConn = nil
	v3.gamepadDisconnectedConn = nil
	return v3
end
local l__UserInputService__2 = game:GetService("UserInputService")
local u3 = Vector3.new(0, 0, 0)
function v2.Enable(p1, p2)
	if not l__UserInputService__2.GamepadEnabled then
		return false
	end
	if p2 == p1.enabled then
		return true
	end
	p1.forwardValue = 0
	p1.backwardValue = 0
	p1.leftValue = 0
	p1.rightValue = 0
	p1.moveVector = u3
	p1.isJumping = false
	if p2 then
		p1.activeGamepad = p1:GetHighestPriorityGamepad()
		if p1.activeGamepad == l__Enum_UserInputType_None__1 then
			return false
		end
		p1:BindContextActions()
		p1:ConnectGamepadConnectionListeners()
	else
		p1:UnbindContextActions()
		p1:DisconnectGamepadConnectionListeners()
		p1.activeGamepad = l__Enum_UserInputType_None__1
	end
	p1.enabled = p2
	return true
end
function v2.GetHighestPriorityGamepad(p3)
	local v4 = l__Enum_UserInputType_None__1
	for v5, v6 in pairs((l__UserInputService__2:GetConnectedGamepads())) do
		if v6.Value < v4.Value then
			v4 = v6
		end
	end
	return v4
end
local l__ContextActionService__4 = game:GetService("ContextActionService")
function v2.BindContextActions(p4)
	if p4.activeGamepad == l__Enum_UserInputType_None__1 then
		return false
	end
	l__ContextActionService__4:BindActivate(p4.activeGamepad, Enum.KeyCode.ButtonR2)
	l__ContextActionService__4:BindAction("jumpAction", function(p5, p6, p7)
		p4.isJumping = p6 == Enum.UserInputState.Begin
	end, false, Enum.KeyCode.ButtonA)
	l__ContextActionService__4:BindAction("moveThumbstick", function(p8, p9, p10)
		if p4.activeGamepad ~= p10.UserInputType then
			return
		end
		if p10.KeyCode ~= Enum.KeyCode.Thumbstick1 then
			return
		end
		if p9 == Enum.UserInputState.Cancel then
			p4.moveVector = u3
			return
		end
		if not (p10.Position.magnitude > 0.2) then
			p4.moveVector = u3
			return
		end
		p4.moveVector = Vector3.new(p10.Position.X, 0, -p10.Position.Y)
	end, false, Enum.KeyCode.Thumbstick1)
	return true
end
function v2.UnbindContextActions(p11)
	if p11.activeGamepad ~= l__Enum_UserInputType_None__1 then
		l__ContextActionService__4:UnbindActivate(p11.activeGamepad, Enum.KeyCode.ButtonR2)
	end
	l__ContextActionService__4:UnbindAction("moveThumbstick")
	l__ContextActionService__4:UnbindAction("jumpAction")
end
function v2.OnNewGamepadConnected(p12)
	local v7 = p12:GetHighestPriorityGamepad()
	if v7 == p12.activeGamepad then
		return
	end
	if v7 == l__Enum_UserInputType_None__1 then
		warn("Gamepad:OnNewGamepadConnected found no connected gamepads")
		p12:UnbindContextActions()
		return
	end
	if p12.activeGamepad ~= l__Enum_UserInputType_None__1 then
		l__ContextActionService__4:UnbindActivate(p12.activeGamepad, Enum.KeyCode.ButtonR2)
	end
	p12.activeGamepad = v7
	l__ContextActionService__4:BindActivate(p12.activeGamepad, Enum.KeyCode.ButtonR2)
end
function v2.OnCurrentGamepadDisconnected(p13)
	if p13.activeGamepad ~= l__Enum_UserInputType_None__1 then
		l__ContextActionService__4:UnbindActivate(p13.activeGamepad, Enum.KeyCode.ButtonR2)
	end
	local v8 = p13:GetHighestPriorityGamepad()
	if p13.activeGamepad ~= l__Enum_UserInputType_None__1 and v8 == p13.activeGamepad then
		warn("Gamepad:OnCurrentGamepadDisconnected found the supposedly disconnected gamepad in connectedGamepads.")
		p13:UnbindContextActions()
		p13.activeGamepad = l__Enum_UserInputType_None__1
		return
	end
	if v8 == l__Enum_UserInputType_None__1 then
		p13:UnbindContextActions()
		p13.activeGamepad = l__Enum_UserInputType_None__1
		return
	end
	p13.activeGamepad = v8
	l__ContextActionService__4:BindActivate(p13.activeGamepad, Enum.KeyCode.ButtonR2)
end
function v2.ConnectGamepadConnectionListeners(p14)
	p14.gamepadConnectedConn = l__UserInputService__2.GamepadConnected:Connect(function(p15)
		p14:OnNewGamepadConnected()
	end)
	p14.gamepadDisconnectedConn = l__UserInputService__2.GamepadDisconnected:Connect(function(p16)
		if p14.activeGamepad == p16 then
			p14:OnCurrentGamepadDisconnected()
		end
	end)
end
function v2.DisconnectGamepadConnectionListeners(p17)
	if p17.gamepadConnectedConn then
		p17.gamepadConnectedConn:Disconnect()
		p17.gamepadConnectedConn = nil
	end
	if p17.gamepadDisconnectedConn then
		p17.gamepadDisconnectedConn:Disconnect()
		p17.gamepadDisconnectedConn = nil
	end
end
return v2
