コード例 #1
0
ファイル: mtpsync.cpp プロジェクト: zhao07/leechcraft
	void Plugin::handlePollFinished ()
	{
		IsPolling_ = false;
		while (!UploadQueue_.isEmpty ())
		{
			const auto& item = UploadQueue_.takeFirst ();
			Upload (item.LocalPath_, item.OrigLocalPath_, item.To_, item.StorageID_);
		}

		auto watcher = dynamic_cast<QFutureWatcher<USBDevInfos_t>*> (sender ());
		watcher->deleteLater ();

		const auto& infos = watcher->result ();
		if (!infos.isEmpty ())
		{
			Infos_ = infos;
			emit availableDevicesChanged ();
		}

		if (FirstPoll_)
		{
			Subscribe2Devs ();
			FirstPoll_ = false;
		}

		QTimer::singleShot (120000,
				this,
				SLOT (pollDevices ()));
	}
コード例 #2
0
ファイル: mtpsync.cpp プロジェクト: zhao07/leechcraft
	void Plugin::handleRowsInserted (const QModelIndex& parent, int start, int end)
	{
		if (parent.isValid ())
			return;

		bool hasNew = false;
		for (auto i = start; i <= end; ++i)
		{
			const auto& idx = Model_->index (i, 0);

			const auto busnum = idx.data (USBDeviceRole::Busnum).toInt ();
			const auto devnum = idx.data (USBDeviceRole::Devnum).toInt ();

			if (LIBMTP_Check_Specific_Device (busnum, devnum))
			{
				hasNew = true;
				break;
			}
		}

		if (!hasNew)
			return;

		QTimer::singleShot (1000,
				this,
				SLOT (pollDevices ()));
	}
