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
9
class
Q_DECL_HIDDEN
KoInputDevice
::
Private
10
{
11
public
:
12
Private
(
KoInputDevice::InputDevice
d,
KoInputDevice::Pointer
p
, qint64
id
,
bool
m)
13
: device(d),
14
pointer(
p
),
15
uniqueTabletId(id),
16
mouse(m) {
17
}
18
KoInputDevice::InputDevice
device
;
19
KoInputDevice::Pointer
pointer
;
20
qint64
uniqueTabletId
;
21
bool
mouse
;
22
};
23
24
KoInputDevice::KoInputDevice
(
KoInputDevice::InputDevice
device,
KoInputDevice::Pointer
pointer, qint64 uniqueTabletId)
25
: d(new
Private
(device, pointer, uniqueTabletId, false))
26
{
27
}
28
29
KoInputDevice::KoInputDevice
()
30
: d(new
Private
(
KoInputDevice
::
InputDevice
::
Unknown
,
KoInputDevice
::
Pointer
::
Unknown
, -1, true))
31
{
32
}
33
34
KoInputDevice::KoInputDevice
(
const
KoInputDevice
&other)
35
: d(new
Private
(other.d->device, other.d->pointer, other.d->uniqueTabletId, other.d->mouse))
36
{
37
}
38
39
40
KoInputDevice::~KoInputDevice
()
41
{
42
delete
d
;
43
}
44
45
KoInputDevice::InputDevice
KoInputDevice::device
()
const
46
{
47
return
d
->device;
48
}
49
50
KoInputDevice::Pointer
KoInputDevice::pointer
()
const
51
{
52
return
d
->pointer;
53
}
54
55
qint64
KoInputDevice::uniqueTabletId
()
const
56
{
57
return
d
->uniqueTabletId;
58
}
59
60
bool
KoInputDevice::isMouse
()
const
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
66
||
d
->pointer ==
KoInputDevice::Pointer::Unknown
;
67
}
68
69
70
bool
KoInputDevice::operator==
(
const
KoInputDevice
&other)
const
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
76
KoInputDevice
&
KoInputDevice::operator=
(
const
KoInputDevice
& other)
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
86
KoInputDevice
KoInputDevice::invalid
()
87
{
88
KoInputDevice
id(
KoInputDevice::InputDevice::Unknown
,
KoInputDevice::Pointer::Unknown
);
89
return
id;
90
}
91
92
93
94
KoInputDevice
KoInputDevice::mouse
()
95
{
96
KoInputDevice
id;
97
return
id;
98
}
99
100
// static
101
KoInputDevice
KoInputDevice::stylus
()
102
{
103
KoInputDevice
id(
KoInputDevice::InputDevice::Stylus
,
KoInputDevice::Pointer::Pen
);
104
return
id;
105
}
106
107
// static
108
KoInputDevice
KoInputDevice::eraser
()
109
{
110
KoInputDevice
id(
KoInputDevice::InputDevice::Stylus
,
KoInputDevice::Pointer::Eraser
);
111
return
id;
112
}
113
114
QDebug
operator<<
(QDebug dbg,
const
KoInputDevice
&device)
115
{
116
if
(device.
isMouse
())
117
dbg.nospace() <<
"mouse"
;
118
else
{
119
switch
(device.
pointer
()) {
120
case
KoInputDevice::Pointer::Unknown
:
121
dbg.nospace() <<
"unknown pointer"
;
122
break
;
123
case
KoInputDevice::Pointer::Pen
:
124
dbg.nospace() <<
"pen"
;
125
break
;
126
case
KoInputDevice::Pointer::Cursor
:
127
dbg.nospace() <<
"cursor"
;
128
break
;
129
case
KoInputDevice::Pointer::Eraser
:
130
dbg.nospace() <<
"eraser"
;
131
break
;
132
default
:
133
dbg.space() <<
"Unsupported pointer type"
;
134
}
135
switch
(device.
device
()) {
136
case
KoInputDevice::InputDevice::Unknown
:
137
dbg.space() <<
"no device"
;
138
break
;
139
case
KoInputDevice::InputDevice::Puck
:
140
dbg.space() <<
"puck"
;
141
break
;
142
case
KoInputDevice::InputDevice::Stylus
:
143
dbg.space() <<
"stylus"
;
144
break
;
145
case
KoInputDevice::InputDevice::Airbrush
:
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
}
p
const Params2D p
Definition
KisBezierUtils.cpp:703
operator<<
QDebug operator<<(QDebug dbg, const KoInputDevice &device)
Definition
KoInputDevice.cpp:114
KoInputDevice.h
KoInputDevice
Definition
KoInputDevice.cpp:10
KoInputDevice::operator=
KoInputDevice & operator=(const KoInputDevice &)
assignment
Definition
KoInputDevice.cpp:76
KoInputDevice::device
KoInputDevice::InputDevice device
Definition
KoInputDevice.cpp:18
KoInputDevice::pointer
KoInputDevice::Pointer pointer
Definition
KoInputDevice.cpp:19
KoInputDevice::mouse
bool mouse
Definition
KoInputDevice.cpp:21
KoInputDevice::eraser
static KoInputDevice eraser()
Wacom eraser.
Definition
KoInputDevice.cpp:108
KoInputDevice::Private
Private(KoInputDevice::InputDevice d, KoInputDevice::Pointer p, qint64 id, bool m)
Definition
KoInputDevice.cpp:12
KoInputDevice::isMouse
bool isMouse() const
Definition
KoInputDevice.cpp:60
KoInputDevice::Pointer
Pointer
Definition
KoInputDevice.h:26
KoInputDevice::Pointer::Eraser
@ Eraser
KoInputDevice::Pointer::Unknown
@ Unknown
KoInputDevice::Pointer::Cursor
@ Cursor
KoInputDevice::Pointer::Pen
@ Pen
KoInputDevice::KoInputDevice
KoInputDevice()
Definition
KoInputDevice.cpp:29
KoInputDevice::stylus
static KoInputDevice stylus()
Wacom style/pen.
Definition
KoInputDevice.cpp:101
KoInputDevice::uniqueTabletId
qint64 uniqueTabletId
Definition
KoInputDevice.cpp:20
KoInputDevice::operator==
bool operator==(const KoInputDevice &) const
equal
Definition
KoInputDevice.cpp:70
KoInputDevice::~KoInputDevice
~KoInputDevice()
Definition
KoInputDevice.cpp:40
KoInputDevice::InputDevice
InputDevice
Definition
KoInputDevice.h:36
KoInputDevice::InputDevice::Unknown
@ Unknown
KoInputDevice::InputDevice::Puck
@ Puck
KoInputDevice::InputDevice::Airbrush
@ Airbrush
KoInputDevice::InputDevice::Stylus
@ Stylus
KoInputDevice::d
Private *const d
Definition
KoInputDevice.h:237
KoInputDevice::invalid
static KoInputDevice invalid()
invalid input device
Definition
KoInputDevice.cpp:86
Private
Definition
SvgTransformParser.cpp:20
Unknown
@ Unknown
Definition
psd.h:44
libs
flake
KoInputDevice.cpp
Generated at
2025-11-04 02:30:02+01:00
from
Krita
branch
master
, commit
c9dde2e79561a8aea4a7e8d9ac99c98a7bac9e52