int InputView::InitJNI() { JNIEnv* env = cocos2d::JniHelper::getEnv(); { const char* strClass = "com/razerzone/store/sdk/engine/cocos2d/InputView"; #if ENABLE_VERBOSE_LOGGING __android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "Searching for %s", strClass); #endif jclass localRef = cocos2d::JniHelper::getEnv()->FindClass(strClass); if (localRef) { #if ENABLE_VERBOSE_LOGGING __android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "Found %s", strClass); #endif _jcInputView = (jclass)env->NewGlobalRef(localRef); env->DeleteLocalRef(localRef); } else { __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "Failed to find %s", strClass); return JNI_ERR; } } JNIFind(); // setup native receiving remapped input { jint ret = env->RegisterNatives(_jcInputView, _nativeMethodTable, _nativeMethodTableSize); if (ret < 0) { __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "Failed to register native methods"); return JNI_ERR; } } { jint ret = env->RegisterNatives(_jcInputView, _nativeMethodTable2, _nativeMethodTableSize2); if (ret < 0) { __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "Failed to register native methods 2"); return JNI_ERR; } } for (int index = 0; index < MAX_CONTROLLERS; ++index) { _axis.push_back(std::map<int, float>()); _button.push_back(std::map<int, bool>()); _buttonDown.push_back(std::map<int, bool>()); _buttonUp.push_back(std::map<int, bool>()); _lastButtonDown.push_back(std::map<int, bool>()); _lastButtonUp.push_back(std::map<int, bool>()); } return JNI_OK; }
int OuyaInputView::InitJNI(JavaVM* jvm) { _jvm = jvm; JNIEnv* env; if (_jvm->GetEnv((void**) &env, JNI_VERSION_1_6) != JNI_OK) { __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "Failed to get JNI environment!"); return JNI_ERR; } { const char* strClass = "tv/ouya/sdk/OuyaInputView"; #if ENABLE_VERBOSE_LOGGING __android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "Searching for %s", strClass); #endif jclass localRef = env->FindClass(strClass); if (localRef) { #if ENABLE_VERBOSE_LOGGING __android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "Found %s", strClass); #endif _jcOuyaInputView = (jclass)env->NewGlobalRef(localRef); env->DeleteLocalRef(localRef); } else { __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "Failed to find %s", strClass); return JNI_ERR; } } JNIFind(); // setup native receiving remapped input { jint ret = env->RegisterNatives(_jcOuyaInputView, _nativeMethodTable, _nativeMethodTableSize); if (ret < 0) { __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "Failed to register native methods"); return JNI_ERR; } } { jint ret = env->RegisterNatives(_jcOuyaInputView, _nativeMethodTable2, _nativeMethodTableSize2); if (ret < 0) { __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "Failed to register native methods 2"); return JNI_ERR; } } for (int index = 0; index < MAX_CONTROLLERS; ++index) { _axis.push_back(std::map<int, float>()); _button.push_back(std::map<int, bool>()); _buttonDown.push_back(std::map<int, bool>()); _buttonUp.push_back(std::map<int, bool>()); } return JNI_OK; }