コード例 #1
0
	~GGreystripe()
	{
		JNIEnv *env = g_getJNIEnv();

		env->CallStaticVoidMethod(cls_, env->GetStaticMethodID(cls_, "cleanup", "()V"));

		env->DeleteGlobalRef(cls_);

		gevent_removeEventsWithGid(gid_);
	}
コード例 #2
0
ファイル: platform-android.cpp プロジェクト: dreiko65/gideros
void g_setFps(int fps)
{
    s_fps = fps;

	JNIEnv *env = g_getJNIEnv();
	jclass localRefCls = env->FindClass("com/giderosmobile/android/player/GiderosApplication");
	jmethodID setFpsID = env->GetStaticMethodID(localRefCls, "setFps", "(I)V");
	env->CallStaticVoidMethod(localRefCls, setFpsID, (jint)fps);
	env->DeleteLocalRef(localRefCls);
}
コード例 #3
0
ファイル: ginput-android.cpp プロジェクト: jdbcdev/gideros
    bool isGyroscopeAvailable()
    {
		JNIEnv *env = g_getJNIEnv();

		jclass cls = env->FindClass("com/giderosmobile/android/player/GiderosApplication");
		jboolean result = env->CallStaticBooleanMethod(cls, env->GetStaticMethodID(cls, "isGyroscopeAvailable_s", "()Z"));
		env->DeleteLocalRef(cls);
		
		return result;
    }
コード例 #4
0
ファイル: ggooglebilling.cpp プロジェクト: Nlcke/gideros
	void onRestoreTransactionsResponse(jint responseCode)
	{
		JNIEnv *env = g_getJNIEnv();

		ggooglebilling_RestoreTransactionsCompleteEvent *event = (ggooglebilling_RestoreTransactionsCompleteEvent*)malloc(sizeof(ggooglebilling_RestoreTransactionsCompleteEvent));
		
		event->responseCode = responseCode;
		
		gevent_EnqueueEvent(gid_, callback_s, GGOOGLEBILLING_RESTORE_TRANSACTIONS_COMPLETE_EVENT, event, 1, this);
	}
コード例 #5
0
	int mapGetInt(const char *str, jobject jsubobj)
	{
		JNIEnv *env = g_getJNIEnv();
		//get value
		jstring jStr = env->NewStringUTF(str);
		int ret = (int)env->CallIntMethod(jsubobj, env->GetMethodID(clsBundle, "getInt", "(Ljava/lang/String;)I"), jStr);
		env->DeleteLocalRef(jStr);
		
		return ret;
	}
コード例 #6
0
	const char *getText()
	{	
		JNIEnv *env = g_getJNIEnv();
		
		jstring jtext = (jstring)env->CallObjectMethod(obj_, getTextId_);
		const char *text = env->GetStringUTFChars(jtext, NULL);
		textBuffer_ = text;
		env->ReleaseStringUTFChars(jtext, text);

		return textBuffer_.c_str();
	}
