MyScript Interactive Ink SDK  3.1.3
PointerEvent.h
1 // Copyright @ MyScript. All rights reserved.
2 
3 #pragma once
4 
5 #include <cstdint>
6 #include <stdexcept>
7 #include <string>
8 
9 namespace myscript {
10 namespace iink {
11 
15 enum class PointerType
16 {
17  PEN = 0,
18  TOUCH = 1,
19  ERASER = 2,
20  MOUSE = 3,
21  CUSTOM_1 = 4,
22  CUSTOM_2 = 5,
23  CUSTOM_3 = 6,
24  CUSTOM_4 = 7,
25  CUSTOM_5 = 8
26 };
27 
31 enum class PointerEventType
32 {
33  DOWN,
34  MOVE,
35  UP,
36  CANCEL
37 };
38 
43 {
45  float x = 0.f;
46  float y = 0.f;
47  int64_t t = -1;
48  float f = 0.0f;
50  int pointerId = -1;
52  PointerEvent() = default;
53 
62  PointerEvent& down(float x, float y) { this->eventType = PointerEventType::DOWN; this->x = x; this->y = y; return *this; }
63 
72  PointerEvent& move(float x, float y) { this->eventType = PointerEventType::MOVE; this->x = x; this->y = y; return *this; }
73 
82  PointerEvent& up(float x, float y) { this->eventType = PointerEventType::UP; this->x = x; this->y = y; return *this; }
83 
91  PointerEvent& timestamp(int64_t t) { this->t = t; return *this; }
92 
100  PointerEvent& force(float f) { this->f = f; return *this; }
101 
109  PointerEvent& type(PointerType pointerType) { this->pointerType = pointerType; return *this; }
110 
118  PointerEvent& id(int pointerId) { this->pointerId = pointerId; return *this; }
119 };
120 
124 class pointer_sequence_error : public std::runtime_error
125 {
126 public:
127  pointer_sequence_error(const std::string& what = "") : std::runtime_error(what) {}
128  pointer_sequence_error(const char* what_arg) : std::runtime_error(what_arg) {}
129  pointer_sequence_error(const pointer_sequence_error& other) noexcept : std::runtime_error(other) {}
130 };
131 
132 }
133 }
Definition: PointerEvent.h:125
pointer_sequence_error(const char *what_arg)
Definition: PointerEvent.h:128
pointer_sequence_error(const std::string &what="")
Definition: PointerEvent.h:127
pointer_sequence_error(const pointer_sequence_error &other) noexcept
Definition: PointerEvent.h:129
PointerType
Definition: PointerEvent.h:16
PointerEventType
Definition: PointerEvent.h:32
Definition: Configuration.h:11
Definition: PointerEvent.h:43
float x
Definition: PointerEvent.h:45
int pointerId
Definition: PointerEvent.h:50
PointerEvent & id(int pointerId)
Definition: PointerEvent.h:118
float y
Definition: PointerEvent.h:46
PointerType pointerType
Definition: PointerEvent.h:49
float f
Definition: PointerEvent.h:48
PointerEvent & up(float x, float y)
Definition: PointerEvent.h:82
PointerEventType eventType
Definition: PointerEvent.h:44
PointerEvent & type(PointerType pointerType)
Definition: PointerEvent.h:109
PointerEvent & down(float x, float y)
Definition: PointerEvent.h:62
PointerEvent & move(float x, float y)
Definition: PointerEvent.h:72
PointerEvent & timestamp(int64_t t)
Definition: PointerEvent.h:91
PointerEvent & force(float f)
Definition: PointerEvent.h:100
int64_t t
Definition: PointerEvent.h:47