예제 #1
0
bool QQnxBpsEventFilter::nativeEventFilter(const QByteArray &eventType, void *message, long *result)
{
    Q_UNUSED(eventType);
    Q_UNUSED(result);
    bps_event_t *event = static_cast<bps_event_t *>(message);
    const int eventDomain = bps_event_get_domain(event);
    qBpsEventFilterDebug() << Q_FUNC_INFO << "event=" << event << "domain=" << eventDomain;

    if (eventDomain == screen_get_domain()) {
        if (!m_screenEventHandler) {
            qWarning("QQNX: registered for screen events, but no handler provided.");
            return false;
        }

        screen_event_t screenEvent = screen_event_get_event(event);
        return m_screenEventHandler->handleEvent(screenEvent);
    }

    if (eventDomain == dialog_get_domain()) {
        dialog_instance_t nativeDialog = dialog_event_get_dialog_instance(event);
        QQnxFileDialogHelper *dialog = m_dialogMapper.value(nativeDialog, 0);
        if (dialog)
            return dialog->handleEvent(event);
    }

    if (eventDomain == navigator_get_domain())
        return handleNavigatorEvent(event);

    if (m_virtualKeyboard->handleEvent(event))
        return true;

    return false;
}
void ScoreLoopThread::run() {
	qDebug() << "ScoreLoopThread run() started";

	AppData_t app;
	SC_InitData_t initData;
	SC_Error_t rc;
	char versionBuffer[0x100]; /* Thats 256 bytes */

	qDebug() << "Starting Scoreloop Sample...";

	/* Initialize the BPS event system */
	bps_initialize();
	bps_set_verbosity(0); /* Set to 1 or 2 for more output if you like */

	memset(&app, 0, sizeof(AppData_t));

	/* Initialize the Scoreloop platform dependent SC_InitData_t structure to default values. */
	SC_InitData_Init(&initData);

	/* What version of the Scoreloop library do we use? */
	if (SC_GetVersionInfo(&initData, versionBuffer, sizeof(versionBuffer))) {
		qDebug() << "Version-Info: " << versionBuffer;
	}

	/* Now, create the Scoreloop Client with the initialized SC_InitData_t structure
	 * as well as the game-id and game-secret as found on the developer portal.
	 */
	rc = SC_Client_New(&app.client, &initData, SCORELOOP_GAME_ID, SCORELOOP_GAME_SECRET, SCORELOOP_GAME_VERSION, SCORELOOP_GAME_CURRENCY, SCORELOOP_GAME_LANGUAGE);
	if (rc != SC_OK) {
		HandleError(&app, rc);
	} else {
		//InformUser(&app, "Note", "Scoreloop Sample started...");

		/* Request the user here just for demonstration purposes */
		RequestUser(&app);
	}

	while (!m_quit) {
		/* Get next BPS event */
		bps_event_t *event;
		bps_get_event(&event, -1);

		/* Scoreloop event handling  */
		if (bps_event_get_domain(event) == SC_GetBPSEventDomain(&initData)) {
			SC_HandleBPSEvent(&initData, event);
		}

		else if (bps_event_get_domain(event) == dialog_get_domain()) {
			dialog_destroy(dialog_event_get_dialog_instance(event));
			app.dialog = 0;
		}
		/* Add more BPS event handling here... */

	}

	/* Cleanup the Scoreloop client */
	SC_Client_Release(app.client);

	/* Shutdown BPS */
	bps_shutdown();
	qDebug() << "SensorsThread run() finished.";
}