File indexing completed on 2024-05-12 05:35:48

0001 /*
0002     SPDX-FileCopyrightText: 2017 Xuetian Weng <wengxt@gmail.com>
0003     SPDX-FileCopyrightText: 2018 Roman Gilg <subdiff@gmail.com>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #pragma once
0009 
0010 #include <config-build-options.h>
0011 
0012 #include <QList>
0013 #include <QObject>
0014 #include <QVariantHash>
0015 #include <memory> // std::unique_ptr
0016 
0017 enum class InputBackendMode {
0018 #if BUILD_KCM_MOUSE_KWIN_WAYLAND
0019     KWinWayland = 0,
0020 #endif
0021 #if BUILD_KCM_MOUSE_X11
0022     XLibinput = 1,
0023     XEvdev = 2,
0024 #endif
0025 };
0026 
0027 class InputBackend : public QObject
0028 {
0029     Q_OBJECT
0030 
0031 protected:
0032     explicit InputBackend(QObject *parent)
0033         : QObject(parent)
0034     {
0035     }
0036     InputBackendMode m_mode;
0037 
0038 public:
0039     static InputBackend *implementation(QObject *parent = nullptr);
0040 
0041     InputBackendMode mode()
0042     {
0043         return m_mode;
0044     }
0045 
0046     virtual void kcmInit()
0047     {
0048     }
0049 
0050     virtual bool isValid() const
0051     {
0052         return false;
0053     }
0054 
0055     virtual void load()
0056     {
0057     }
0058 
0059     virtual bool applyConfig(const QVariantHash &)
0060     {
0061         return false;
0062     }
0063     virtual bool getConfig(QVariantHash &)
0064     {
0065         return false;
0066     }
0067 
0068     virtual bool applyConfig()
0069     {
0070         return false;
0071     }
0072     virtual bool getConfig()
0073     {
0074         return false;
0075     }
0076 
0077     virtual bool getDefaultConfig()
0078     {
0079         return false;
0080     }
0081     virtual bool isChangedConfig() const
0082     {
0083         return false;
0084     }
0085 
0086     virtual QString errorString() const
0087     {
0088         return QString();
0089     }
0090 
0091     virtual int deviceCount() const
0092     {
0093         return 0;
0094     }
0095     virtual QList<QObject *> getDevices() const
0096     {
0097         return QList<QObject *>();
0098     }
0099 
0100 Q_SIGNALS:
0101     void deviceAdded(bool success);
0102     void deviceRemoved(int index);
0103 };