local function p(p)if math.abs(p)<GAMEPAD_DEADZONE then return 0 end return(p+(p>0 and-GAMEPAD_DEADZONE or GAMEPAD_DEADZONE))/(1-GAMEPAD_DEADZONE)end local function n(p,n)if p and boostAmount>n then boostAmount=boostAmount-n elseif boostAmount>=0 and boostAmount<maxBoostAmount then boostAmount=boostAmount+n/2 p=false end return p end

local function ApplyDeadzone(n)
	if math.abs(n) < GAMEPAD_DEADZONE then return 0 end
	return (n + (n > 0 and -GAMEPAD_DEADZONE or GAMEPAD_DEADZONE)) / (1 - GAMEPAD_DEADZONE)
end -- ApplyDeadzone()

local function UpdateBoost(boost, step)	
	-- Update boost amount
	if boost and boostAmount > step then
		boostAmount = boostAmount - step
	elseif ((boostAmount >= 0) and (boostAmount < maxBoostAmount)) then
		-- Restore boost when boost is off (restores at half speed of use rate)
		boostAmount = boostAmount + step/2
		boost = false 
	end
	
	return boost
end
