예제 #1
0
QEvdevTabletHandler::QEvdevTabletHandler(const QString &spec, QObject *parent)
    : QObject(parent), d(0)
{
    setObjectName(QLatin1String("Evdev Tablet Handler"));
    d = new QEvdevTabletData(this);
    QString dev;
    QStringList args = spec.split(QLatin1Char(':'));
    for (int i = 0; i < args.count(); ++i) {
        if (args.at(i).startsWith(QLatin1String("/dev/"))) {
            dev = args.at(i);
            break;
        }
    }
    if (dev.isEmpty()) {
        QScopedPointer<QDeviceDiscovery> deviceDiscovery(
            QDeviceDiscovery::create(QDeviceDiscovery::Device_Tablet, this));
        if (deviceDiscovery) {
            QStringList devices = deviceDiscovery->scanConnectedDevices();
            if (!devices.isEmpty())
                dev = devices.at(0);
        }
    }
    if (!dev.isEmpty()) {
        qDebug("evdevtablet: using %s", qPrintable(dev));
        d->fd = QT_OPEN(dev.toLocal8Bit().constData(), O_RDONLY | O_NDELAY, 0);
        if (d->fd >= 0) {
            d->testGrab();
            if (d->queryLimits()) {
                d->notifier = new QSocketNotifier(d->fd, QSocketNotifier::Read, this);
                connect(d->notifier, SIGNAL(activated(int)), this, SLOT(readData()));
            }
예제 #2
0
QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &spec, QObject *parent)
    : QObject(parent), m_notify(0), m_fd(-1), d(0)
#ifdef USE_MTDEV
      , m_mtdev(0)
#endif
{
    setObjectName(QLatin1String("Evdev Touch Handler"));

    QString dev;

    // only the first device argument is used for now
    QStringList args = spec.split(QLatin1Char(':'));
    for (int i = 0; i < args.count(); ++i) {
        if (args.at(i).startsWith(QLatin1String("/dev/"))) {
            dev = args.at(i);
            break;
        }
    }

    if (dev.isEmpty()) {
        // try to let udev scan for already connected devices
        QScopedPointer<QDeviceDiscovery> deviceDiscovery(QDeviceDiscovery::create(QDeviceDiscovery::Device_Touchpad | QDeviceDiscovery::Device_Touchscreen, this));
        if (deviceDiscovery) {
            QStringList devices = deviceDiscovery->scanConnectedDevices();

            // only the first device found is used for now
            if (devices.size() > 0)
                dev = devices[0];
        }
    }

    if (dev.isEmpty())
        return;

    qDebug("evdevtouch: Using device %s", qPrintable(dev));
    m_fd = QT_OPEN(dev.toLocal8Bit().constData(), O_RDONLY | O_NDELAY, 0);

    if (m_fd >= 0) {
        m_notify = new QSocketNotifier(m_fd, QSocketNotifier::Read, this);
        connect(m_notify, SIGNAL(activated(int)), this, SLOT(readData()));
    } else {