Beispiel #1
0
void InputDaemon::refresh()
{
    stop();

    Logger::LogInfo("Refreshing joystick list");

    QEventLoop q;
    connect(eventWorker, SIGNAL(sdlStarted()), &q, SLOT(quit()));
    QMetaObject::invokeMethod(eventWorker, "refresh", Qt::BlockingQueuedConnection);

    if (eventWorker->isSDLOpen())
    {
        q.exec();
    }

    disconnect(eventWorker, SIGNAL(sdlStarted()), &q, SLOT(quit()));

    pollResetTimer.stop();

    // Put in an extra delay before refreshing the joysticks
    QTimer temp;
    connect(&temp, SIGNAL(timeout()), &q, SLOT(quit()));
    temp.start(100);
    q.exec();

    refreshJoysticks();
    QTimer::singleShot(100, eventWorker, SLOT(performWork()));

    stopped = false;
}
Beispiel #2
0
void InputDaemon::refresh()
{
    stop();

    eventWorker->refresh();

    QEventLoop q;
    connect(eventWorker, SIGNAL(sdlStarted()), &q, SLOT(quit()));
    q.exec();
    disconnect(eventWorker, SIGNAL(sdlStarted()), &q, SLOT(quit()));

    // Put in an extra delay before refreshing the joysticks
    QTimer temp;
    connect(&temp, SIGNAL(timeout()), &q, SLOT(quit()));
    temp.start(100);
    q.exec();

    refreshJoysticks();
    QTimer::singleShot(0, eventWorker, SLOT(performWork()));
}
Beispiel #3
0
void SDLEventReader::initSDL()
{
#ifdef USE_SDL_2
    // SDL_INIT_GAMECONTROLLER should automatically initialize SDL_INIT_JOYSTICK
    // but it doesn't seem to be the case with v2.0.4
    SDL_Init(SDL_INIT_GAMECONTROLLER | SDL_INIT_JOYSTICK);
#else
    // Video support is required to use event system in SDL 1.2.
    SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK);
#endif

    SDL_JoystickEventState(SDL_ENABLE);
    sdlIsOpen = true;

#ifdef USE_SDL_2
    //QSettings settings(PadderCommon::configFilePath, QSettings::IniFormat);
    settings->getLock()->lock();
    settings->beginGroup("Mappings");
    QStringList mappings = settings->allKeys();
    QStringListIterator iter(mappings);
    while (iter.hasNext())
    {
        QString tempstring = iter.next();
        QString mappingSetting = settings->value(tempstring, QString()).toString();
        if (!mappingSetting.isEmpty())
        {
            QByteArray temparray = mappingSetting.toUtf8();
            char *mapping = temparray.data();
            SDL_GameControllerAddMapping(mapping); // Let SDL take care of validation
        }
    }

    settings->endGroup();
    settings->getLock()->unlock();

    //SDL_GameControllerAddMapping("03000000100800000100000010010000,Twin USB Joystick,a:b2,b:b1,x:b3,y:b0,back:b8,start:b9,leftshoulder:b6,rightshoulder:b7,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a3,righty:a2,lefttrigger:b4,righttrigger:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2");
#endif

    pollRateTimer.stop();
    pollRateTimer.setInterval(pollRate);
    //pollRateTimer.start();
    //pollRateTimer.setSingleShot(true);

    emit sdlStarted();
}