Пример #1
0
    g_id SoundCreateFromBuffer(const void *data, int numChannels, int sampleRate, int bitsPerSample, int numSamples)
    {
        ALuint buffer;
        alGenBuffers(1, &buffer);

        ALenum format = 0;
        if (bitsPerSample == 8)
        {
            if (numChannels == 1)
                format = AL_FORMAT_MONO8;
            else if (numChannels == 2)
                format = AL_FORMAT_STEREO8;
        }
        else if (bitsPerSample == 16)
        {
            if (numChannels == 1)
                format = AL_FORMAT_MONO16;
            else if (numChannels == 2)
                format = AL_FORMAT_STEREO16;
        }

        alBufferData(buffer, format, data, numSamples * numChannels * (bitsPerSample / 8), sampleRate);

        g_id gid = g_NextId();
        sounds_[gid] = new Sound(gid, buffer, (numSamples * 1000LL) / sampleRate);

        return gid;
    }
Пример #2
0
	g_id Put(const char *url, const ghttp_Header *headers, const void *data, size_t size, gevent_Callback callback, void *udata)
	{
		JNIEnv *env = g_getJNIEnv();

		jstring jurl = env->NewStringUTF(url);

		jobjectArray jheaders = toJava(env, headers);

		jbyteArray jdata = NULL;
		if (size > 0)
		{
			jdata = env->NewByteArray(size);
			env->SetByteArrayRegion(jdata, 0, size, (jbyte*)data);
		}

		g_id id = g_NextId();

		env->CallStaticVoidMethod(javaNativeBridge_, putId_, jurl, jheaders, jdata, (jlong)this, (jlong)id);

		if (jdata)
			env->DeleteLocalRef(jdata);

		if (jheaders)
			env->DeleteLocalRef(jheaders);

		env->DeleteLocalRef(jurl);

		CallbackElement element;
		element.callback = callback;
		element.udata = udata;
		map_[id] = element;
		
		return id;
	}
Пример #3
0
    g_id SoundPlay(g_id sound, bool paused)
    {
        std::map<g_id, Sound*>::iterator iter = sounds_.find(sound);
        if (iter == sounds_.end())
            return 0;

        if (channels_.size() >= 31)
            return 0;

        Sound *sound2 = iter->second;

        ALuint source;
        alGetError();
        alGenSources(1, &source);
        if(alGetError() != AL_NO_ERROR)
            return 0;

        alSourcei(source, AL_BUFFER, sound2->buffer);

        g_id gid = g_NextId();

        Channel *channel = new Channel(gid, sound2, source);

        sound2->channels.insert(channel);

        channels_[gid] = channel;

        channel->paused = paused;
        if (!paused)
            alSourcePlay(channel->source);

        return gid;
    }
