void MoviePlayerView::UpdateUI( const VrFrame & vrFrame )
{
	// only show cursor when uiActive
	if ( uiActive )
	{
		const Matrix4f screenModel = Cinema.app->GetActivityPanel().Matrix;

		// -1 to 1 range on panelMatrix, returns -2,-2 if looking away from the panel
		const Vector2f cursor = GazeCoordinatesOnPanel( Cinema.SceneMgr.Scene.CenterViewMatrix(), screenModel, Cinema.app->GetActivityPanel().AlternateGazeCheck );

		const bool press = ( vrFrame.Input.buttonPressed & ( BUTTON_A | BUTTON_TOUCH ) ) != 0;
		const bool release = ( ( vrFrame.Input.buttonReleased & ( BUTTON_A | BUTTON_TOUCH ) ) != 0 );

		ePlaybackControlsEvent uiButtonPressed = ( ePlaybackControlsEvent )Native::GazeCursor( Cinema.app, (cursor.x * 0.5 + 0.5) * Cinema.app->GetActivityPanel().Width,
			(0.5 - cursor.y * 0.5) * Cinema.app->GetActivityPanel().Height, press, release, SeekSpeed );

		// don't register a button press if we just finished a swipe
		if ( !( vrFrame.Input.buttonState & BUTTON_TOUCH_WAS_SWIPE ) )
		{
			switch( uiButtonPressed )
			{
			case UI_RW_PRESSED :
				// rewind
				Cinema.app->PlaySound( "touch_up" );
				if ( SeekSpeed == 0 )
				{
					Native::PauseMovie( Cinema.app );
					PlaybackPos = Native::GetPosition( Cinema.app );
				}

				SeekSpeed--;
				if ( ( SeekSpeed == 0 ) || ( SeekSpeed < -MaxSeekSpeed ) )
				{
					SeekSpeed = 0;
					Native::ResumeMovie( Cinema.app );
				}
				break;

			case UI_PLAY_PRESSED :
				// play/pause
				Cinema.app->PlaySound( "touch_up" );
				Native::TogglePlaying( Cinema.app );
				SeekSpeed = 0;
				break;

			case UI_FF_PRESSED :
				// fast forward
				Cinema.app->PlaySound( "touch_up" );
				if ( SeekSpeed == 0 )
				{
					Native::PauseMovie( Cinema.app );
					PlaybackPos = Native::GetPosition( Cinema.app );
				}

				SeekSpeed++;
				if ( ( SeekSpeed == 0 ) || ( SeekSpeed > MaxSeekSpeed ) )
				{
					SeekSpeed = 0;
					Native::ResumeMovie( Cinema.app );
				}
				break;

			case UI_CAROUSEL_PRESSED :
				// movie select
				Cinema.app->PlaySound( "touch_up" );
				Cinema.MovieSelection( false );
				break;

			case UI_CLOSE_UI_PRESSED :
				Cinema.app->PlaySound( "touch_up" );
				HideUI();
				Native::ResumeMovie( Cinema.app );
				break;

			case UI_USER_TIMEOUT :
				HideUI();
				Native::ResumeMovie( Cinema.app );
				break;

			case UI_SEEK_PRESSED :
				PlaybackPos = Native::GetPosition( Cinema.app );
				NextSeekTime = TimeInSeconds() + 0.25;
				break;

			default:
			case UI_NO_EVENT :
				break;
			}
		}

		float cursorDistance = FLT_MAX;
		eGazeCursorStateType cursorState = CURSOR_STATE_NORMAL;

		if ( InsideUnit( cursor ) )
		{
			// FIXME: Project onto Free Screen
			const Vector3f pos = screenModel.Transform( Vector3f( cursor.x, cursor.y, 0.0f ) );
			cursorDistance = ( pos - Cinema.SceneMgr.Scene.CenterViewMatrix().GetTranslation() ).Length();
		}
		Cinema.app->GetGazeCursor().UpdateForUser( GazeUserId, cursorDistance, cursorState );
	}
}
示例#2
0
void MoviePlayerView::CheckInput( const VrFrame & vrFrame )
{
	if ( !uiActive && !RepositionScreen )
	{
		if ( ( vrFrame.Input.buttonPressed & BUTTON_A ) || ( ( vrFrame.Input.buttonReleased & BUTTON_TOUCH ) && !( vrFrame.Input.buttonState & BUTTON_TOUCH_WAS_SWIPE ) ) )
		{
			// open ui if it's not visible
			Cinema.app->PlaySound( "touch_up" );
			ShowUI();

			// ignore button A or touchpad until release so we don't close the UI immediately after opening it
			UIOpened = true;
		}
	}

	if ( vrFrame.Input.buttonPressed & ( BUTTON_DPAD_LEFT | BUTTON_SWIPE_BACK ) )
	{
		if ( ( vrFrame.Input.buttonPressed & BUTTON_DPAD_LEFT ) || !GazeTimer.IsFocused() )
		{
			ShowUI();
			if ( SeekSpeed == 0 )
			{
				PauseMovie();
			}

			SeekSpeed--;
			if ( ( SeekSpeed == 0 ) || ( SeekSpeed < -MaxSeekSpeed ) )
			{
				SeekSpeed = 0;
				PlayMovie();
			}
			SetSeekIcon( SeekSpeed );

			Cinema.app->PlaySound( "touch_up" );
		}
	}

	if ( vrFrame.Input.buttonPressed & ( BUTTON_DPAD_RIGHT | BUTTON_SWIPE_FORWARD ) )
	{
		if ( ( vrFrame.Input.buttonPressed & BUTTON_DPAD_RIGHT ) || !GazeTimer.IsFocused() )
		{
			ShowUI();
			if ( SeekSpeed == 0 )
			{
				PauseMovie();
			}

			SeekSpeed++;
			if ( ( SeekSpeed == 0 ) || ( SeekSpeed > MaxSeekSpeed ) )
			{
				SeekSpeed = 0;
				PlayMovie();
			}
			SetSeekIcon( SeekSpeed );

			Cinema.app->PlaySound( "touch_up" );
		}
	}

	if ( Cinema.SceneMgr.FreeScreenActive )
	{
		const Vector2f screenCursor = GazeCoordinatesOnScreen( Cinema.SceneMgr.Scene.CenterViewMatrix(), Cinema.SceneMgr.ScreenMatrix() );
		bool onscreen = false;
		if ( InsideUnit( screenCursor ) )
		{
			onscreen = true;
		}
		else if ( uiActive )
		{
			onscreen = GazeTimer.IsFocused();
		}

		if ( !onscreen )
		{
			// outside of screen, so show reposition message
			const double now = ovr_GetTimeInSeconds();
			float alpha = MoveScreenAlpha.Value( now );
			if ( alpha > 0.0f )
			{
				MoveScreenLabel.SetVisible( true );
				MoveScreenLabel.SetTextColor( Vector4f( alpha ) );
			}

			if ( vrFrame.Input.buttonPressed & ( BUTTON_A | BUTTON_TOUCH ) )
			{
				RepositionScreen = true;
			}
		}
		else
		{
			// onscreen, so hide message
			const double now = ovr_GetTimeInSeconds();
			MoveScreenAlpha.Set( now, -1.0f, now + 1.0f, 1.0f );
			MoveScreenLabel.SetVisible( false );
		}
	}

	// while we're holding down the button or touchpad, reposition screen
	if ( RepositionScreen )
	{
		if ( vrFrame.Input.buttonState & ( BUTTON_A | BUTTON_TOUCH ) )
		{
			Cinema.SceneMgr.PutScreenInFront();
		}
		else
		{
			RepositionScreen = false;
		}
	}

	if ( vrFrame.Input.buttonPressed & BUTTON_START )
	{
		TogglePlayback();
	}

	if ( vrFrame.Input.buttonPressed & BUTTON_SELECT )
	{
		// movie select
		Cinema.app->PlaySound( "touch_up" );
		Cinema.MovieSelection( false );
	}

	if ( vrFrame.Input.buttonPressed & BUTTON_B )
	{
		if ( !uiActive )
		{
			BackPressed();
		}
		else
		{
			LOG( "User pressed button 2" );
			Cinema.app->PlaySound( "touch_up" );
			HideUI();
			PlayMovie();
		}
	}
}
void MoviePlayerView::CheckInput( const VrFrame & vrFrame )
{
	if ( !uiActive && !RepositionScreen )
	{
		if ( ( vrFrame.Input.buttonPressed & BUTTON_A ) || ( ( vrFrame.Input.buttonReleased & BUTTON_TOUCH ) && !( vrFrame.Input.buttonState & BUTTON_TOUCH_WAS_SWIPE ) ) )
		{
			// open ui if it's not visible
			Cinema.app->PlaySound( "touch_up" );
			ShowUI();
		}
	}

	if ( vrFrame.Input.buttonPressed & ( BUTTON_DPAD_LEFT | BUTTON_SWIPE_BACK ) )
	{
		if ( ( vrFrame.Input.buttonPressed & BUTTON_DPAD_LEFT ) || !CursorInsidePlaybackControls() )
		{
			ShowUI();
			if ( SeekSpeed == 0 )
			{
				Native::PauseMovie( Cinema.app );
				PlaybackPos = Native::GetPosition( Cinema.app );
			}

			SeekSpeed--;
			if ( ( SeekSpeed == 0 ) || ( SeekSpeed < -MaxSeekSpeed ) )
			{
				SeekSpeed = 0;
				Native::ResumeMovie( Cinema.app );
			}

			Cinema.app->PlaySound( "touch_up" );
		}
	}

	if ( vrFrame.Input.buttonPressed & ( BUTTON_DPAD_RIGHT | BUTTON_SWIPE_FORWARD ) )
	{
		if ( ( vrFrame.Input.buttonPressed & BUTTON_DPAD_RIGHT ) || !CursorInsidePlaybackControls() )
		{
			ShowUI();
			if ( SeekSpeed == 0 )
			{
				Native::PauseMovie( Cinema.app );
				PlaybackPos = Native::GetPosition( Cinema.app );
			}

			SeekSpeed++;
			if ( ( SeekSpeed == 0 ) || ( SeekSpeed > MaxSeekSpeed ) )
			{
				SeekSpeed = 0;
				Native::ResumeMovie( Cinema.app );
			}

			Cinema.app->PlaySound( "touch_up" );
		}
	}

	if ( Cinema.SceneMgr.FreeScreenActive )
	{
		const Vector2f screenCursor = GazeCoordinatesOnPanel( Cinema.SceneMgr.Scene.CenterViewMatrix(), Cinema.SceneMgr.FreeScreenMatrix(), Cinema.app->GetActivityPanel().AlternateGazeCheck  );
		if ( !InsideUnit( screenCursor ) && !CursorInsidePlaybackControls() )
		{
			// outside of screen, so show reposition message
			const double now = TimeInSeconds();
			float alpha = MoveScreenAlpha.Value( now );
			if ( alpha > 0.0f )
			{
				MoveScreenObj->RemoveFlags( VRMENUOBJECT_DONT_RENDER );
				MoveScreenObj->SetTextColor( Vector4f( alpha ) );
			}

			if ( vrFrame.Input.buttonPressed & ( BUTTON_A | BUTTON_TOUCH ) )
			{
				RepositionScreen = true;
			}
		}
		else
		{
			// onscreen, so hide message
			const double now = TimeInSeconds();
			MoveScreenAlpha.Set( now, -1.0f, now + 1.0f, 1.0f );
			MoveScreenObj->AddFlags( VRMENUOBJECT_DONT_RENDER );
		}
	}

	// while we're holding down the button or touchpad, reposition screen
	if ( RepositionScreen )
	{
		if ( vrFrame.Input.buttonState & ( BUTTON_A | BUTTON_TOUCH ) )
		{
			Cinema.SceneMgr.PutScreenInFront();
		}
		else
		{
			RepositionScreen = false;
		}
	}

	if ( vrFrame.Input.buttonPressed & BUTTON_START )
	{
		Native::TogglePlaying( Cinema.app );
		SeekSpeed = 0;
	}

	if ( vrFrame.Input.buttonPressed & BUTTON_SELECT )
	{
		// movie select
		Cinema.app->PlaySound( "touch_up" );
		Cinema.MovieSelection( false );
	}

	if ( vrFrame.Input.buttonPressed & BUTTON_B )
	{
		if ( !uiActive )
		{
			BackPressed();
		}
		else
		{
			Cinema.app->PlaySound( "touch_up" );
			HideUI();
			Native::ResumeMovie( Cinema.app );
		}
	}
}