jint JNI_OnLoad(JavaVM* vm, void* reserved) { JNIEnv *env; NVThreadInit(vm); DEBUG("JNI_OnLoad called"); if (vm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) { DEBUG("Failed to get the environment using GetEnv()"); return -1; } JNINativeMethod methods[] = { { "init", "()Z", (void *) NVEventJNIInit }, { "touchEvent", "(IIILandroid/view/MotionEvent;)Z", (void *) NVEventTouchEvent }, { "multiTouchEvent", "(IIIIIILandroid/view/MotionEvent;)Z", (void *) NVEventMultiTouchEvent }, { "keyEvent", "(IIILandroid/view/KeyEvent;)Z", (void *) NVEventKeyEvent }, { "accelerometerEvent", "(FFF)Z", (void *) NVEventAccelerometerEvent }, { "cleanup", "()V", (void *) NVEventCleanup }, // TODO TBD - this should be done in NVTimeInit(), but we use a different // class than most apps. Need to clean this up, as it is fragile w.r.t. // changes in nv_time { "nvAcquireTimeExtension", "()V", (void *) nvAcquireTimeExtensionJNI }, { "nvGetSystemTime", "()J", (void *) nvGetSystemTimeJNI }, { "setWindowSize", "(II)V", (void *) NVEventSetWindowSize }, { "quitAndWait", "()V", (void *) NVEventQuitAndWait }, { "postCleanup", "()V", (void *) NVEventPostCleanup }, { "resumeEvent", "()V", (void *) NVEventResumeEvent }, { "pauseEvent", "()V", (void *) NVEventPauseEvent }, }; jclass k; k = (env)->FindClass ("com/nvidia/devtech/NvEventQueueActivity"); (env)->RegisterNatives(k, methods, dimof(methods)); s_initEGL = env->GetMethodID(k, "InitEGLAndGLES2", "()Z"); s_finish = env->GetMethodID(k, "finish", "()V"); s_swap = env->GetMethodID(k, "swapBuffers", "()Z"); s_makeCurrent = env->GetMethodID(k, "makeCurrent", "()Z"); s_unMakeCurrent = env->GetMethodID(k, "unMakeCurrent", "()Z"); #ifdef _TIMFUDGE s_width = env->GetMethodID(k, "getSurfaceWidth", "()I"); s_height = env->GetMethodID(k, "getSurfaceHeight", "()I"); #endif return JNI_VERSION_1_4; }
void InitNVEvent(JavaVM* vm) { JNIEnv *env; NVThreadInit(vm); NVDEBUG("InitNVEvent called"); if (vm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) { NVDEBUG("Failed to get the environment using GetEnv()"); return; } JNINativeMethod methods[] = { { "onCreateNative", "()Z", (void *) onCreateNative }, { "onStartNative", "()Z", (void *) onStartNative }, { "onRestartNative", "()Z", (void *) onRestartNative }, { "onResumeNative", "()Z", (void *) onResumeNative }, { "onSurfaceCreatedNative", "(III)Z", (void *) onSurfaceCreatedNative }, { "onFocusChangedNative", "(Z)Z", (void *) onFocusChangedNative }, { "onSurfaceChangedNative", "(III)Z", (void *) onSurfaceChangedNative }, { "onSurfaceDestroyedNative", "()Z", (void *) onSurfaceDestroyedNative }, { "onPauseNative", "()Z", (void *) onPauseNative }, { "onStopNative", "()Z", (void *) onStopNative }, { "onDestroyNative", "()Z", (void *) onDestroyNative }, { "multiTouchEvent", "(IZZIIIILandroid/view/MotionEvent;)Z", (void *) NVEventMultiTouchEvent }/*, { "onLongClickNative", "(II)Z", (void *) NVEventLongClickEvent }*/ }; jclass k; k = (env)->FindClass ("com/nvidia/devtech/NvEventQueueFragment"); (env)->RegisterNatives(k, methods, dimof(methods)); s_InitEGL.QueryID(env, k); s_CleanupEGL.QueryID(env, k); s_CreateSurfaceEGL.QueryID(env, k); s_DestroySurfaceEGL.QueryID(env, k); s_SwapBuffersEGL.QueryID(env, k); s_BindSurfaceAndContextEGL.QueryID(env, k); s_UnbindSurfaceAndContextEGL.QueryID(env, k); s_GetErrorEGL.QueryID(env, k); s_finish.QueryID(env, k); s_ReportUnsupported.QueryID(env, k); s_OnRenderingInitialized.QueryID(env, k); }