コード例 #7
0
void openUrl(const char *url)
{
	JNIEnv *env = g_getJNIEnv();
	
	jclass localRefCls = env->FindClass("com/giderosmobile/android/player/GiderosApplication");
	jmethodID openUrlID = env->GetStaticMethodID(localRefCls, "openUrl", "(Ljava/lang/String;)V");
	jstring jurl = env->NewStringUTF(url);
	env->CallStaticVoidMethod(localRefCls, openUrlID, jurl);
	env->DeleteLocalRef(jurl);
	env->DeleteLocalRef(localRefCls);
}
コード例 #8
0
	TextInputBox(const char *title,
				 const char *message,
				 const char *text,
				 const char *cancelButton,
				 const char *button1,
				 const char *button2,
				 gevent_Callback callback,
				 void *udata,
				 g_id gid)
	{
		callback_ = callback;
		udata_ = udata;
		gid_ = gid;

		JNIEnv *env = g_getJNIEnv();
	
		jclass localRefCls  = env->FindClass("com/giderosmobile/android/player/TextInputBox");
		cls_ = (jclass)env->NewGlobalRef(localRefCls);
		env->DeleteLocalRef(localRefCls);
		
		ctorId_ = env->GetMethodID(cls_, "<init>", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;J)V");
		showId_ = env->GetMethodID(cls_, "show", "()V");
		hideId_ = env->GetMethodID(cls_, "hide", "()V");
		deleteId_ = env->GetMethodID(cls_, "delete", "()V");
		isVisibleId_ = env->GetMethodID(cls_, "isVisible", "()Z");
		setTextId_ = env->GetMethodID(cls_, "setText", "(Ljava/lang/String;)V");
		getTextId_ = env->GetMethodID(cls_, "getText", "()Ljava/lang/String;");
		setInputTypeId_ = env->GetMethodID(cls_, "setInputType", "(I)V");
		getInputTypeId_ = env->GetMethodID(cls_, "getInputType", "()I");
		setSecureInputId_ = env->GetMethodID(cls_, "setSecureInput", "(Z)V");
		isSecureInputId_ = env->GetMethodID(cls_, "isSecureInput", "()Z");
		
		jstring jtitle = env->NewStringUTF(title);
		jstring jmessage = env->NewStringUTF(message);
		jstring jtext = env->NewStringUTF(text);
		jstring jcancelButton = env->NewStringUTF(cancelButton);
		jstring jbutton1 = button1 ? env->NewStringUTF(button1) : NULL;
		jstring jbutton2 = button2 ? env->NewStringUTF(button2) : NULL;
		
		jobject localRefObj = env->NewObject(cls_, ctorId_, jtitle, jmessage, jtext, jcancelButton, jbutton1, jbutton2, (jlong)this);

		env->DeleteLocalRef(jtitle);
		env->DeleteLocalRef(jmessage);
		env->DeleteLocalRef(jtext);
		env->DeleteLocalRef(jcancelButton);
		if (jbutton1)
			env->DeleteLocalRef(jbutton1);
		if (jbutton2)
			env->DeleteLocalRef(jbutton2);

		obj_ = env->NewGlobalRef(localRefObj);
		env->DeleteLocalRef(localRefObj);
	}
コード例 #9
0
bool canOpenUrl(const char *url)
{
	JNIEnv *env = g_getJNIEnv();
	
	jclass localRefCls = env->FindClass("com/giderosmobile/android/player/GiderosApplication");
	jmethodID canOpenUrlID = env->GetStaticMethodID(localRefCls, "canOpenUrl", "(Ljava/lang/String;)Z");
	jstring jurl = env->NewStringUTF(url);
	jboolean result = env->CallStaticBooleanMethod(localRefCls, canOpenUrlID, jurl);
	env->DeleteLocalRef(jurl);
	env->DeleteLocalRef(localRefCls);
	return result;
}
コード例 #10
0
	const char* mapGetStr(const char *str, jobject jsubobj)
	{
		JNIEnv *env = g_getJNIEnv();
		//get value
		jstring jStr = env->NewStringUTF(str);
		jstring jretStr = (jstring)env->CallObjectMethod(jsubobj, env->GetMethodID(clsBundle, "getString", "(Ljava/lang/String;)Ljava/lang/String;"), jStr);
		env->DeleteLocalRef(jStr);
	
		const char *retVal = env->GetStringUTFChars(jretStr, NULL);

		return retVal;
	}
コード例 #11
0
	GGreystripe()
	{
		gid_ = g_nextgid();

		JNIEnv *env = g_getJNIEnv();

		jclass localClass = env->FindClass("com/nightspade/gideros/android/plugins/greystripe/GGreystripe");
		cls_ = (jclass)env->NewGlobalRef(localClass);
		env->DeleteLocalRef(localClass);

		env->CallStaticVoidMethod(cls_, env->GetStaticMethodID(cls_, "init", "(J)V"), (jlong)this);
	}
コード例 #12
0
ファイル: ggooglebilling.cpp プロジェクト: Nlcke/gideros
	bool confirmNotification(const char *notificationId)
	{
		JNIEnv *env = g_getJNIEnv();
	
		jstring jnotificationId = env->NewStringUTF(notificationId);
	
		jboolean result = env->CallStaticBooleanMethod(cls_, env->GetStaticMethodID(cls_, "confirmNotification", "(Ljava/lang/String;)Z"), jnotificationId);
	
		env->DeleteLocalRef(jnotificationId);		
		
		return result;
	}
