示例#1
0
void Java_com_oculus_vrappframework_VrActivity_nativePopup( JNIEnv *jni, jclass clazz,
		jlong appPtr, jint width, jint height, jfloat seconds )
{
	LOG( "%p nativePopup", (void *)appPtr );
	OVR::AppLocal * appLocal = (OVR::AppLocal *)appPtr;
	appLocal->GetMessageQueue().PostPrintf( "popup %i %i %f", width, height, seconds );
}
示例#2
0
void Java_com_oculus_vrappframework_VrApp_nativeOnResume( JNIEnv *jni, jclass clazz,
		jlong appPtr )
{
	LOG( "%p nativeResume", (void *)appPtr );
	OVR::AppLocal * appLocal = (OVR::AppLocal *)appPtr;
	appLocal->GetMessageQueue().SendPrintf( "resume " );
}
示例#3
0
void Java_com_oculus_vrappframework_VrActivity_nativeTouch( JNIEnv *jni, jclass clazz,
		jlong appPtr, jint action, jfloat x, jfloat y )
{
	OVR::AppLocal * appLocal = (OVR::AppLocal *)appPtr;
	// Suspend input until EnteredVrMode( INTENT_LAUNCH ) has finished to avoid overflowing the message queue on long loads.
	if ( appLocal->IntentType != OVR::INTENT_LAUNCH )
	{
		appLocal->GetMessageQueue().PostPrintfIfSpaceAvailable( MIN_SLOTS_AVAILABLE_FOR_INPUT, "touch %i %f %f", action, x, y );
	}
}
示例#4
0
void Java_com_oculus_vrappframework_VrActivity_nativeJoypadAxis( JNIEnv *jni, jclass clazz,
		jlong appPtr, jfloat lx, jfloat ly, jfloat rx, jfloat ry )
{
	OVR::AppLocal * appLocal = (OVR::AppLocal *)appPtr;
	// Suspend input until OneTimeInit() has finished to avoid overflowing the message queue on long loads.
	if ( appLocal->OneTimeInitCalled )
	{
		appLocal->GetMessageQueue().PostPrintfIfSpaceAvailable( MIN_SLOTS_AVAILABLE_FOR_INPUT, "joy %f %f %f %f", lx, ly, rx, ry );
	}
}
示例#5
0
void Java_com_oculus_vrappframework_VrActivity_nativeKeyEvent( JNIEnv *jni, jclass clazz,
		jlong appPtr, jint key, jboolean down, jint repeatCount )
{
	OVR::AppLocal * appLocal = (OVR::AppLocal *)appPtr;
	// Suspend input until OneTimeInit() has finished to avoid overflowing the message queue on long loads.
	if ( appLocal->OneTimeInitCalled )
	{
		OVR::ovrKeyCode keyCode = OVR::OSKeyToKeyCode( key );
		appLocal->GetMessageQueue().PostPrintfIfSpaceAvailable( MIN_SLOTS_AVAILABLE_FOR_INPUT, "key %i %i %i", keyCode, down, repeatCount );
	}
}
示例#6
0
void Java_com_oculus_vrappframework_VrActivity_nativeKeyEvent( JNIEnv *jni, jclass clazz,
		jlong appPtr, jint key, jboolean down, jint repeatCount )
{
	OVR::AppLocal * appLocal = (OVR::AppLocal *)appPtr;
	// Suspend input until EnteredVrMode( INTENT_LAUNCH ) has finished to avoid overflowing the message queue on long loads.
	if ( appLocal->IntentType != OVR::INTENT_LAUNCH )
	{
		OVR::ovrKeyCode keyCode = OVR::OSKeyToKeyCode( key );
		//LOG( "nativeKeyEvent: key = %i, keyCode = %i, down = %s, repeatCount = %i", key, keyCode, down ? "true" : "false", repeatCount );
		appLocal->GetMessageQueue().PostPrintfIfSpaceAvailable( MIN_SLOTS_AVAILABLE_FOR_INPUT, "key %i %i %i", keyCode, down, repeatCount );
	}
}
示例#7
0
void Java_com_oculus_vrappframework_VrApp_nativeSurfaceDestroyed( JNIEnv *jni, jclass clazz,
		jlong appPtr, jobject surface )
{
	LOG( "%p nativeSurfaceDestroyed()", (void *)appPtr );

	OVR::AppLocal * appLocal = (OVR::AppLocal *)appPtr;

	appLocal->GetMessageQueue().SendPrintf( "surfaceDestroyed " );
	LOG( "    ANativeWindow_release( %p )", appLocal->pendingNativeWindow );
	ANativeWindow_release( appLocal->pendingNativeWindow );
	appLocal->pendingNativeWindow = NULL;
}
示例#8
0
void Java_com_oculus_vrappframework_VrApp_nativeSurfaceChanged( JNIEnv *jni, jclass clazz,
		jlong appPtr, jobject surface )
{
	LOG( "%p nativeSurfaceChanged( %p )", (void *)appPtr, surface );

	OVR::AppLocal * appLocal = (OVR::AppLocal *)appPtr;

	ANativeWindow * newNativeWindow = ANativeWindow_fromSurface( jni, surface );
	if ( ANativeWindow_getWidth( newNativeWindow ) < ANativeWindow_getHeight( newNativeWindow ) )
	{
		// An app that is relaunched after pressing the home button gets an initial surface with
		// the wrong orientation even though android:screenOrientation="landscape" is set in the
		// manifest. The choreographer callback will also never be called for this surface because
		// the surface is immediately replaced with a new surface with the correct orientation.
		WARN( "        Surface not in landscape mode!" );
	}

	if ( newNativeWindow != appLocal->pendingNativeWindow )
	{
		if ( appLocal->pendingNativeWindow != NULL )
		{
			appLocal->GetMessageQueue().SendPrintf( "surfaceDestroyed " );
			LOG( "    ANativeWindow_release( pendingNativeWindow )" );
			ANativeWindow_release( appLocal->pendingNativeWindow );
			appLocal->pendingNativeWindow = NULL;
		}
		if ( newNativeWindow != NULL )
		{
			LOG( "    pendingNativeWindow = ANativeWindow_fromSurface( jni, surface )" );
			appLocal->pendingNativeWindow = newNativeWindow;
			appLocal->GetMessageQueue().SendPrintf( "surfaceCreated " );
		}
	}
	else if ( newNativeWindow != NULL )
	{
		ANativeWindow_release( newNativeWindow );
	}
}
示例#9
0
void Java_com_oculus_vrappframework_VrActivity_nativeNewIntent( JNIEnv *jni, jclass clazz,
		jlong appPtr, jstring fromPackageName, jstring command, jstring uriString )
{
	LOG( "%p nativeNewIntent", (void *)appPtr );
	JavaUTFChars utfPackageName( jni, fromPackageName );
	JavaUTFChars utfUri( jni, uriString );
	JavaUTFChars utfJson( jni, command );

	char intentMessage[4096];
	ComposeIntentMessage( utfPackageName.ToStr(), utfUri.ToStr(), utfJson.ToStr(), 
			intentMessage, sizeof( intentMessage ) );
	LOG( "nativeNewIntent: %s", intentMessage );
	OVR::AppLocal * appLocal = (OVR::AppLocal *)appPtr;
	appLocal->GetMessageQueue().PostString( intentMessage );
}