local x=.35 local k=.8 local function i(i)i=math.clamp(i,-1,1)if i>=0 then return(x*i)/((x-i)+1)end return-((k*-i)/((k+i)+1))end local L=.1 local function E(x)return(1+L)*(2*math.abs(x)-1)-L end local function s(x)return x/2+.5 end function CameraUtils.GamepadLinearToCurve(x)local function k(x)local k=1 if x<0 then k=-1 end local L=s(i(E(math.abs(x))))L=L*k return math.clamp(L,-1,1)end return Vector2.new(k(x.x),k(x.y))end
-- K is a tunable parameter that changes the shape of the S-curve
-- the larger K is the more straight/linear the curve gets
local k = 0.35
local lowerK = 0.8
local function SCurveTranform(t)
	t = math.clamp(t, -1, 1)
	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 math.clamp(point, -1, 1)
	end
	return Vector2.new(onAxis(thumbstickPosition.x), onAxis(thumbstickPosition.y))
end
