Logo Search packages:      
Sourcecode: kcm-tablet version File versions  Download package

bool DeviceHandler::findWacomDevList (  )  [private]

Checks xsetwacom list dev to find the names of the pad/stylus/eraser/cursor

Returns:
true if xsetwacom found some devices false if no input device could be found

Definition at line 329 of file devicehandler.cpp.

References deviceName().

Referenced by detectTablet().

{
    Q_D(DeviceHandler);
    d->deviceList.clear();

    // read xinput --list
    QProcess xinput;
    xinput.start("xsetwacom list dev");
    xinput.waitForStarted();
    xinput.waitForFinished();

    QRegExp rxStylus("(.*) STYLUS", Qt::CaseInsensitive);
    QRegExp rxPad("(.*) PAD", Qt::CaseInsensitive);
    QRegExp rxCursor("(.*) CURSOR", Qt::CaseInsensitive);
    QRegExp rxEraser("(.*) ERASER", Qt::CaseInsensitive);
    QString curLine;

    // parse xinput
    while (!xinput.atEnd()) {
        curLine = xinput.readLine();

        int pos = rxStylus.indexIn(curLine);
        if (pos > -1) {
            QString deviceName = rxStylus.cap(1);

            //add device name to the list of known devices
            d->deviceList.append(deviceName);
            d->internalStylusName = deviceName;
        }
        pos = rxPad.indexIn(curLine);
        if (pos > -1) {
            QString deviceName = rxPad.cap(1);

            //add device name to the list of known devices
            d->deviceList.append(deviceName);
            d->internalPadName = deviceName;
        }
        pos = rxCursor.indexIn(curLine);
        if (pos > -1) {
            QString deviceName = rxCursor.cap(1);

            //add device name to the list of known devices
            d->deviceList.append(deviceName);
            d->internalCursorName = deviceName;
        }
        pos = rxEraser.indexIn(curLine);
        if (pos > -1) {
            QString deviceName = rxEraser.cap(1);

            //add device name to the list of known devices
            d->deviceList.append(deviceName);
            d->internalEraserName = deviceName;
        }
    }

    // Regexp could not find any device named stylus/pad/eraser/cursor/touch or with wacom in the name
    if (d->deviceList.isEmpty()) {
        return false;
    }

    // This happens because we deal with two different output results of xinput --list
    // happens that both fit ... really time to let solid handle this
    d->deviceList.removeDuplicates();

    // if we just have no pad name only a name for a stylus...copy that, this is how the touchpc devices seem to work
    if (d->internalPadName.isEmpty()) {
        d->internalPadName = d->internalStylusName;
    }

    // seems we found something useful
    return true;
}


Generated by  Doxygen 1.6.0   Back to index