Пример #1
0
void OuyaPlugin_asyncOuyaRequestReceipts(s3eCallback onSuccess, s3eCallback onFailure, s3eCallback onCancel)
{
	IwTrace(ODK, ("ODK_platform: OuyaPlugin_asyncOuyaRequestReceipts"));

	OuyaSDK::CallbackSingleton::GetInstance()->m_callbacksRequestReceipts->RegisterCallbacks(onSuccess, onFailure, onCancel);

	g_pluginOuya.AsyncOuyaRequestReceipts();
}
Пример #2
0
void OuyaPlugin_asyncOuyaFetchGamerUUID(s3eCallback onSuccess, s3eCallback onFailure, s3eCallback onCancel)
{
	IwTrace(ODK, ("ODK_platform: OuyaPlugin_asyncOuyaFetchGamerUUID"));

	OuyaSDK::CallbackSingleton::GetInstance()->m_callbacksFetchGamerUUID->RegisterCallbacks(onSuccess, onFailure, onCancel);

    g_pluginOuya.AsyncOuyaFetchGamerUUID();
}
Пример #3
0
void OuyaPlugin_asyncSetDeveloperId(const char* developerId)
{
	std::string buffer = "OuyaPlugin_asyncSetDeveloperId developerId=";
	buffer.append(developerId);
	IwTrace(ODK, (buffer.c_str()));

    g_pluginOuya.AsyncSetDeveloperId(developerId);
}
Пример #4
0
void OuyaPlugin_initOuyaPlugin(const char* jsonData, s3eCallback onSuccess, s3eCallback onFailure)
{
    IwTrace(ODK, ("OuyaPlugin_initOuyaPlugin"));

    OuyaSDK::CallbackSingleton::GetInstance()->m_callbacksInitOuyaPlugin->RegisterCallbacks(onSuccess, onFailure);

    g_pluginOuya.AsyncInitOuyaPlugin(jsonData);
}
Пример #5
0
void OuyaPlugin_asyncOuyaRequestPurchase(const char* purchasable, s3eCallback onSuccess, s3eCallback onFailure, s3eCallback onCancel)
{
	IwTrace(ODK, ("ODK_platform: OuyaPlugin_asyncOuyaRequestPurchase"));

	std::string msg = "OuyaPlugin_asyncOuyaRequestPurchase: purchasable=";
	msg.append(purchasable);
	IwTrace(ODK, (msg.c_str()));

	OuyaSDK::CallbackSingleton::GetInstance()->m_callbacksRequestPurchase->RegisterCallbacks(onSuccess, onFailure, onCancel);

	g_pluginOuya.AsyncOuyaRequestPurchase(purchasable);
}
Пример #6
0
void OuyaPlugin_asyncOuyaRequestProducts(const char* productsJson, s3eCallback onSuccess, s3eCallback onFailure, s3eCallback onCancel)
{
	IwTrace(ODK, ("ODK_platform: OuyaPlugin_asyncOuyaRequestProducts"));

	std::string msg = "OuyaPlugin_asyncOuyaRequestProducts: productsJson=";
	msg.append(productsJson);
	IwTrace(ODK, (msg.c_str()));

	//convert JSON to product id array

	// Parse example data
	JSONValue* value = JSON::Parse(productsJson);

	if (value == NULL)
	{
		IwTrace(ODK, ("Parsing JSON Failed"));
		return;
	}

	if (!value->IsArray())
	{
		IwTrace(ODK, ("Parsing JSON Failed: Not an array"));
		return;
	}

	// Retrieve the main object
	JSONArray data = value->AsArray();

	std::vector<std::string> productIds;

	for (unsigned int i = 0; i < data.size(); i++)
	{
		if (data[i]->IsString())
		{
			const std::wstring wstr = data[i]->AsString();

			std::string productId( wstr.begin(), wstr.end() );

			productIds.push_back(productId);
		}
	}

	OuyaSDK::CallbackSingleton::GetInstance()->m_callbacksRequestProducts->RegisterCallbacks(onSuccess, onFailure, onCancel);

	g_pluginOuya.AsyncOuyaRequestProducts(productIds);
}
Пример #7
0
void OuyaPlugin_asyncOuyaRequestProducts(const char* productsJson, s3eCallback onSuccess, s3eCallback onFailure, s3eCallback onCancel)
{
    IwTrace(ODK, ("ODK_platform: OuyaPlugin_asyncOuyaRequestProducts"));

    std::string msg = "OuyaPlugin_asyncOuyaRequestProducts: productsJson=";
    msg.append(productsJson);
    IwTrace(ODK, (msg.c_str()));

    //convert JSON to product id array
    JSONArray jsonArray = JSONArray(productsJson);

    std::vector<std::string> productIds;

    for (int i = 0; i < jsonArray.length(); i++)
    {
        std::string productId = jsonArray.getString(i);
        productIds.push_back(productId);
    }

    OuyaSDK::CallbackSingleton::GetInstance()->m_callbacksRequestProducts->RegisterCallbacks(onSuccess, onFailure, onCancel);

    g_pluginOuya.AsyncOuyaRequestProducts(productIds);
}
Пример #8
0
s3eResult ODKInit_platform()
{
    // Get the environment from the pointer
    JNIEnv* env = s3eEdkJNIGetEnv();

    jobject obj = NULL;
	jfieldID field = NULL;

    // Get the extension class
    jclass cls = s3eEdkAndroidFindClass("com/ODK/ODK");
    if (!cls)
        goto fail;

	IwTrace(ODK, ("ODK init Found: com/ODK/ODK"));

    field = env->GetStaticFieldID(cls, "m_Activity", "Lcom/ODK/ODK;");
    if (!field)
        goto fail;

	IwTrace(ODK, ("ODK init Found: GetStaticFieldID"));

    obj = env->GetStaticObjectField(cls,field);
	if (!obj)
        goto fail;

	IwTrace(ODK, ("ODK init Found: GetStaticObjectField "));
/*
    // Get its constructor
    cons = env->GetMethodID(cls, "<init>", "()V");
    if (!cons)
        goto fail;

    // Construct the java class
    obj = env->NewObject(cls, cons);
    if (!obj)
        goto fail;
*/
    // Get all the extension methods
    g_OuyaController_startOfFrame = env->GetMethodID(cls, "OuyaController_startOfFrame", "()V");
    if (!g_OuyaController_startOfFrame)
        goto fail;

    g_OuyaController_selectControllerByPlayer = env->GetMethodID(cls, "OuyaController_selectControllerByPlayer", "(I)Z");
    if (!g_OuyaController_selectControllerByPlayer)
        goto fail;

    g_OuyaController_selectControllerByDeviceID = env->GetMethodID(cls, "OuyaController_selectControllerByDeviceID", "(I)Z");
    if (!g_OuyaController_selectControllerByDeviceID)
        goto fail;

    g_OuyaController_getAxisValue = env->GetMethodID(cls, "OuyaController_getAxisValue", "(I)I");
    if (!g_OuyaController_getAxisValue)
        goto fail;

    g_OuyaController_getButton = env->GetMethodID(cls, "OuyaController_getButton", "(I)Z");
    if (!g_OuyaController_getButton)
        goto fail;

    g_OuyaController_buttonPressedThisFrame = env->GetMethodID(cls, "OuyaController_buttonPressedThisFrame", "(I)Z");
    if (!g_OuyaController_buttonPressedThisFrame)
        goto fail;

    g_OuyaController_buttonReleasedThisFrame = env->GetMethodID(cls, "OuyaController_buttonReleasedThisFrame", "(I)Z");
    if (!g_OuyaController_buttonReleasedThisFrame)
        goto fail;

    g_OuyaController_buttonChangedThisFrame = env->GetMethodID(cls, "OuyaController_buttonChangedThisFrame", "(I)Z");
    if (!g_OuyaController_buttonChangedThisFrame)
        goto fail;

    g_OuyaController_getPlayerNum = env->GetMethodID(cls, "OuyaController_getPlayerNum", "()I");
    if (!g_OuyaController_getPlayerNum)
        goto fail;



    IwTrace(ODK, ("ODK init success"));
    g_Obj = env->NewGlobalRef(obj);
    env->DeleteLocalRef(obj);
    env->DeleteGlobalRef(cls);

    // cache class references
    g_pluginOuya.CacheClasses(env);

    // Add any platform-specific initialisation code here
    return S3E_RESULT_SUCCESS;

fail:
    jthrowable exc = env->ExceptionOccurred();
    if (exc)
    {
        env->ExceptionDescribe();
        env->ExceptionClear();
        IwTrace(ODK, ("One or more java methods could not be found"));
    }
    return S3E_RESULT_ERROR;

}
Пример #9
0
s3eResult ODKInit_platform()
{
    __android_log_print(ANDROID_LOG_INFO, LOG_TAG, "Marmalade Plugin Native Version: 0.0.1");
    IwTrace(ODK, ("Marmalade Plugin Native Version: 0.0.1"));


    // Get the environment from the pointer
    JNIEnv* env = s3eEdkJNIGetEnv();

    for (int index = 0; index < MAX_CONTROLLERS; ++index)
    {
        g_axis.push_back(std::map<int, float>());
        g_button.push_back(std::map<int, bool>());
        g_buttonDown.push_back(std::map<int, bool>());
        g_buttonUp.push_back(std::map<int, bool>());
        g_lastButtonDown.push_back(std::map<int, bool>());
        g_lastButtonUp.push_back(std::map<int, bool>());
    }

    __android_log_print(ANDROID_LOG_INFO, LOG_TAG, "Find OuyaInputView...");
    jclass clazz = env->FindClass("tv/ouya/sdk/marmalade/OuyaInputView");
    if (clazz)
    {
        jint ret = env->RegisterNatives(clazz, method_table, method_table_size);
        ret = env->RegisterNatives(clazz, method_table2, method_table_size2);

        const char* strField = "sNativeInitialized";
        jfieldID fieldNativeInitialized = env->GetStaticFieldID(clazz, strField, "Z");
        env->SetStaticBooleanField(clazz, fieldNativeInitialized, true);
        env->DeleteLocalRef(clazz);
        __android_log_print(ANDROID_LOG_INFO, LOG_TAG, "Loaded Native Plugin: 003");
    }
    else
    {
        IwTrace(ODK, ("*********************Failed to find OuyaInputView"));
        goto fail;
    }

    if (JSONArray::InitJNI(env) == JNI_ERR)
    {
        goto fail;
    }

    if (JSONObject::InitJNI(env) == JNI_ERR)
    {
        goto fail;
    }

    if (OuyaController::InitJNI(env) == JNI_ERR)
    {
        goto fail;
    }

    // cache class references
    g_pluginOuya.CacheClasses(env);

    // Add any platform-specific initialization code here
    return S3E_RESULT_SUCCESS;

fail:
    jthrowable exc = env->ExceptionOccurred();
    if (exc)
    {
        env->ExceptionDescribe();
        env->ExceptionClear();
        IwTrace(ODK, ("One or more java methods could not be found"));
    }
    return S3E_RESULT_ERROR;

}