class fullscreenDpadSupported extends inkLogicController
{
	editable var m_targetPath_DpadUp : weak< inkWidget >;
	editable var m_targetPath_DpadDown : weak< inkWidget >;
	editable var m_targetPath_DpadLeft : weak< inkWidget >;
	editable var m_targetPath_DpadRight : weak< inkWidget >;

	protected event OnInitialize()
	{
		GetRootWidget().RegisterToCallback( 'OnRelease', this, 'OnRelease' );
	}

	public function SetDpadTargets( argLeft : weak< inkWidget >, argUp : weak< inkWidget >, argRight : weak< inkWidget >, argDown : weak< inkWidget > )
	{
		if( argUp )
		{
			m_targetPath_DpadUp = argUp;
		}
		if( argDown )
		{
			m_targetPath_DpadDown = argDown;
		}
		if( argLeft )
		{
			m_targetPath_DpadLeft = argLeft;
		}
		if( argRight )
		{
			m_targetPath_DpadRight = argRight;
		}
	}

	public function SetDpadTargetsInList( mainList : inkVerticalPanel )
	{
		var j : Int32;
		var numItems : Int32;
		var lastWidget : weak< inkWidget >;
		var currWidget : weak< inkWidget >;
		var currLogic : weak< inkButtonDpadSupportedController >;
		numItems = mainList.GetNumChildren();
		for( j = 0; j < numItems; j = j + 1 )
		{
			currWidget = mainList.GetWidget( j );
			currLogic = ( ( inkButtonDpadSupportedController )( currWidget.GetController() ) );
			currLogic.SetDpadUpTarget( ( ( j == 0 ) ? ( mainList.GetWidget( numItems - 1 ) ) : ( lastWidget ) ) );
			lastWidget = currWidget;
			currLogic.SetDpadDownTarget( ( ( j == ( numItems - 1 ) ) ? ( mainList.GetWidget( 0 ) ) : ( mainList.GetWidget( j + 1 ) ) ) );
		}
	}

	protected event OnRelease( e : inkPointerEvent )
	{
		var actionName : CName;
		var targetWidget : weak< inkWidget >;
		var currLogic : weak< inkButtonDpadSupportedController >;
		currLogic = ( ( inkButtonDpadSupportedController )( e.GetTarget().GetController() ) );
		if( e.IsAction( 'up_button' ) )
		{
			targetWidget = ( ( currLogic ) ? ( currLogic.m_targetPath_DpadUp ) : ( m_targetPath_DpadUp ) );
		}
		else if( e.IsAction( 'down_button' ) )
		{
			targetWidget = ( ( currLogic ) ? ( currLogic.m_targetPath_DpadDown ) : ( m_targetPath_DpadDown ) );
		}
		else if( e.IsAction( 'left_button' ) )
		{
			targetWidget = ( ( currLogic ) ? ( currLogic.m_targetPath_DpadLeft ) : ( m_targetPath_DpadLeft ) );
		}
		else if( actionName == 'right_button' )
		{
			targetWidget = ( ( currLogic ) ? ( currLogic.m_targetPath_DpadRight ) : ( m_targetPath_DpadRight ) );
		}
		if( targetWidget )
		{
			SetCursorOverWidget( targetWidget );
		}
	}

}