コード例 #3
0
ファイル: controllermanager.cpp プロジェクト: Shunty/mixxx
ControllerManager::ControllerManager(ConfigObject<ConfigValue>* pConfig)
        : QObject(),
          m_pConfig(pConfig),
          // WARNING: Do not parent m_pControllerLearningEventFilter to
          // ControllerManager because the CM is moved to its own thread and runs
          // its own event loop.
          m_pControllerLearningEventFilter(new ControllerLearningEventFilter()),
          m_pollTimer(this) {
    qRegisterMetaType<ControllerPresetPointer>("ControllerPresetPointer");

    // Create controller mapping paths in the user's home directory.
    QString userPresets = userPresetsPath(m_pConfig);
    if (!QDir(userPresets).exists()) {
        qDebug() << "Creating user controller presets directory:" << userPresets;
        QDir().mkpath(userPresets);
    }
    QString localPresets = localPresetsPath(m_pConfig);
    if (!QDir(localPresets).exists()) {
        qDebug() << "Creating local controller presets directory:" << localPresets;
        QDir().mkpath(localPresets);
    }

    // Initialize preset info parsers
    m_pPresetInfoManager = new PresetInfoEnumerator(m_pConfig);

    // Instantiate all enumerators
    m_enumerators.append(new PortMidiEnumerator());
#ifdef __HSS1394__
    m_enumerators.append(new Hss1394Enumerator());
#endif
#ifdef __BULK__
    m_enumerators.append(new BulkEnumerator());
#endif
#ifdef __HID__
    m_enumerators.append(new HidEnumerator());
#endif

    m_pollTimer.setInterval(kPollIntervalMillis);
    connect(&m_pollTimer, SIGNAL(timeout()),
            this, SLOT(pollDevices()));

    m_pThread = new QThread;
    m_pThread->setObjectName("Controller");

    // Moves all children (including the poll timer) to m_pThread
    moveToThread(m_pThread);

    // Controller processing needs to be prioritized since it can affect the
    // audio directly, like when scratching
    m_pThread->start(QThread::HighPriority);

    connect(this, SIGNAL(requestSetUpDevices()),
            this, SLOT(slotSetUpDevices()));
    connect(this, SIGNAL(requestShutdown()),
            this, SLOT(slotShutdown()));
    connect(this, SIGNAL(requestSave(bool)),
            this, SLOT(slotSavePresets(bool)));
}
コード例 #4
0
ファイル: main.c プロジェクト: dejanberry/NDK-Samples
void update()
{
    handleEvents();

    if (_polling) {
        pollDevices();
    }

    int i;
    for (i = 0; i < MAX_CONTROLLERS; ++i) {
        GameController* controller = &_controllers[i];

        // If a button is active, map it to the first gamepad button pressed.
        if (_activeButton[i]) {
            int j;
            for (j = 0; j < controller->buttonCount; ++j) {
                if (controller->buttons & _buttonMappings[j]) {
                    // Erase old button mapping if one exists.
                    int k;
                    for (k = 0; k < 16; ++k) {
                        Button* button = &_buttons[i][k];
                        if (_buttonMappings[j] & button->mapping) {
                            button->mapping = 0;
                            break;
                        }
                    }

                    // Set new button mapping.
                    _activeButton[i]->mapping = _buttonMappings[j];
                    _activeButton[i] = NULL;
                    break;
                }
            }
        }

        float xOffset = (_surfaceWidth * 0.5f)*i;

        // Set the inner joystick positions.
        _analog0Inner[i]->x = ANALOG0_X + xOffset + (controller->analog0[0] >> 2);
        _analog0Inner[i]->y = ANALOG_Y - (controller->analog0[1] >> 2);

        _analog1Inner[i]->x = ANALOG1_X + xOffset + (controller->analog1[0] >> 2);
        _analog1Inner[i]->y = ANALOG_Y - (controller->analog1[1] >> 2);

        // Set the button UVs to correspond to their states, as well as the button text.
        sprintf(controller->buttonsString, "Buttons: ");
        int j;
        for (j = 0; j < 16; ++j) {
            Button* button = &_buttons[i][j];

            if ((controller->buttons & button->mapping) || button == _activeButton[i]) {
                switch (button->type) {
                case DPAD_LEFT:
                    button->quad->uvs = _leftDPadDownUVs;
                    break;
                case DPAD_RIGHT:
                    button->quad->uvs = _rightDPadDownUVs;
                    break;
                case DPAD_UP:
                    button->quad->uvs = _upDPadDownUVs;
                    break;
                case DPAD_DOWN:
                    button->quad->uvs = _downDPadDownUVs;
                    break;
                case TRIGGER:
                    button->quad->uvs = _triggerDownUVs;
                    break;
                case BUTTON:
                    button->quad->uvs = _buttonDownUVs;
                    break;
                }
            } else {
                switch (button->type) {
                case DPAD_LEFT:
                    button->quad->uvs = _leftDPadUpUVs;
                    break;
                case DPAD_RIGHT:
                    button->quad->uvs = _rightDPadUpUVs;
                    break;
                case DPAD_UP:
                    button->quad->uvs = _upDPadUpUVs;
                    break;
                case DPAD_DOWN:
                    button->quad->uvs = _downDPadUpUVs;
                    break;
                case TRIGGER:
                    button->quad->uvs = _triggerUpUVs;
                    break;
                case BUTTON:
                    button->quad->uvs = _buttonUpUVs;
                    break;
                }
            }
        }

        // Append button indices to the string showing which buttons are pressed,
        // regardless of whether or not the buttons are mapped.
        char buttonString[4];
        for (j = 0; j < controller->buttonCount; ++j) {
            if (_buttonMappings[j] & controller->buttons) {
                sprintf(buttonString, "%d ", j);
                strcat(controller->buttonsString, buttonString);
            }
        }

        // Set the rest of the text to display for this controller.
        sprintf(controller->analog0String, "Analog 0: (%4d, %4d)", controller->analog0[0], controller->analog0[1]);

        if (controller->type == SCREEN_EVENT_GAMEPAD) {
            sprintf(controller->analog1String, "Analog 1: (%4d, %4d)", controller->analog1[0], controller->analog1[1]);
        } else {
            controller->analog1String[0] = '\0';
        }
    }
}
コード例 #5
0
ファイル: mtpsync.cpp プロジェクト: zhao07/leechcraft
	void Plugin::Refresh ()
	{
		pollDevices ();
	}