--[[
    Listens for user input
]]

function UserInput.init()
	UserInputService.InputBegan:Connect(
		function(inputObject, gameProcessedEvent)
			if gameProcessedEvent then
				return
			end

			local action = getActionFromInput(inputObject)
			if action == "Forwards" then
				throttle = 1
			elseif action == "Backwards" then
				throttle = -1
			elseif action == "Left" then
				steer = -1
			elseif action == "Right" then
				steer = 1
			elseif action == "Boost" then
				if FlagEnableBoosts then
					ClientVehicleBoosts.requestBoost()
				end
			end
		end
	)

	UserInputService.InputEnded:Connect(
		function(inputObject, gameProcessedEvent)
			if gameProcessedEvent then
				return
			end

			local action = getActionFromInput(inputObject)

			if action == "Forwards" or action == "Backwards" then
				throttle = isActionHeld("Forwards") and 1 or isActionHeld("Backwards") and -1 or 0
			elseif action == "Left" or action == "Right" then
				steer = isActionHeld("Right") and 1 or isActionHeld("Left") and -1 or 0
			end
		end
	)
end
