diff --git a/autotests/faketablet/CMakeLists.txt b/autotests/faketablet/CMakeLists.txt index f183979..e37cd49 100644 --- a/autotests/faketablet/CMakeLists.txt +++ b/autotests/faketablet/CMakeLists.txt @@ -1,11 +1,17 @@ include(CheckTypeSize) +include(CheckIncludeFile) + +if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") + set(CMAKE_EXTRA_INCLUDE_FILES "linux/uinput.h") +elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") + set(CMAKE_EXTRA_INCLUDE_FILES "dev/evdev/uinput.h") +endif() -set(CMAKE_EXTRA_INCLUDE_FILES linux/uinput.h dev/evdev/uinput.h) check_type_size("struct uinput_setup" STRUCT_UINPUT_SETUP) set(CMAKE_EXTRA_INCLUDE_FILES) if(HAVE_STRUCT_UINPUT_SETUP) add_executable(faketablet faketablet.cpp) else() message(STATUS "No suitable uinput API, fake tablet is disabled") endif() diff --git a/src/common/devicetype.h b/src/common/devicetype.h index 9594b75..63280d2 100644 --- a/src/common/devicetype.h +++ b/src/common/devicetype.h @@ -1,98 +1,98 @@ /* * This file is part of the KDE wacomtablet project. For copyright * information and license terms see the AUTHORS and COPYING files * in the top-level directory of this distribution. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DEVICETYPE_H #define DEVICETYPE_H #include #include "enum.h" #include "property.h" namespace Wacom { // forward declaration class DeviceType; -class DeviceTypeTemplateSpecializationLessFunctor; +struct DeviceTypeTemplateSpecializationLessFunctor; /** * @brief Helper Typedef! Do not use! * * This typedef is required by the DeviceType class. It eases maintenane of template parameters. */ typedef Enum DeviceTypeTemplateSpecialization; /** * @brief Helper Class! Do not use! * * This functor is required by the DeviceType class to sort its instances. */ struct DeviceTypeTemplateSpecializationLessFunctor { bool operator()(const DeviceTypeTemplateSpecialization* p1, const DeviceTypeTemplateSpecialization* p2) { return (p1->key() < p2->key()); } }; /** * @brief An enum of all device types. * * Device types are tablet components like the stylus, the eraser or the pad itself. * This enumeration ensures that only correct device type identifiers are sent via * D-Bus by taking care of converting them to a string and providing a way to map * these strings back to a device type. *
* This class also helps to ease maintenance by passing the responsibility for checking * for correct device types to the compiler. When using this enumeration it is no * longer possible to have method/d-bus calls fail because of typos in the device type * identifier. Also refactoring is much easier. */ class DeviceType : public DeviceTypeTemplateSpecialization { public: //! Compare operator which compares the keys case-insensitive. bool operator< (const DeviceType& other) const; static const DeviceType Cursor; static const DeviceType Eraser; static const DeviceType Pad; static const DeviceType Stylus; static const DeviceType Touch; private: /** * Private constructor to initialize the static instances of this class. */ DeviceType(const QString& key) : DeviceTypeTemplateSpecialization(this, key) {} }; // CLASS /* * Declare static instances-container of the DeviceType template specialization. */ template<> DeviceTypeTemplateSpecialization::Container DeviceTypeTemplateSpecialization::instances; } // NAMESPACE #endif // HEADER PROTECTION diff --git a/src/common/screenrotation.h b/src/common/screenrotation.h index 03632e0..de5a55c 100644 --- a/src/common/screenrotation.h +++ b/src/common/screenrotation.h @@ -1,84 +1,84 @@ /* * This file is part of the KDE wacomtablet project. For copyright * information and license terms see the AUTHORS and COPYING files * in the top-level directory of this distribution. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef SCREENROTATION_H #define SCREENROTATION_H #include #include "enum.h" #include "property.h" namespace Wacom { class ScreenRotation; -class ScreenRotationTemplateSpecializationLessFunctor; +struct ScreenRotationTemplateSpecializationLessFunctor; /** * @brief Helper Typedef! Do not use! * * This typedef is required by the ScreenRotation class. It eases maintenane of template parameters. */ typedef Enum ScreenRotationTemplateSpecialization; /** * @brief Helper Class! Do not use! * * This functor is required by the ScreenRotation class to sort its instances. */ struct ScreenRotationTemplateSpecializationLessFunctor { bool operator()(const ScreenRotationTemplateSpecialization* p1, const ScreenRotationTemplateSpecialization* p2) { return (p1->key() < p2->key()); } }; class ScreenRotation : public ScreenRotationTemplateSpecialization { public: static const ScreenRotation NONE; static const ScreenRotation CCW; static const ScreenRotation HALF; static const ScreenRotation CW; static const ScreenRotation AUTO; static const ScreenRotation AUTO_INVERTED; const ScreenRotation& invert() const; private: ScreenRotation (const QString& key) : ScreenRotationTemplateSpecialization(this, key) {} }; // CLASS /* * Declare static instances-container of the template specialization. */ template<> ScreenRotationTemplateSpecialization::Container ScreenRotationTemplateSpecialization::instances; } // NAMESPACE #endif // HEADER PROTECTION diff --git a/src/common/tabletinfo.h b/src/common/tabletinfo.h index c58ed83..b79f16b 100644 --- a/src/common/tabletinfo.h +++ b/src/common/tabletinfo.h @@ -1,102 +1,102 @@ /* * This file is part of the KDE wacomtablet project. For copyright * information and license terms see the AUTHORS and COPYING files * in the top-level directory of this distribution. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef TABLETINFO_H #define TABLETINFO_H #include #include "enum.h" #include "property.h" namespace Wacom { // forward declaration class TabletInfo; -class TabletInfoTemplateSpecializationLessFunctor; +struct TabletInfoTemplateSpecializationLessFunctor; /** * @brief Helper Typedef! Do not use! * * This typedef is required by the TabletInfo class. It eases maintenane of template parameters. */ typedef Enum TabletInfoTemplateSpecialization; /** * @brief Helper Class! Do not use! * * This functor is required by the TabletInfo class to sort its instances. */ struct TabletInfoTemplateSpecializationLessFunctor { bool operator()(const TabletInfoTemplateSpecialization* p1, const TabletInfoTemplateSpecialization* p2) { return (p1->key() < p2->key()); } }; /** * @brief An enum of all supported device information properties. * * This enumeration ensures that only correct tablet info identifiers are sent via * D-Bus by taking care of converting them to a string and providing a way to map * these strings back to a tablet info type. *
* This class also helps to ease maintenance by passing the responsibility for checking * for correct tablet info types to the compiler. When using this enumeration it is no * longer possible to have method/d-bus calls fail because of typos in the tablet info * identifier. Also refactoring is much easier. */ class TabletInfo : public TabletInfoTemplateSpecialization { public: static const TabletInfo ButtonLayout; //!< The button layout. static const TabletInfo CompanyId; //!< The vendor identifier. static const TabletInfo CompanyName; //!< The vendor name. static const TabletInfo HasLeftTouchStrip; //!< Flag if this tablet has a left touch strip. static const TabletInfo HasRightTouchStrip; //!< Flag if this tablet has a right touch strip. static const TabletInfo HasTouchRing; //!< Flag if this tablet has a touch ring. static const TabletInfo HasWheel; //!< Flag if this tablet has a wheel. static const TabletInfo NumPadButtons; //!< Number of pad buttons. static const TabletInfo StatusLEDs; //!< Number of LED's that can display tablet modes (for Intuos) static const TabletInfo TabletId; //!< The tablet identifier as a four digit hex code. static const TabletInfo TabletModel; //!< The tablet model. static const TabletInfo TabletName; //!< The name of the tablet. static const TabletInfo TabletSerial; //!< The tablet serial id as reported by the wacom driver. private: /** * Private constructor for the static members of this class. */ TabletInfo(const QString& key) : TabletInfoTemplateSpecialization(this, key) {} }; // CLASS /* * Declare static instances-container of the TabletInfo template specialization. */ template<> TabletInfoTemplateSpecialization::Container TabletInfoTemplateSpecialization::instances; } // NAMESPACE #endif // HEADER PROTECTION diff --git a/src/kcmodule/kcmwacomtablet.cpp b/src/kcmodule/kcmwacomtablet.cpp index 59f72e4..60e1199 100644 --- a/src/kcmodule/kcmwacomtablet.cpp +++ b/src/kcmodule/kcmwacomtablet.cpp @@ -1,109 +1,108 @@ /* * This file is part of the KDE wacomtablet project. For copyright * information and license terms see the AUTHORS and COPYING files * in the top-level directory of this distribution. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "kcmwacomtablet.h" #include "kcmwacomtabletwidget.h" #include "../wacomtablet-version.h" #include "aboutdata.h" #include "profilemanagement.h" #include "dbustabletinterface.h" // KDE includes #include #include #include #include #include //Qt includes #include using namespace Wacom; K_PLUGIN_FACTORY(KCMWacomTabletFactory, registerPlugin();) -K_EXPORT_PLUGIN(KCMWacomTabletFactory("kcm_wacomtablet")) KCMWacomTablet::KCMWacomTablet(QWidget *parent, const QVariantList & args) : KCModule(parent, args) , m_changed(false) { initUi(); } KCMWacomTablet::~KCMWacomTablet() { if (m_layout) { delete m_layout; } if (m_tabletWidget) { delete m_tabletWidget; } // This makes sure all global shortcuts are restored by our daemon. // Unfortunately KAction disables all global shortcuts on destruction. // There is no way to stop it from doing that so we have to use this // workaround and reload the current profile here. //BUG restore global shortcuts on exit //DBusTabletInterface::instance().setProfile( d->tabletId, , ProfileManagement::instance().profileName() ); } void KCMWacomTablet::initUi() { // about data will be deleted by KCModule AboutData *about = new AboutData(QLatin1Literal("kcm_wacomtablet"), i18n("Graphic Tablet Configuration"), QLatin1String(WACOMTABLET_VERSION_STRING), i18n("A configurator for graphic tablets"), i18n("In this module you can configure your Wacom tablet profiles")); // setup kcm module setAboutData(about); setButtons(Apply | Help); // setup module ui m_tabletWidget = new KCMWacomTabletWidget(this); m_layout = new QVBoxLayout(this); m_layout->setMargin(0); m_layout->addWidget(m_tabletWidget); // connect signals connect(m_tabletWidget, SIGNAL(changed(bool)), SIGNAL(changed(bool))); } void KCMWacomTablet::load() { if (m_tabletWidget) { m_tabletWidget->reloadProfile(); } emit changed(false); } void KCMWacomTablet::save() { if (m_tabletWidget) { m_tabletWidget->saveProfile(); } emit changed(false); } #include "kcmwacomtablet.moc" diff --git a/src/kded/procsystemadaptor.cpp b/src/kded/procsystemadaptor.cpp index 9f5357f..d89430b 100644 --- a/src/kded/procsystemadaptor.cpp +++ b/src/kded/procsystemadaptor.cpp @@ -1,109 +1,107 @@ /* * This file is part of the KDE wacomtablet project. For copyright * information and license terms see the AUTHORS and COPYING files * in the top-level directory of this distribution. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "procsystemadaptor.h" #include "logging.h" #include "procsystemproperty.h" #include using namespace Wacom; namespace Wacom { class ProcSystemAdaptorPrivate { public: QString deviceName; }; // CLASS } // NAMESPACE ProcSystemAdaptor::ProcSystemAdaptor(const QString& deviceName) : PropertyAdaptor(nullptr), d_ptr(new ProcSystemAdaptorPrivate) { Q_D(ProcSystemAdaptor); d->deviceName = deviceName; } ProcSystemAdaptor::~ProcSystemAdaptor() { delete this->d_ptr; } const QList< Property > ProcSystemAdaptor::getProperties() const { return ProcSystemProperty::ids(); } const QString ProcSystemAdaptor::getProperty(const Property& property) const { Q_D(const ProcSystemAdaptor); qCWarning(KDED) << QString::fromLatin1("Can not get unsupported property '%1' from device '%2' using proc system!").arg(property.key()).arg(d->deviceName); return QString(); } bool ProcSystemAdaptor::setProperty(const Property& property, const QString& value) { - Q_D(const ProcSystemAdaptor); - qCDebug(KDED) << QString::fromLatin1("Setting property '%1' to '%2'.").arg(property.key()).arg(value); // https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-driver-wacom /* /sys/bus/usb/devices/-:./wacom_led/status_led0_select Writing to this file sets which one of the four (for Intuos 4 and Intuos 5) or of the right four (for Cintiq 21UX2 and Cintiq 24HD) status LEDs is active (0..3). The other three LEDs on the same side are always inactive. */ /* /sys/bus/usb/devices/-:./wacom_led/status_led1_select Writing to this file sets which one of the left four (for Cintiq 21UX2 and Cintiq 24HD) status LEDs is active (0..3). The other three LEDs on the left are always inactive. */ int statusLed = value.toInt(); QString cmd; if(statusLed < 4 && statusLed >= 0) { cmd = QString::fromLatin1("bash -c \"echo %1 > /sys/bus/usb/devices/*/wacom_led/status_led0_select\"").arg(statusLed); } else if(statusLed < 8 && statusLed >= 4) { statusLed -= 4; cmd = QString::fromLatin1("bash -c \"echo %1 > /sys/bus/usb/devices/*/wacom_led/status_led1_select\"").arg(statusLed); } else { return false; } int ret = QProcess::execute(cmd); return ret == 0; } bool ProcSystemAdaptor::supportsProperty(const Property& property) const { return (ProcSystemProperty::map(property)); } diff --git a/src/kded/x11eventnotifier.h b/src/kded/x11eventnotifier.h index dc9f8a9..d372278 100644 --- a/src/kded/x11eventnotifier.h +++ b/src/kded/x11eventnotifier.h @@ -1,89 +1,89 @@ /* * This file is part of the KDE wacomtablet project. For copyright * information and license terms see the AUTHORS and COPYING files * in the top-level directory of this distribution. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef X11EVENTNOTIFIER_H #define X11EVENTNOTIFIER_H #include "eventnotifier.h" #include #include namespace Wacom { class X11EventNotifierPrivate; /** * @brief Singleton that listens to X11 events, mainly tablet plug/unplug events */ class X11EventNotifier : public EventNotifier, public QAbstractNativeEventFilter { Q_OBJECT public: virtual ~X11EventNotifier(); /** * Returns an instance of this class. */ static X11EventNotifier& instance(); /** * @see EventNotifier::start() */ - void start(); + void start() final; /** * @see EventNotifier::stop() */ - void stop(); + void stop() final; protected: /** * Called by Qt when a new X11 event is detected. */ virtual bool nativeEventFilter(const QByteArray& eventType, void* message, long int* result) Q_DECL_OVERRIDE; private: X11EventNotifier(); explicit X11EventNotifier(const X11EventNotifier& notifier) = delete; X11EventNotifier& operator= (const X11EventNotifier& notifier) = delete; /** * Handles X11 input events which signal adding or removal of a device. * This method should not be called directly, but only by our X11 event * handler method. */ void handleX11InputEvent(xcb_ge_generic_event_t* event); /** * Register the eventhandler with the X11 system */ int registerForNewDeviceEvent(xcb_connection_t* display); Q_DECLARE_PRIVATE( X11EventNotifier ) X11EventNotifierPrivate *const d_ptr; }; // CLASS } // NAMESPACE #endif // HEADER PROTECTION