local U=.35 local F=.8 local function i(i)i=CameraUtils.Clamp(-1,1,i)if i>=0 then return(U*i)/((U-i)+1)end return-((F*-i)/((F+i)+1))end local A=.1 local function y(U)return(1+A)*(2*math.abs(U)-1)-A end local function d(U)return U/2+.5 end function CameraUtils.GamepadLinearToCurve(U)local function F(U)local F=1 if U<0 then F=-1 end local A=d(i(y(math.abs(U))))A=A*F return CameraUtils.Clamp(-1,1,A)end return Vector2.new(F(U.x),F(U.y))end

local k = 0.35
local lowerK = 0.8
local function SCurveTranform(t)
	t = CameraUtils.Clamp(-1,1,t)
	if t >= 0 then
		return (k*t) / (k - t + 1)
	end
	return -((lowerK*-t) / (lowerK + t + 1))
end

local DEADZONE = 0.1
local function toSCurveSpace(t)
	return (1 + DEADZONE) * (2*math.abs(t) - 1) - DEADZONE
end

local function fromSCurveSpace(t)
	return t/2 + 0.5
end
	
function CameraUtils.GamepadLinearToCurve(thumbstickPosition)
	local function onAxis(axisValue)
		local sign = 1
		if axisValue < 0 then
			sign = -1
		end
		local point = fromSCurveSpace(SCurveTranform(toSCurveSpace(math.abs(axisValue))))
		point = point * sign
		return CameraUtils.Clamp(-1, 1, point)
	end
	return Vector2.new(onAxis(thumbstickPosition.x), onAxis(thumbstickPosition.y))
end
