File: input-device-manager.h

package info (click to toggle)
ukui-settings-daemon 4.0.0.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,324 kB
  • sloc: cpp: 39,120; ansic: 3,240; xml: 1,570; sh: 88; makefile: 4
file content (122 lines) | stat: -rw-r--r-- 2,957 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/* -*- Mode: C++; indent-tabs-mode: nil; tab-width: 4 -*-
 * -*- coding: utf-8 -*-
 *
 * Copyright (C) 2023 KylinSoft Co., Ltd.
 *
 * 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 3 of the License, or
 * 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 <http://www.gnu.org/licenses/>.
 *
 * Authors: sundagao <sundagao@kylinos.cn>
 */

#ifndef INPUTDEVICEMANAGER_H
#define INPUTDEVICEMANAGER_H
#include <QObject>
#include <QTimer>
#include <QThread>
#include "input-device.h"
#include "input-gsettings.h"
#include "input-device-factory.h"

class InputDeviceFactor;
class InputDeviceManager : public QObject
{
    Q_OBJECT
    typedef QList<InputDevice*> DeviceList;
public:
    explicit InputDeviceManager(QObject *parent = nullptr);
    ~InputDeviceManager();
    void start();
    void stop();
    friend class InputXDeviceFactor;
    friend class InputWaylandDeviceFactor;

private:

    bool initDeviceFactor();
    /**
     * @brief 剔除特殊设备
     * 新版内核 无效mouse设备跟随touchpad上报,product id 一致
     */
    void eliminateSpecialDevice();

    /**
     * @brief 清空设备列表
     */
    void clearUpDeviceList();

    /**
     * @brief gsettings 监听
     */
    void connctGsettings();

    /**
     * @brief 根据设备类型筛选设备
     * @param device
     */
    void classifyDevice(InputDevice* device);

    /**
     * @brief 断开所有连接
     */
    void disconnectAll();

    /**
     * @brief 删除设备
     * @param deviceId 设备id
     * @return
     */
    bool deleteDevice(QVariant deviceId);

    /**
     * @brief 检测鼠标存在
     * @return true
     */
    bool existMouse();

    /**
     * @brief 测试打印设备列表
     */
    void testPrintDeviceList();

    /**
     * @brief 检测鼠标存在禁用触摸板 初始化时,设备插入时,设备移除时。
     */
    void disbleTouchpadMousePresent();

    /**
     * @brief deviceAdd
     * @param device
     */
    void deviceAdd(InputDevice* device);

    /**
     * @brief deviceRemove
     * @param deviceId
     */
    void deviceRemove(QVariant deviceId);
private:

private Q_SLOTS:
    void onMouseChanged(const QString&, QVariant);
    void onTouchpadChanged(const QString&, QVariant);
    void managerStart();
private:
    InputDeviceFactor* m_deviceFactor;
    InputGsettings* m_inputGsettings;
    DeviceList m_mouseList;
    DeviceList m_touchpadList;
    QTimer    *m_timer;
};

#endif // INPUTDEVICEMANAGER_H