File indexing completed on 2024-04-21 16:11:00

0001 /*
0002  *   SPDX-FileCopyrightText: 2022 Bart Ribbers <bribbers@disroot.org>
0003  *
0004  *   SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005  */
0006 
0007 #pragma once
0008 
0009 #include <QObject>
0010 #include <QSet>
0011 
0012 #include <unistd.h>
0013 
0014 enum DeviceType {
0015     DeviceCEC,
0016     DeviceWiimote,
0017     DeviceGamepad
0018 };
0019 
0020 class Device : public QObject
0021 {
0022     Q_OBJECT
0023 
0024 public:
0025     Device() = default;
0026     Device(DeviceType deviceType, QString name, QString uniqueIdentifier);
0027     ~Device();
0028 
0029     void setIndex(int index);
0030     QString getUniqueIdentifier();
0031 
0032     QString getName();
0033     DeviceType getDeviceType();
0034     QString iconName() const;
0035 
0036     /// needs to be called before newDevice() is called
0037     void setUsedKeys(const QSet<int> &keys) { m_usedKeys = keys; }
0038     QSet<int> usedKeys() const { return m_usedKeys; }
0039 
0040 public slots:
0041     virtual void watchEvents() { return; };
0042 
0043 Q_SIGNALS:
0044     void deviceDisconnected(int index);
0045 
0046 protected:
0047     int m_index = -1;
0048     QString m_uniqueIdentifier;
0049     QString m_name;
0050     DeviceType m_deviceType;
0051     QSet<int> m_usedKeys;
0052 };