コード例 #13
0
ファイル: media.cpp プロジェクト: Nlcke/gideros
	GMEDIA()
	{
		gid_ = g_NextId();
		
		JNIEnv *env = g_getJNIEnv();

		jclass localClass = env->FindClass("com/giderosmobile/android/plugins/media/GMedia");
		cls_ = (jclass)env->NewGlobalRef(localClass);
		env->DeleteLocalRef(localClass);

		env->CallStaticVoidMethod(cls_, env->GetStaticMethodID(cls_, "init", "(J)V"), (jlong)this);
	}
コード例 #14
0
ファイル: controller.cpp プロジェクト: Nlcke/gideros
	void onLeftJoystick(jfloat x, jfloat y, jdouble angle, jdouble strength, jint playerId)
	{
		JNIEnv *env = g_getJNIEnv();

		ghid_JoystickEvent *event = (ghid_JoystickEvent*)malloc(sizeof(ghid_JoystickEvent));
		event->x = (float)x;
		event->y = (float)y;
		event->angle = angle;
		event->playerId = (int)playerId;
		event->strength = (double)strength;
		
		gevent_EnqueueEvent(gid_, callback_s, GHID_LEFT_JOYSTICK_EVENT, event, 1, this);
	}
コード例 #15
0
	~GNotification()
	{
		JNIEnv *env = g_getJNIEnv();
		
		env->CallStaticVoidMethod(cls_, env->GetStaticMethodID(cls_, "destruct", "()V"));
		
		env->DeleteGlobalRef(cls_);
		env->DeleteGlobalRef(clsBundle);
		env->DeleteGlobalRef(clsSparse);
		
		gevent_RemoveEventsWithGid(gid_);
		gapplication_removeCallback(onAppStart, this);
	}
コード例 #16
0
	void onPushRegistrationError(jstring jerrorId)
	{
		JNIEnv *env = g_getJNIEnv();
		const char *errorId = env->GetStringUTFChars(jerrorId, NULL);
		
		gnotification_RegisterPushErrorEvent *event = (gnotification_RegisterPushErrorEvent*)gevent_CreateEventStruct1(
			sizeof(gnotification_RegisterPushErrorEvent),
			offsetof(gnotification_RegisterPushErrorEvent, errorId), errorId);
	
		env->ReleaseStringUTFChars(jerrorId, errorId);

		gevent_EnqueueEvent(gid_, callback_s, NOTIFICATION_PUSH_REGISTER_ERROR_EVENT, event, 1, this);
	}
コード例 #17
0
ファイル: ggooglebilling.cpp プロジェクト: Nlcke/gideros
	bool checkBillingSupported(const char *productType)
	{
		JNIEnv *env = g_getJNIEnv();

		jstring jproductType = productType ? env->NewStringUTF(productType) : NULL;
		
		jboolean result = env->CallStaticBooleanMethod(cls_, env->GetStaticMethodID(cls_, "checkBillingSupported", "(Ljava/lang/String;)Z"), jproductType);
		
		if (jproductType)
			env->DeleteLocalRef(jproductType);		
		
		return result;
	}
コード例 #18
0
ファイル: media.cpp プロジェクト: Nlcke/gideros
	void onMediaReceived(jstring jpath)
	{
		JNIEnv *env = g_getJNIEnv();

		const char *path = env->GetStringUTFChars(jpath, NULL);

		gmedia_ReceivedEvent *event = (gmedia_ReceivedEvent*)gevent_CreateEventStruct1(
			sizeof(gmedia_ReceivedEvent),
			offsetof(gmedia_ReceivedEvent, path), path);

		env->ReleaseStringUTFChars(jpath, path);
		gevent_EnqueueEvent(gid_, callback_s, GMEDIA_RECEIVED_EVENT, event, 1, this);
	}
