~ubuntu-branches/ubuntu/raring/recorditnow/raring

« back to all changes in this revision

Viewing changes to src/keymon/manager.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2011-01-09 14:54:01 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20110109145401-gyckb4airz4fio50
Tags: 0.8.1-0ubuntu1
* New upstream release. (LP: #681270)
  - Update debian/copyright.
* Build-depend on recordmydesktop.
* Add a watch file.
* Drop 01_fix_ftbfs_kwarning_call.diff, fixed upstream.
* Add 01_joschy_install_to_usr_lib.diff.
* Add 02_fix_ftbfs_no-add-needed.diff.
* Add 03_dont_install_header_files.diff.
* Replace dependency on libpolkit-qt-1-0 with policykit-1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/***************************************************************************
2
 
 *   Copyright (C) 2009 by Kai Dombrowe <just89@gmx.de>                    *
 
2
 *   Copyright (C) 2010 by Kai Dombrowe <just89@gmx.de>                    *
3
3
 *                                                                         *
4
4
 *   This program is free software; you can redistribute it and/or modify  *
5
5
 *   it under the terms of the GNU General Public License as published by  *
21
21
#include "manager.h"
22
22
#include "device.h"
23
23
 
 
24
// KDE
 
25
#include <kdebug.h>
 
26
 
 
27
// Qt
 
28
#include <QtCore/QFile>
 
29
#include <QtCore/QDir>
 
30
 
 
31
// C
 
32
#include <linux/input.h>
 
33
#include <fcntl.h>
 
34
#include <unistd.h>
 
35
 
 
36
// Solid
 
37
#include <solid/device.h>
 
38
#include <solid/deviceinterface.h>
 
39
#include <solid/genericinterface.h>
 
40
#include <solid/predicate.h>
 
41
 
24
42
 
25
43
namespace KeyMon {
26
44
 
43
61
}
44
62
 
45
63
 
46
 
KeyMon::Device *Manager::watch(const QString &device, QObject *parent)
47
 
{
48
 
 
49
 
    KeyMon::Device *dev = new KeyMon::Device(parent, device);
50
 
    return dev;
51
 
 
52
 
}
53
 
 
 
64
QList<KeyMon::DeviceInfo> Manager::getInputDeviceList()
 
65
{
 
66
 
 
67
    QList<KeyMon::DeviceInfo> list;
 
68
    foreach (const Solid::Device &device, Solid::Device::allDevices()) {
 
69
 
 
70
        bool found = false;
 
71
        KeyMon::DeviceInfo info;
 
72
        const Solid::GenericInterface *interface = device.as<Solid::GenericInterface>();
 
73
 
 
74
        if (interface && interface->isValid()) {
 
75
            foreach (const QString &cap, interface->property("info.capabilities").toStringList()) {
 
76
                if (cap == QLatin1String("input.mouse")) {
 
77
                    if (interface->property("input.x11_driver").toString() != QLatin1String("evdev")) {
 
78
                        break;
 
79
                    }
 
80
                    info.file = interface->property("input.device").toString();
 
81
                    info.uuid = device.udi();
 
82
                    info.name = device.product();
 
83
                    info.icon = device.icon();
 
84
                    info.type = KeyMon::DeviceInfo::MouseType;
 
85
                    found = true;
 
86
                    break;
 
87
 
 
88
                } else if (cap == QLatin1String("input.keyboard")) {
 
89
                    if (interface->property("input.x11_driver").toString() != QLatin1String("evdev")) {
 
90
                        break;
 
91
                    }
 
92
                    info.file = interface->property("input.device").toString();
 
93
                    info.uuid = device.udi();
 
94
                    info.name = device.product();
 
95
                    info.icon = device.icon();
 
96
                    info.type = KeyMon::DeviceInfo::KeyboardType;
 
97
                    found = true;
 
98
                    break;
 
99
                }
 
100
            }
 
101
 
 
102
            if (found) {
 
103
                kDebug() << "Found input device:" << info.name;
 
104
                list.append(info);
 
105
            }
 
106
 
 
107
 
 
108
        }
 
109
    }
 
110
    return list;
 
111
 
 
112
}
 
113
 
 
114
 
 
115
QString Manager::fileForDevice(const KeyMon::DeviceInfo &info)
 
116
{
 
117
 
 
118
    Solid::Device device = Solid::Device(info.uuid);
 
119
    if (device.isValid()) {
 
120
        const Solid::GenericInterface *interface = device.as<Solid::GenericInterface>();
 
121
        if (interface && interface->isValid()) {
 
122
            return interface->property("input.device").toString();
 
123
        } else {
 
124
            kWarning() << "Invalid interface!";
 
125
            return QString();
 
126
        }
 
127
    }
 
128
    kWarning() << "Device not found...";
 
129
    return QString();
 
130
 
 
131
}
54
132
 
55
133
 
56
134
}; // Namespace KeyMon