MyScript Interactive Ink SDK 4.5.0
PointerEvent.h
1// Copyright @ MyScript. All rights reserved.
2
3#pragma once
4
5#include <iink/APIVisibility.h>
6
7#include <stdexcept>
8#include <string>
9#include <cstdint>
10
11namespace myscript {
12namespace iink {
13
17enum class PointerType
18{
19 PEN = 0,
20 TOUCH = 1,
21 ERASER = 2,
22 MOUSE = 3,
23 CUSTOM_1 = 4,
24 CUSTOM_2 = 5,
25 CUSTOM_3 = 6,
26 CUSTOM_4 = 7,
27 CUSTOM_5 = 8
28};
29
34{
35 DOWN,
36 MOVE,
37 UP,
38 CANCEL
39};
40
45{
47 float x = 0.f;
48 float y = 0.f;
49 int64_t t = -1;
50 float f = 1.f;
51 float tilt = -1.f;
52 float orientation = -10.f;
54 int pointerId = -1;
56 PointerEvent() = default;
57
66 PointerEvent& down(float x, float y) { this->eventType = PointerEventType::DOWN; this->x = x; this->y = y; return *this; }
67
76 PointerEvent& move(float x, float y) { this->eventType = PointerEventType::MOVE; this->x = x; this->y = y; return *this; }
77
86 PointerEvent& up(float x, float y) { this->eventType = PointerEventType::UP; this->x = x; this->y = y; return *this; }
87
95 PointerEvent& timestamp(int64_t t) { this->t = t; return *this; }
96
104 PointerEvent& force(float f) { this->f = f; return *this; }
105
115 PointerEvent& tiltAngle(float tilt) { this->tilt = tilt; return *this; }
116
126 PointerEvent& orientationAngle(float orientation) { this->orientation = orientation; return *this; }
127
135 PointerEvent& type(PointerType pointerType) { this->pointerType = pointerType; return *this; }
136
144 PointerEvent& id(int pointerId) { this->pointerId = pointerId; return *this; }
145
153 IINK_API bool hasTiltAndOrientation() const;
154};
155
159class pointer_sequence_error : public std::runtime_error
160{
161public:
162 pointer_sequence_error(const std::string& what = "") : std::runtime_error(what) {}
163 pointer_sequence_error(const char* what_arg) : std::runtime_error(what_arg) {}
164 pointer_sequence_error(const pointer_sequence_error& other) noexcept : std::runtime_error(other) {}
165};
166
167}
168}
Definition: PointerEvent.h:160
pointer_sequence_error(const char *what_arg)
Definition: PointerEvent.h:163
pointer_sequence_error(const std::string &what="")
Definition: PointerEvent.h:162
pointer_sequence_error(const pointer_sequence_error &other) noexcept
Definition: PointerEvent.h:164
PointerType
Definition: PointerEvent.h:18
PointerEventType
Definition: PointerEvent.h:34
Definition: Configuration.h:10
Definition: PointerEvent.h:45
float x
Definition: PointerEvent.h:47
PointerEvent & move(float x, float y)
Definition: PointerEvent.h:76
PointerEvent & id(int pointerId)
Definition: PointerEvent.h:144
int pointerId
Definition: PointerEvent.h:54
float y
Definition: PointerEvent.h:48
PointerEvent & timestamp(int64_t t)
Definition: PointerEvent.h:95
PointerType pointerType
Definition: PointerEvent.h:53
PointerEvent & force(float f)
Definition: PointerEvent.h:104
float f
Definition: PointerEvent.h:50
PointerEvent & down(float x, float y)
Definition: PointerEvent.h:66
bool hasTiltAndOrientation() const
PointerEventType eventType
Definition: PointerEvent.h:46
float tilt
Definition: PointerEvent.h:51
float orientation
Definition: PointerEvent.h:52
PointerEvent & orientationAngle(float orientation)
Definition: PointerEvent.h:126
PointerEvent & tiltAngle(float tilt)
Definition: PointerEvent.h:115
int64_t t
Definition: PointerEvent.h:49
PointerEvent & type(PointerType pointerType)
Definition: PointerEvent.h:135
PointerEvent & up(float x, float y)
Definition: PointerEvent.h:86