コード例 #19
0
ファイル: platform-android.cpp プロジェクト: callcc/gideros
std::string getDeviceName(){
    JNIEnv *env = g_getJNIEnv();

	jclass localRefCls = env->FindClass("com/giderosmobile/android/player/GiderosApplication");
	jmethodID getMethodID = env->GetStaticMethodID(localRefCls, "getDeviceName", "()Ljava/lang/String;");
	jstring jresult = (jstring)env->CallStaticObjectMethod(localRefCls, getMethodID);
	const char *result = env->GetStringUTFChars(jresult, NULL);
	std::string sresult = result;
	env->ReleaseStringUTFChars(jresult, result);
	env->DeleteLocalRef(jresult);
	env->DeleteLocalRef(localRefCls);

	return sresult;
}
コード例 #20
0
	jstring transformPath(jstring jpath)
	{
		JNIEnv *env = g_getJNIEnv();
		
		const char *path = env->GetStringUTFChars(jpath, NULL);

		const char *gpath = g_pathForFile(path);
		
		env->ReleaseStringUTFChars(jpath, path);

		jstring jgpath = env->NewStringUTF(gpath);
			
		return jgpath;
	}
コード例 #21
0
ファイル: ghttp-android.cpp プロジェクト: Nlcke/gideros
	void SetProxy(const char *host,int port,const char *user,const char *pass)
	{
		JNIEnv *env = g_getJNIEnv();

		jstring jhost = env->NewStringUTF(host);
		jstring juser = env->NewStringUTF(user);
		jstring jpass = env->NewStringUTF(pass);

		env->CallStaticVoidMethod(javaNativeBridge_, setProxyId_, jhost, (jint)port, juser, jpass);

		env->DeleteLocalRef(jhost);
		env->DeleteLocalRef(juser);
		env->DeleteLocalRef(jpass);
	}
コード例 #22
0
ファイル: controller.cpp プロジェクト: Nlcke/gideros
	GHID()
	{
		gid_ = g_NextId();
		
		JNIEnv *env = g_getJNIEnv();

		jclass localClass = env->FindClass("com/giderosmobile/android/plugins/controller/GControllerManager");
		cls_ = (jclass)env->NewGlobalRef(localClass);
		env->DeleteLocalRef(localClass);
		
		jclass class_sparse = env->FindClass("android/util/SparseArray");
		clsSparse = static_cast<jclass>(env->NewGlobalRef(class_sparse));
		env->DeleteLocalRef(class_sparse);

		env->CallStaticVoidMethod(cls_, env->GetStaticMethodID(cls_, "init", "(J)V"), (jlong)this);
	}
コード例 #23
0
ファイル: ggooglebilling.cpp プロジェクト: Nlcke/gideros
	void onConfirmNotificationsResponse(jint responseCode, jstring jnotificationId)
	{
		JNIEnv *env = g_getJNIEnv();

		const char *notificationId = env->GetStringUTFChars(jnotificationId, NULL);

		ggooglebilling_ConfirmNotificationCompleteEvent *event = (ggooglebilling_ConfirmNotificationCompleteEvent*)gevent_CreateEventStruct1(
			sizeof(ggooglebilling_ConfirmNotificationCompleteEvent),
			offsetof(ggooglebilling_ConfirmNotificationCompleteEvent, notificationId), notificationId);
		
		event->responseCode = responseCode;

		env->ReleaseStringUTFChars(jnotificationId, notificationId);

		gevent_EnqueueEvent(gid_, callback_s, GGOOGLEBILLING_CONFIRM_NOTIFICATION_COMPLETE_EVENT, event, 1, this);
	}
コード例 #24
0
ファイル: ggooglebilling.cpp プロジェクト: Nlcke/gideros
	void onBillingSupported(jint responseCode, jstring jproductType)
	{
		JNIEnv *env = g_getJNIEnv();

		const char *productType = jproductType ? env->GetStringUTFChars(jproductType, NULL) : NULL;

		ggooglebilling_CheckBillingSupportedCompleteEvent *event = (ggooglebilling_CheckBillingSupportedCompleteEvent*)gevent_CreateEventStruct1(
			sizeof(ggooglebilling_CheckBillingSupportedCompleteEvent),
			offsetof(ggooglebilling_CheckBillingSupportedCompleteEvent, productType), productType);
	
		event->responseCode = responseCode;

		if (jproductType)
			env->ReleaseStringUTFChars(jproductType, productType);

		gevent_EnqueueEvent(gid_, callback_s, GGOOGLEBILLING_CHECK_BILLING_SUPPORTED_COMPLETE_EVENT, event, 1, this);
	}
