MyScript Interactive Ink SDK  4.1.2
PointerEvent.h
1 // Copyright @ MyScript. All rights reserved.
2 
3 #pragma once
4 
5 #ifndef IINK_API
6 #if defined(_WIN32)
7 #ifdef IINK_IMPL
8 #define IINK_API __declspec(dllexport)
9 #else
10 #define IINK_API __declspec(dllimport)
11 #endif
12 #else
13 #define IINK_API
14 #endif
15 #endif
16 
17 #include <stdexcept>
18 #include <string>
19 
20 #include <cstdint>
21 
22 namespace myscript {
23 namespace iink {
24 
28 enum class PointerType
29 {
30  PEN = 0,
31  TOUCH = 1,
32  ERASER = 2,
33  MOUSE = 3,
34  CUSTOM_1 = 4,
35  CUSTOM_2 = 5,
36  CUSTOM_3 = 6,
37  CUSTOM_4 = 7,
38  CUSTOM_5 = 8
39 };
40 
44 enum class PointerEventType
45 {
46  DOWN,
47  MOVE,
48  UP,
49  CANCEL
50 };
51 
56 {
58  float x = 0.f;
59  float y = 0.f;
60  int64_t t = -1;
61  float f = 1.f;
62  float tilt = -1.f;
63  float orientation = -10.f;
65  int pointerId = -1;
67  PointerEvent() = default;
68 
77  PointerEvent& down(float x, float y) { this->eventType = PointerEventType::DOWN; this->x = x; this->y = y; return *this; }
78 
87  PointerEvent& move(float x, float y) { this->eventType = PointerEventType::MOVE; this->x = x; this->y = y; return *this; }
88 
97  PointerEvent& up(float x, float y) { this->eventType = PointerEventType::UP; this->x = x; this->y = y; return *this; }
98 
106  PointerEvent& timestamp(int64_t t) { this->t = t; return *this; }
107 
115  PointerEvent& force(float f) { this->f = f; return *this; }
116 
126  PointerEvent& tiltAngle(float tilt) { this->tilt = tilt; return *this; }
127 
137  PointerEvent& orientationAngle(float orientation) { this->orientation = orientation; return *this; }
138 
146  PointerEvent& type(PointerType pointerType) { this->pointerType = pointerType; return *this; }
147 
155  PointerEvent& id(int pointerId) { this->pointerId = pointerId; return *this; }
156 
164  IINK_API bool hasTiltAndOrientation() const;
165 };
166 
170 class pointer_sequence_error : public std::runtime_error
171 {
172 public:
173  pointer_sequence_error(const std::string& what = "") : std::runtime_error(what) {}
174  pointer_sequence_error(const char* what_arg) : std::runtime_error(what_arg) {}
175  pointer_sequence_error(const pointer_sequence_error& other) noexcept : std::runtime_error(other) {}
176 };
177 
178 }
179 }
Definition: PointerEvent.h:171
pointer_sequence_error(const char *what_arg)
Definition: PointerEvent.h:174
pointer_sequence_error(const std::string &what="")
Definition: PointerEvent.h:173
pointer_sequence_error(const pointer_sequence_error &other) noexcept
Definition: PointerEvent.h:175
PointerType
Definition: PointerEvent.h:29
PointerEventType
Definition: PointerEvent.h:45
Definition: Configuration.h:10
Definition: PointerEvent.h:56
float x
Definition: PointerEvent.h:58
int pointerId
Definition: PointerEvent.h:65
PointerEvent & id(int pointerId)
Definition: PointerEvent.h:155
PointerEvent & tiltAngle(float tilt)
Definition: PointerEvent.h:126
float y
Definition: PointerEvent.h:59
PointerType pointerType
Definition: PointerEvent.h:64
float f
Definition: PointerEvent.h:61
PointerEvent & up(float x, float y)
Definition: PointerEvent.h:97
bool hasTiltAndOrientation() const
PointerEventType eventType
Definition: PointerEvent.h:57
PointerEvent & type(PointerType pointerType)
Definition: PointerEvent.h:146
PointerEvent & down(float x, float y)
Definition: PointerEvent.h:77
PointerEvent & move(float x, float y)
Definition: PointerEvent.h:87
float tilt
Definition: PointerEvent.h:62
PointerEvent & orientationAngle(float orientation)
Definition: PointerEvent.h:137
float orientation
Definition: PointerEvent.h:63
PointerEvent & timestamp(int64_t t)
Definition: PointerEvent.h:106
PointerEvent & force(float f)
Definition: PointerEvent.h:115
int64_t t
Definition: PointerEvent.h:60