File indexing completed on 2025-01-26 05:09:25

0001 /*
0002  * This file is part of the KDE wacomtablet project. For copyright
0003  * information and license terms see the AUTHORS and COPYING files
0004  * in the top-level directory of this distribution.
0005  *
0006  * This program is free software; you can redistribute it and/or
0007  * modify it under the terms of the GNU General Public License as
0008  * published by the Free Software Foundation; either version 2 of
0009  * the License, or (at your option) any later version.
0010  *
0011  * This program is distributed in the hope that it will be useful,
0012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014  * GNU General Public License for more details.
0015  *
0016  * You should have received a copy of the GNU General Public License
0017  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
0018  */
0019 
0020 #include <iostream>
0021 
0022 #include "common/property.h"
0023 #include "common/screenspace.h"
0024 #include "kded/xinputadaptor.h"
0025 #include "kded/xsetwacomadaptor.h"
0026 
0027 #include <QApplication>
0028 #include <QObject>
0029 #include <QThread>
0030 #include <QTimer>
0031 
0032 using namespace Wacom;
0033 
0034 class Task : public QObject
0035 {
0036     Q_OBJECT
0037 public:
0038     Task(QObject *parent = nullptr)
0039         : QObject(parent)
0040     {
0041     }
0042 
0043 public slots:
0044     void run()
0045     {
0046         QString device = QString::fromLatin1("Wacom Bamboo One S Pen stylus");
0047 
0048         Wacom::XinputAdaptor xi(device);
0049         XsetwacomAdaptor xsetwacom(device);
0050 
0051         auto defmode = xsetwacom.getProperty(Property::Mode);
0052         // auto defmapping = xi.getProperty(Property::ScreenSpace);
0053 
0054         Wacom::ScreenSpace space(QLatin1String("speedx0.5x0.5"));
0055 
0056         xsetwacom.setProperty(Property::Mode, QString::fromLatin1("relative"));
0057         xi.setProperty(Property::ScreenSpace, space.toString());
0058         std::cout << "Mapping set\n";
0059 
0060         QThread::sleep(10);
0061 
0062         xsetwacom.setProperty(Property::Mode, defmode);
0063 
0064         std::cout << "Mapping reset\n";
0065 
0066         emit finished();
0067     }
0068 
0069 signals:
0070     void finished();
0071 };
0072 
0073 int main(int argc, char **argv)
0074 {
0075     QApplication a(argc, argv);
0076 
0077     Task *task = new Task(&a);
0078     QObject::connect(task, SIGNAL(finished()), &a, SLOT(quit()));
0079     QTimer::singleShot(0, task, SLOT(run()));
0080 
0081     return a.exec();
0082 }
0083 
0084 #include "setmapping.moc"