コード例 #25
0
ファイル: gcameraplugin.cpp プロジェクト: Nlcke/gideros
	void start(TextureData *texture,int orientation,int *camwidth,int *camheight) {
		tex = texture;
		rdrTgt = ShaderEngine::Engine->createRenderTarget(tex->id());
		vertices[0] = Point2f(0, 0);
		vertices[1] = Point2f(tex->width, 0);
		vertices[2] = Point2f(tex->width, tex->height);
		vertices[3] = Point2f(0, tex->height);
		vertices.Update();
		switch (orientation)
		{
		case 0: //Portrait
			texcoords[3] = Point2f(1, 0);
			texcoords[0] = Point2f(0, 0);
			texcoords[1] = Point2f(0, 1);
			texcoords[2] = Point2f(1, 1);
			break;
		case 90: //Landscape left
			texcoords[0] = Point2f(1, 0);
			texcoords[1] = Point2f(0, 0);
			texcoords[2] = Point2f(0, 1);
			texcoords[3] = Point2f(1, 1);
			break;
		case 180: //Portrait upside down
			texcoords[1] = Point2f(1, 0);
			texcoords[2] = Point2f(0, 0);
			texcoords[3] = Point2f(0, 1);
			texcoords[0] = Point2f(1, 1);
			break;
		case 270: //Landscape right
			texcoords[2] = Point2f(1, 0);
			texcoords[3] = Point2f(0, 0);
			texcoords[0] = Point2f(0, 1);
			texcoords[1] = Point2f(1, 1);
			break;
		}
		texcoords.Update();

		JNIEnv *env = g_getJNIEnv();
		jintArray ret=(jintArray) env->CallStaticObjectMethod(cls_,
				env->GetStaticMethodID(cls_, "start", "(III)[I"),tex->width, tex->height,orientation);
		jboolean isCopy;
		jint *rvals = env->GetIntArrayElements(ret, &isCopy);
		*camwidth=rvals[0];
		*camheight=rvals[1];
		running=true;
	}
コード例 #26
0
ファイル: controller.cpp プロジェクト: Nlcke/gideros
	int* getPlayers(int* size)
	{
		JNIEnv *env = g_getJNIEnv();
		jintArray ptr = (jintArray) env->CallStaticObjectMethod(cls_, env->GetStaticMethodID(cls_, "getPlayers", "()[I"));
		jsize len = env->GetArrayLength(ptr);

		if(len == 0)
		{
			return NULL;
		}
		*size = len;
		int* ret = (int*)env->GetIntArrayElements(ptr, 0);
	
		env->DeleteLocalRef(ptr);
		return &ret[0];
		//return NULL;
	}
