Krita Source Code Documentation
Loading...
Searching...
No Matches
KoInputDevice Class Reference

#include <KoInputDevice.h>

+ Inheritance diagram for KoInputDevice:

Public Types

enum class  InputDevice {
  Unknown = 0x0000 , Mouse = 0x0001 , TouchScreen = 0x0002 , TouchPad = 0x0004 ,
  Puck = 0x0008 , Stylus = 0x0010 , Airbrush = 0x0020 , Keyboard = 0x1000 ,
  AllDevices = 0x7FFFFFFF
}
 
enum class  Pointer {
  Unknown = 0 , Generic = 0x0001 , Finger = 0x0002 , Pen = 0x0004 ,
  Eraser = 0x0008 , Cursor = 0x0010 , AllPointerTypes = 0x7FFF
}
 

Public Member Functions

InputDevice device () const
 
bool isMouse () const
 
 KoInputDevice ()
 
 KoInputDevice (const KoInputDevice &other)
 
 KoInputDevice (InputDevice device, Pointer pointer, qint64 uniqueTabletId=-1)
 
KoInputDeviceoperator= (const KoInputDevice &)
 assignment
 
bool operator== (const KoInputDevice &) const
 equal
 
Pointer pointer () const
 
 Private (KoInputDevice::InputDevice d, KoInputDevice::Pointer p, qint64 id, bool m)
 
qint64 uniqueTabletId () const
 
 ~KoInputDevice ()
 

Static Public Member Functions

static InputDevice convertDeviceType (QTabletEvent *event)
 
static Pointer convertPointerType (QTabletEvent *event)
 
static KoInputDevice eraser ()
 Wacom eraser.
 
static KoInputDevice invalid ()
 invalid input device
 
static KoInputDevice mouse ()
 Standard mouse.
 
static KoInputDevice stylus ()
 Wacom style/pen.
 

Public Attributes

KoInputDevice::InputDevice device
 
bool mouse
 
KoInputDevice::Pointer pointer
 
qint64 uniqueTabletId
 

Private Attributes

Private *const d
 
- Private Attributes inherited from Private
KisCanvas2canvas
 
int displayedFrame
 
int intendedFrame
 

Additional Inherited Members

- Private Member Functions inherited from Private
 Private (KisCanvas2 *c)
 

Detailed Description

This class represents an input device. A user can manipulate flake-shapes using a large variety of input devices. This ranges from a mouse to a paintbrush-like tool connected to a tablet.

Definition at line 9 of file KoInputDevice.cpp.

Member Enumeration Documentation

◆ InputDevice

enum class KoInputDevice::InputDevice
strong
Enumerator
Unknown 
Mouse 
TouchScreen 
TouchPad 
Puck 
Stylus 
Airbrush 
Keyboard 
AllDevices 

Definition at line 36 of file KoInputDevice.h.

◆ Pointer

enum class KoInputDevice::Pointer
strong
Enumerator
Unknown 
Generic 
Finger 
Pen 
Eraser 
Cursor 
AllPointerTypes 

Definition at line 26 of file KoInputDevice.h.

26 {
27 Unknown = 0,
28 Generic = 0x0001, // mouse or similar
29 Finger = 0x0002, // touchscreen or pad
30 Pen = 0x0004, // stylus on a tablet
31 Eraser = 0x0008, // eraser end of a stylus
32 Cursor = 0x0010, // digitizer with crosshairs
33 AllPointerTypes = 0x7FFF
34 };

Constructor & Destructor Documentation

◆ KoInputDevice() [1/3]

KoInputDevice::KoInputDevice ( const KoInputDevice & other)

Copy constructor.

Definition at line 34 of file KoInputDevice.cpp.

35 : d(new Private(other.d->device, other.d->pointer, other.d->uniqueTabletId, other.d->mouse))
36{
37}
Private *const d

◆ KoInputDevice() [2/3]

KoInputDevice::KoInputDevice ( KoInputDevice::InputDevice device,
KoInputDevice::Pointer pointer,
qint64 uniqueTabletId = -1 )
explicit

Constructor for a tablet. Create a new input device with one of the many types that the tablet can have.

Parameters
devicethe device as found on a QTabletEvent
pointerthe pointer as found on a QTabletEvent
uniqueTabletIdthe uniqueId as found on a QTabletEvent

Definition at line 24 of file KoInputDevice.cpp.

25 : d(new Private(device, pointer, uniqueTabletId, false))
26{
27}
KoInputDevice::InputDevice device
KoInputDevice::Pointer pointer

◆ KoInputDevice() [3/3]

KoInputDevice::KoInputDevice ( )

Constructor for the mouse as input device.

Definition at line 29 of file KoInputDevice.cpp.

◆ ~KoInputDevice()

KoInputDevice::~KoInputDevice ( )

Definition at line 40 of file KoInputDevice.cpp.

41{
42 delete d;
43}

References d.

Member Function Documentation

◆ convertDeviceType()

static InputDevice KoInputDevice::convertDeviceType ( QTabletEvent * event)
inlinestatic

Definition at line 101 of file KoInputDevice.h.