Пример #4
0
    InputManager()
    {
        isMouseToTouchEnabled_ = 0;
        isTouchToMouseEnabled_ = 0;
        mouseTouchOrder_= 0;

        keyMap_[Qt::Key_Left] = GINPUT_KEY_LEFT;
        keyMap_[Qt::Key_Right] = GINPUT_KEY_RIGHT;
        keyMap_[Qt::Key_Up] = GINPUT_KEY_UP;
        keyMap_[Qt::Key_Down] = GINPUT_KEY_DOWN;

        keyMap_[Qt::Key_0] = GINPUT_KEY_0;
        keyMap_[Qt::Key_1] = GINPUT_KEY_1;
        keyMap_[Qt::Key_2] = GINPUT_KEY_2;
        keyMap_[Qt::Key_3] = GINPUT_KEY_3;
        keyMap_[Qt::Key_4] = GINPUT_KEY_4;
        keyMap_[Qt::Key_5] = GINPUT_KEY_5;
        keyMap_[Qt::Key_6] = GINPUT_KEY_6;
        keyMap_[Qt::Key_7] = GINPUT_KEY_7;
        keyMap_[Qt::Key_8] = GINPUT_KEY_8;
        keyMap_[Qt::Key_9] = GINPUT_KEY_9;

        keyMap_[Qt::Key_A] = GINPUT_KEY_A;
        keyMap_[Qt::Key_B] = GINPUT_KEY_B;
        keyMap_[Qt::Key_C] = GINPUT_KEY_C;
        keyMap_[Qt::Key_D] = GINPUT_KEY_D;
        keyMap_[Qt::Key_E] = GINPUT_KEY_E;
        keyMap_[Qt::Key_F] = GINPUT_KEY_F;
        keyMap_[Qt::Key_G] = GINPUT_KEY_G;
        keyMap_[Qt::Key_H] = GINPUT_KEY_H;
        keyMap_[Qt::Key_I] = GINPUT_KEY_I;
        keyMap_[Qt::Key_J] = GINPUT_KEY_J;
        keyMap_[Qt::Key_K] = GINPUT_KEY_K;
        keyMap_[Qt::Key_L] = GINPUT_KEY_L;
        keyMap_[Qt::Key_M] = GINPUT_KEY_M;
        keyMap_[Qt::Key_N] = GINPUT_KEY_N;
        keyMap_[Qt::Key_O] = GINPUT_KEY_O;
        keyMap_[Qt::Key_P] = GINPUT_KEY_P;
        keyMap_[Qt::Key_Q] = GINPUT_KEY_Q;
        keyMap_[Qt::Key_R] = GINPUT_KEY_R;
        keyMap_[Qt::Key_S] = GINPUT_KEY_S;
        keyMap_[Qt::Key_T] = GINPUT_KEY_T;
        keyMap_[Qt::Key_U] = GINPUT_KEY_U;
        keyMap_[Qt::Key_V] = GINPUT_KEY_V;
        keyMap_[Qt::Key_W] = GINPUT_KEY_W;
        keyMap_[Qt::Key_X] = GINPUT_KEY_X;
        keyMap_[Qt::Key_Y] = GINPUT_KEY_Y;
        keyMap_[Qt::Key_Z] = GINPUT_KEY_Z;

        pthread_mutex_init(&touchPoolMutex_, NULL);

        gevent_AddCallback(posttick_s, this);

        gid_ = g_NextId();
    }
Пример #5
0
GHID::GHID()
{
    gid_ = g_NextId();
    players.clear();
    Gamepad_deviceAttachFunc(ghid_onConnected, (void *) 0x1);
    Gamepad_deviceRemoveFunc(ghid_onDisconnected, (void *) 0x2);
    Gamepad_buttonDownFunc(ghid_onButtonDown, (void *) 0x3);
    Gamepad_buttonUpFunc(ghid_onButtonUp, (void *) 0x4);
    Gamepad_axisMoveFunc(ghid_onAxisMoved, (void *) 0x5);
    Gamepad_init();
    gevent_AddCallback(onEnterFrame, this);
}
Пример #6
0
	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);
	}
Пример #7
0
	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);
	}
Пример #8
0
g_id UIManager::createAlertDialog(const char *title,
                                  const char *message,
                                  const char *cancelButton,
                                  const char *button1,
                                  const char *button2,
                                  gevent_Callback callback,
                                  void *udata)
{
    g_id gid = g_NextId();

    AlertBox *alertBox = new AlertBox(title, message,
									  cancelButton, button1, button2,
									  callback, udata,
									  gid);
    map_[gid] = alertBox;

    return gid;
}
Пример #9
0
g_id HTTPManager::Delete(const char *url, const ghttp_Header *header, gevent_Callback callback, void *udata)
{
    QNetworkRequest request(QUrl::fromEncoded(url));

    request.setRawHeader("User-Agent", "Gideros");

    if (header)
        for (; header->name; ++header)
            request.setRawHeader(QByteArray(header->name), QByteArray(header->value));

    QNetworkReply *reply = manager_->deleteResource(request);

    connect(reply, SIGNAL(downloadProgress(qint64, qint64)),
            this,	 SLOT(downloadProgress(qint64, qint64)));

    NetworkReply reply2;
    reply2.id = g_NextId();
    reply2.callback = callback;
    reply2.udata = udata;
    map_[reply] = reply2;

    return reply2.id;
}
	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);
	}
Пример #11
0
	g_id Get(const char *url, const ghttp_Header *headers, gevent_Callback callback, void *udata)
	{
		JNIEnv *env = g_getJNIEnv();

		jstring jurl = env->NewStringUTF(url);

		jobjectArray jheaders = toJava(env, headers);
		
		g_id id = g_NextId();
		
		env->CallStaticVoidMethod(javaNativeBridge_, getId_, jurl, jheaders, (jlong)this, (jlong)id);

		if (jheaders)
			env->DeleteLocalRef(jheaders);
		
		env->DeleteLocalRef(jurl);

		CallbackElement element;
		element.callback = callback;
		element.udata = udata;
		map_[id] = element;
		
		return id;
	}
Пример #12
0
 GGApplicationManager()
 {
     gid_ = g_NextId();
 }
Пример #13
0
	GMEDIA()
	{
		gid_ = g_NextId();

	}
Пример #14
0
void ggeolocation_init()
{
	gid_ = g_NextId();
}
Пример #15
0
    GGInputManager()
    {
		accelerometerStartCount_ = 0;
		gyroscopeStartCount_ = 0;

        isMouseToTouchEnabled_ = 0;
        isTouchToMouseEnabled_ = 0;
        mouseTouchOrder_= 0;

		const int KEYCODE_SEARCH  = 84;
		const int KEYCODE_BACK = 4;
		const int KEYCODE_MENU  = 82;
		const int KEYCODE_DPAD_CENTER = 23;
		const int KEYCODE_DPAD_UP = 19;
		const int KEYCODE_DPAD_DOWN = 20;
		const int KEYCODE_DPAD_LEFT = 21;
		const int KEYCODE_DPAD_RIGHT = 22;

		const int KEYCODE_0 = 7;
		const int KEYCODE_1 = 8;
		const int KEYCODE_2 = 9;
		const int KEYCODE_3 = 10;
		const int KEYCODE_4 = 11;
		const int KEYCODE_5 = 12;
		const int KEYCODE_6 = 13;
		const int KEYCODE_7 = 14;
		const int KEYCODE_8 = 15;
		const int KEYCODE_9 = 16;

		const int KEYCODE_A = 29;
		const int KEYCODE_B = 30;
		const int KEYCODE_C = 31;
		const int KEYCODE_D = 32;
		const int KEYCODE_E = 33;
		const int KEYCODE_F = 34;
		const int KEYCODE_G = 35;
		const int KEYCODE_H = 36;
		const int KEYCODE_I = 37;
		const int KEYCODE_J = 38;
		const int KEYCODE_K = 39;
		const int KEYCODE_L = 40;
		const int KEYCODE_M = 41;
		const int KEYCODE_N = 42;
		const int KEYCODE_O = 43;
		const int KEYCODE_P = 44;
		const int KEYCODE_Q = 45;
		const int KEYCODE_R = 46;
		const int KEYCODE_S = 47;
		const int KEYCODE_T = 48;
		const int KEYCODE_U = 49;
		const int KEYCODE_V = 50;
		const int KEYCODE_W = 51;
		const int KEYCODE_X = 52;
		const int KEYCODE_Y = 53;
		const int KEYCODE_Z = 54;

		const int KEYCODE_BACKSPACE = 67;

		const int KEYCODE_BUTTON_A = 96;
		const int KEYCODE_BUTTON_B = 97;
		const int KEYCODE_BUTTON_C = 98;
		const int KEYCODE_BUTTON_X = 99;
		const int KEYCODE_BUTTON_Y = 100;
		const int KEYCODE_BUTTON_Z = 101;
		
		const int KEYCODE_BUTTON_SELECT = 109;
		const int KEYCODE_BUTTON_START = 108;
		const int KEYCODE_BUTTON_L1 = 102;
		const int KEYCODE_BUTTON_R1 = 103;
	
		keyMap_[KEYCODE_SEARCH] = GINPUT_KEY_SEARCH;
		keyMap_[KEYCODE_BACK] = GINPUT_KEY_BACK;
		keyMap_[KEYCODE_MENU] = GINPUT_KEY_MENU;
		keyMap_[KEYCODE_DPAD_CENTER] = GINPUT_KEY_CENTER;
		keyMap_[KEYCODE_DPAD_UP] = GINPUT_KEY_UP;
		keyMap_[KEYCODE_DPAD_DOWN] = GINPUT_KEY_DOWN;
		keyMap_[KEYCODE_DPAD_LEFT] = GINPUT_KEY_LEFT;
		keyMap_[KEYCODE_DPAD_RIGHT] = GINPUT_KEY_RIGHT;
		keyMap_[KEYCODE_BUTTON_SELECT] = GINPUT_KEY_SELECT;
		keyMap_[KEYCODE_BUTTON_START] = GINPUT_KEY_START;
		keyMap_[KEYCODE_BUTTON_L1] = GINPUT_KEY_L1;
		keyMap_[KEYCODE_BUTTON_R1] = GINPUT_KEY_R1;

		keyMap_[KEYCODE_0] = GINPUT_KEY_0;
		keyMap_[KEYCODE_1] = GINPUT_KEY_1;
		keyMap_[KEYCODE_2] = GINPUT_KEY_2;
		keyMap_[KEYCODE_3] = GINPUT_KEY_3;
		keyMap_[KEYCODE_4] = GINPUT_KEY_4;
		keyMap_[KEYCODE_5] = GINPUT_KEY_5;
		keyMap_[KEYCODE_6] = GINPUT_KEY_6;
		keyMap_[KEYCODE_7] = GINPUT_KEY_7;
		keyMap_[KEYCODE_8] = GINPUT_KEY_8;
		keyMap_[KEYCODE_9] = GINPUT_KEY_9;
		
		keyMap_[KEYCODE_A] = GINPUT_KEY_A;
		keyMap_[KEYCODE_B] = GINPUT_KEY_B;
		keyMap_[KEYCODE_C] = GINPUT_KEY_C;
		keyMap_[KEYCODE_D] = GINPUT_KEY_D;
		keyMap_[KEYCODE_E] = GINPUT_KEY_E;
		keyMap_[KEYCODE_F] = GINPUT_KEY_F;
		keyMap_[KEYCODE_G] = GINPUT_KEY_G;
		keyMap_[KEYCODE_H] = GINPUT_KEY_H;
		keyMap_[KEYCODE_I] = GINPUT_KEY_I;
		keyMap_[KEYCODE_J] = GINPUT_KEY_J;
		keyMap_[KEYCODE_K] = GINPUT_KEY_K;
		keyMap_[KEYCODE_L] = GINPUT_KEY_L;
		keyMap_[KEYCODE_M] = GINPUT_KEY_M;
		keyMap_[KEYCODE_N] = GINPUT_KEY_N;
		keyMap_[KEYCODE_O] = GINPUT_KEY_O;
		keyMap_[KEYCODE_P] = GINPUT_KEY_P;
		keyMap_[KEYCODE_Q] = GINPUT_KEY_Q;
		keyMap_[KEYCODE_R] = GINPUT_KEY_R;
		keyMap_[KEYCODE_S] = GINPUT_KEY_S;
		keyMap_[KEYCODE_T] = GINPUT_KEY_T;
		keyMap_[KEYCODE_U] = GINPUT_KEY_U;
		keyMap_[KEYCODE_V] = GINPUT_KEY_V;
		keyMap_[KEYCODE_W] = GINPUT_KEY_W;
		keyMap_[KEYCODE_X] = GINPUT_KEY_X;
		keyMap_[KEYCODE_Y] = GINPUT_KEY_Y;
		keyMap_[KEYCODE_Z] = GINPUT_KEY_Z;		

		keyMap_[KEYCODE_BACKSPACE] = GINPUT_KEY_BACKSPACE;
		keyMap_[KEYCODE_BUTTON_A] = GINPUT_KEY_A;
		keyMap_[KEYCODE_BUTTON_B] = GINPUT_KEY_B;
		keyMap_[KEYCODE_BUTTON_C] = GINPUT_KEY_C;
		keyMap_[KEYCODE_BUTTON_X] = GINPUT_KEY_X;
		keyMap_[KEYCODE_BUTTON_Y] = GINPUT_KEY_Y;
		keyMap_[KEYCODE_BUTTON_Z] = GINPUT_KEY_Z;

		pthread_mutex_init(&touchPoolMutex_, NULL);
		pthread_mutex_init(&keyPoolMutex_, NULL);
		pthread_mutex_init(&mousePoolMutex_, NULL);

        gevent_AddCallback(posttick_s, this);

        gid_ = g_NextId();
    }
Пример #16
0
	GAds()
	{
		gid_ = g_NextId();
		frameworks["pubcenter"] = &createInstance<AdsPubcenter>;
	}