コード例 #27
0
ファイル: ggooglebilling.cpp プロジェクト: Nlcke/gideros
	bool requestPurchase(const char *productId, const char* productType, const char *developerPayload)
	{
		JNIEnv *env = g_getJNIEnv();
	
		jstring jproductId = env->NewStringUTF(productId);
		jstring jproductType = productType ? env->NewStringUTF(productType) : NULL;
		jstring jdeveloperPayload = developerPayload ? env->NewStringUTF(developerPayload) : NULL;
		
		jboolean result = env->CallStaticBooleanMethod(cls_, env->GetStaticMethodID(cls_, "requestPurchase", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z"), jproductId, jproductType, jdeveloperPayload);
	
		env->DeleteLocalRef(jproductId);
		if (jproductType)
			env->DeleteLocalRef(jproductType);
		if (jdeveloperPayload)
			env->DeleteLocalRef(jdeveloperPayload);
		
		return result;
	}
コード例 #28
0
ファイル: ghttp-android.cpp プロジェクト: Nlcke/gideros
	HTTPManager()
	{
		JNIEnv *env = g_getJNIEnv();

		jclass localRefCls = env->FindClass("com/giderosmobile/android/player/HTTPManager");
		javaNativeBridge_ = (jclass)env->NewGlobalRef(localRefCls);
		env->DeleteLocalRef(localRefCls);

		initId_ = env->GetStaticMethodID(javaNativeBridge_, "ghttp_Init", "()V");
		cleanupId_ = env->GetStaticMethodID(javaNativeBridge_, "ghttp_Cleanup", "()V");
		getId_ = env->GetStaticMethodID(javaNativeBridge_, "ghttp_Get", "(Ljava/lang/String;[Ljava/lang/String;JJ)V");
		postId_ = env->GetStaticMethodID(javaNativeBridge_, "ghttp_Post", "(Ljava/lang/String;[Ljava/lang/String;[BJJ)V");
		putId_ = env->GetStaticMethodID(javaNativeBridge_, "ghttp_Put", "(Ljava/lang/String;[Ljava/lang/String;[BJJ)V");
		deleteId_ = env->GetStaticMethodID(javaNativeBridge_, "ghttp_Delete", "(Ljava/lang/String;[Ljava/lang/String;JJ)V");
		closeId_ = env->GetStaticMethodID(javaNativeBridge_, "ghttp_Close", "(J)V");
		closeAllId_ = env->GetStaticMethodID(javaNativeBridge_, "ghttp_CloseAll", "()V");
		ignoreSslErrorsId_ = env->GetStaticMethodID(javaNativeBridge_, "ghttp_IgnoreSslErrors", "()V");
		setProxyId_ = env->GetStaticMethodID(javaNativeBridge_, "ghttp_SetProxy", "(Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;)V");

		env->CallStaticVoidMethod(javaNativeBridge_, initId_);
	}
コード例 #29
0
	void dispatch_on(int id, gnotification_Parameter *params1, gnotification_Parameter *params2){
		JNIEnv *env = g_getJNIEnv();
		
		//create Java Map object
		jobject jdispatchdate = env->NewObject(clsBundle, env->GetMethodID(clsBundle, "<init>", "()V"));
		while (params1->key)
		{
			jstring jKey = env->NewStringUTF(params1->key);
			jstring jVal = env->NewStringUTF(params1->value);
			env->CallVoidMethod(jdispatchdate, env->GetMethodID(clsBundle, "putString", "(Ljava/lang/String;Ljava/lang/String;)V"), jKey, jVal);
			env->DeleteLocalRef(jKey);
			env->DeleteLocalRef(jVal);
			++params1;
		}
		
		if(params2)
		{
			//create Java Map object
			jobject jrepeatdate = env->NewObject(clsBundle, env->GetMethodID(clsBundle, "<init>", "()V"));
			while (params2->key)
			{
				jstring jKey = env->NewStringUTF(params2->key);
				jstring jVal = env->NewStringUTF(params2->value);
				env->CallVoidMethod(jrepeatdate, env->GetMethodID(clsBundle, "putString", "(Ljava/lang/String;Ljava/lang/String;)V"), jKey, jVal);
				env->DeleteLocalRef(jKey);
				env->DeleteLocalRef(jVal);
				++params2;
			}
			env->CallStaticVoidMethod(cls_, env->GetStaticMethodID(cls_, "dispatchOn", "(ILjava/lang/Object;Ljava/lang/Object;)V"), (jint)id, jdispatchdate, jrepeatdate);
			
			env->DeleteLocalRef(jrepeatdate);
		}
		else
		{
			env->CallStaticVoidMethod(cls_, env->GetStaticMethodID(cls_, "dispatchOn", "(ILjava/lang/Object;)V"), (jint)id, jdispatchdate);
		}
		
		env->DeleteLocalRef(jdispatchdate);
	}
コード例 #30
0
	GNotification()
	{
		gid_ = g_NextId();
		
		JNIEnv *env = g_getJNIEnv();

		jclass localClass = env->FindClass("com/giderosmobile/android/plugins/notification/NotificationClass");
		cls_ = (jclass)env->NewGlobalRef(localClass);
		env->DeleteLocalRef(localClass);
		
		jclass class_bundle = env->FindClass("android/os/Bundle");
		clsBundle = static_cast<jclass>(env->NewGlobalRef(class_bundle));
		env->DeleteLocalRef(class_bundle);
	
		jclass class_sparse = env->FindClass("android/util/SparseArray");
		clsSparse = static_cast<jclass>(env->NewGlobalRef(class_sparse));
		env->DeleteLocalRef(class_sparse);
		
		env->CallStaticVoidMethod(cls_, env->GetStaticMethodID(cls_, "construct", "(J)V"), (jlong)this);
		
		//subscribe to event
		gapplication_addCallback(onAppStart, this);
	}