102 {
103#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
104 switch (event->deviceType()) {
105 case QTabletEvent::NoDevice: {
107 }
108 break;
109 case QTabletEvent::Puck: {
110 return InputDevice::Puck;
111 }
112 break;
113 case QTabletEvent::Stylus: {
114 return InputDevice::Stylus;
115 }
116 break;
117 case QTabletEvent::Airbrush: {
119 }
120 case QTabletEvent::RotationStylus: {
121 // Note: Qt6 no longer has the RotationStylus device type, so we will
122 // have to stop supporting it.
123 return InputDevice::Stylus;
124 }
125 default:
127 }
128
129#else
130 QInputDevice::DeviceType deviceType = event->deviceType();
131 switch(deviceType) {
132 case QInputDevice::DeviceType::Unknown: {
134 }
135 break;
136 case QInputDevice::DeviceType::Mouse:{
137 return InputDevice::Mouse;
138 }
139 break;
140 case QInputDevice::DeviceType::TouchScreen:
141 {
143 }
144 break;
145 case QInputDevice::DeviceType::TouchPad:
146 {
148 }
149 break;
150 case QInputDevice::DeviceType::Puck:
151 {
152 return InputDevice::Puck;
153 }
154 break;
155 case QInputDevice::DeviceType::Stylus:
156 {
157 return InputDevice::Stylus;
158 }
159 break;
160 case QInputDevice::DeviceType::Airbrush:
161 {
163 }
164 break;
165 case QInputDevice::DeviceType::Keyboard:
166 {
168 }
169 break;
170 case QInputDevice::DeviceType::AllDevices:
171 {
173 }
174 default:
176 }
177#endif
178 }

◆ convertPointerType()

static Pointer KoInputDevice::convertPointerType ( QTabletEvent * event)
inlinestatic

Definition at line 48 of file KoInputDevice.h.

49 {
50#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
51 switch (event->pointerType()) {
52 case QTabletEvent::UnknownPointer: {
53 return Pointer::Unknown;
54 }
55 break;
56 case QTabletEvent::Pen: {
57 return Pointer::Pen;
58 }
59 break;
60 case QTabletEvent::Cursor: {
61 return Pointer::Cursor;
62 }
63 break;
64 case QTabletEvent::Eraser: {
65 return Pointer::Eraser;
66 }
67 default:
68 return Pointer::Unknown;
69 }
70#else
71 QPointingDevice::PointerType pointer = event->pointerType();
72 switch (pointer) {
73 case (QPointingDevice::PointerType::Unknown): {
74 return Pointer::Unknown;
75 } break;
76 case QPointingDevice::PointerType::Generic:{
77 return Pointer::Generic;
78 } break;
79 case QPointingDevice::PointerType::Finger:{
80 return Pointer::Finger;
81 } break;
82 case QPointingDevice::PointerType::Pen:{
83 return Pointer::Pen;
84 } break;
85 case QPointingDevice::PointerType::Eraser:{
86 return Pointer::Eraser;
87 } break;
88
89 case QPointingDevice::PointerType::Cursor:{
90 return Pointer::Cursor;
91 } break;
92 case QPointingDevice::PointerType::AllPointerTypes:{
94 } break;
95 default:
96 return Pointer::Unknown;
97 }
98#endif
99 }

◆ device()

InputDevice KoInputDevice::device ( ) const

Return the tablet device used

◆ eraser()

KoInputDevice KoInputDevice::eraser ( )
static

Wacom eraser.

Definition at line 108 of file KoInputDevice.cpp.

References Eraser, and Stylus.

◆ invalid()

KoInputDevice KoInputDevice::invalid ( )
static

invalid input device

Definition at line 86 of file KoInputDevice.cpp.

References Unknown.

◆ isMouse()

bool KoInputDevice::isMouse ( ) const

Return if this is a mouse device.

Definition at line 60 of file KoInputDevice.cpp.

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}

References d, and Unknown.

◆ mouse()

static KoInputDevice KoInputDevice::mouse ( )
static

Standard mouse.

◆ operator=()

KoInputDevice & KoInputDevice::operator= ( const KoInputDevice & other)

assignment

Definition at line 76 of file KoInputDevice.cpp.

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}

References d.

◆ operator==()

bool KoInputDevice::operator== ( const KoInputDevice & other) const

equal

Definition at line 70 of file KoInputDevice.cpp.

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}

References d.

◆ pointer()

Pointer KoInputDevice::pointer ( ) const

Return the pointer used

◆ Private()

KoInputDevice::Private ( KoInputDevice::InputDevice d,
KoInputDevice::Pointer p,
qint64 id,
bool m )
inline

Definition at line 12 of file KoInputDevice.cpp.

13 : device(d),
14 pointer(p),
16 mouse(m) {
17 }
const Params2D p

◆ stylus()

KoInputDevice KoInputDevice::stylus ( )
static

Wacom style/pen.

Definition at line 101 of file KoInputDevice.cpp.

References Pen, and Stylus.

◆ uniqueTabletId()

qint64 KoInputDevice::uniqueTabletId ( ) const

Return the unique tablet id as registered by QTabletEvents. Note that this id can change randomly, so it's not dependable.

See https://bugs.kde.org/show_bug.cgi?id=407659

Member Data Documentation

◆ d

Private* const KoInputDevice::d
private

Definition at line 237 of file KoInputDevice.h.

◆ device

KoInputDevice::InputDevice KoInputDevice::device

Definition at line 18 of file KoInputDevice.cpp.

◆ mouse

KoInputDevice KoInputDevice::mouse

Definition at line 21 of file KoInputDevice.cpp.

◆ pointer

KoInputDevice::Pointer KoInputDevice::pointer

Definition at line 19 of file KoInputDevice.cpp.

◆ uniqueTabletId

qint64 KoInputDevice::uniqueTabletId

Definition at line 20 of file KoInputDevice.cpp.


The documentation for this class was generated from the following files: