Krita Source Code Documentation
Loading...
Searching...
No Matches
KoInputDevice.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2007 Thomas Zander <zander@kde.org>
3 *
4 SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
7#include "KoInputDevice.h"
8
9class Q_DECL_HIDDEN KoInputDevice::Private
10{
11public:
13 : device(d),
14 pointer(p),
15 uniqueTabletId(id),
16 mouse(m) {
17 }
21 bool mouse;
22};
23
25 : d(new Private(device, pointer, uniqueTabletId, false))
26{
27}
28
33
35 : d(new Private(other.d->device, other.d->pointer, other.d->uniqueTabletId, other.d->mouse))
36{
37}
38
39
41{
42 delete d;
43}
44
46{
47 return d->device;
48}
49
51{
52 return d->pointer;
53}
54
56{
57 return d->uniqueTabletId;
58}
59
61{
62 // sometimes, the system gives us tablet events with NoDevice or UnknownPointer. This is
63 // likely an XInput2 bug. However, assuming that if cannot identify the tablet device we've
64 // actually got a mouse is reasonable. See https://bugs.kde.org/show_bug.cgi?id=283130.
65 return d->mouse || d->device == KoInputDevice::InputDevice::Unknown
67}
68
69
71{
72 return d->device == other.d->device && d->pointer == other.d->pointer &&
73 d->uniqueTabletId == other.d->uniqueTabletId && d->mouse == other.d->mouse;
74}
75
77{
78 d->device = other.d->device;
79 d->pointer = other.d->pointer;
80 d->uniqueTabletId = other.d->uniqueTabletId;
81 d->mouse = other.d->mouse;
82 return *this;
83}
84
85// static
91
92
93
95{
97 return id;
98}
99
100// static
106
107// static
113
114QDebug operator<<(QDebug dbg, const KoInputDevice &device)
115{
116 if (device.isMouse())
117 dbg.nospace() << "mouse";
118 else {
119 switch (device.pointer()) {
121 dbg.nospace() << "unknown pointer";
122 break;
124 dbg.nospace() << "pen";
125 break;
127 dbg.nospace() << "cursor";
128 break;
130 dbg.nospace() << "eraser";
131 break;
132 default:
133 dbg.space() << "Unsupported pointer type";
134 }
135 switch(device.device()) {
137 dbg.space() << "no device";
138 break;
140 dbg.space() << "puck";
141 break;
143 dbg.space() << "stylus";
144 break;
146 dbg.space() << "airbrush";
147 break;
148 default:
149 dbg.space() << "Unsupported device type";
150 }
151 dbg.space() << "(id: " << device.uniqueTabletId() << ")";
152 }
153 return dbg.space();
154}
const Params2D p
QDebug operator<<(QDebug dbg, const KoInputDevice &device)
KoInputDevice & operator=(const KoInputDevice &)
assignment
KoInputDevice::InputDevice device
KoInputDevice::Pointer pointer
static KoInputDevice eraser()
Wacom eraser.
Private(KoInputDevice::InputDevice d, KoInputDevice::Pointer p, qint64 id, bool m)
bool isMouse() const
static KoInputDevice stylus()
Wacom style/pen.
bool operator==(const KoInputDevice &) const
equal
Private *const d
static KoInputDevice invalid()
invalid input device
@ Unknown
Definition psd.h:44