-
Notifications
You must be signed in to change notification settings - Fork 0
/
libWSAController.h
90 lines (70 loc) · 3.27 KB
/
libWSAController.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#pragma once
#if defined(LIBWSACONTROLLER_EXPORT)
#define LIBWSACONTROLLER __declspec(dllexport)
#else
#define LIBWSACONTROLLER __declspec(dllimport)
#endif
namespace libWSAController
{
// void callback(sender, level, msg);
using lib_callback = std::function<void(std::string_view, std::string_view, std::string_view)>;
class IWSAController
{
public:
virtual bool Init(bool resizeWindow, bool goldenBorder, bool replace, lib_callback) PURE;
virtual void ReleaseAll() PURE;
virtual void AddPackageName(tstring pkgName) PURE; // Deprecated
virtual std::vector<tstring> GetSelectedPackageName() PURE; // Deprecated
virtual bool StartCapture(tstring pkgName) PURE;
virtual cv::Mat GetOnce(bool c3u8, tstring pkgName) PURE;
virtual cv::Mat PeekOnce(bool c3u8, tstring pkgName) PURE;
virtual bool EndCapture(tstring pkgName) PURE;
virtual bool InputInterrupt(tstring pkgName) PURE;
virtual bool MouseLeftClick(int x, int y, tstring pkgName) PURE;
virtual bool MouseLeftSwipe(int sx, int sy, int ex, int ey, int dur, int slow_end, tstring pkgName) PURE;
virtual bool TouchClick(int x, int y, tstring pkgName) PURE;
virtual bool TouchSwipe(int sx, int sy, int ex, int ey, int dur, int slow_end, tstring pkgName) PURE;
virtual bool MouseLeftDown(int x, int y, tstring pkgName) PURE;
virtual bool MouseMove(int x, int y, tstring pkgName) PURE;
virtual bool MouseLeftUp(int x, int y, tstring pkgName) PURE;
virtual UINT64 TouchDown(int x, int y, tstring pkgName) PURE;
virtual bool TouchMove(int x, int y, UINT64 id, tstring pkgName) PURE;
virtual bool TouchUp(int x, int y, UINT64 id, tstring pkgName) PURE;
virtual size_t CountTouchedPoints(tstring pkgName) PURE;
virtual void WaitInput(tstring pkgName) PURE;
};
class WSAControllerWrap
{
public:
static WSAControllerWrap LIBWSACONTROLLER CreateWSAController(lib_callback, bool resizeWindow, bool goldenBorder, bool replace);
WSAControllerWrap(std::nullptr_t = nullptr)
: m_(nullptr) {}
WSAControllerWrap(IWSAController* ptr)
: m_(ptr) {}
~WSAControllerWrap()
{
if (m_) { m_->ReleaseAll(); delete m_; }
m_ = nullptr;
}
WSAControllerWrap& operator=(const WSAControllerWrap&) = delete;
WSAControllerWrap& operator=(const WSAControllerWrap&&) = delete;
operator bool()
{
return (m_ != nullptr);
}
public:
bool StartCapture(tstring pkgName = {}) { return m_->StartCapture(pkgName); }
cv::Mat GetOnce(bool c3u8 = true, tstring pkgName = {}) { return m_->GetOnce(c3u8, pkgName); }
cv::Mat PeekOnce(bool c3u8 = true, tstring pkgName = {}) { return m_->PeekOnce(c3u8, pkgName); }
bool EndCapture(tstring pkgName = {}) { return m_->EndCapture(pkgName); }
bool MouseLeftClick(int x, int y, tstring pkgName = {}) { return m_->MouseLeftClick(x, y, pkgName); }
bool MouseLeftSwipe(int sx, int sy, int ex, int ey, int dur, int slow_end, tstring pkgName = {})
{ return m_->MouseLeftSwipe(sx, sy, ex, ey, dur, slow_end, pkgName); }
bool TouchClick(int x, int y, tstring pkgName = {}) { return m_->TouchClick(x, y, pkgName); }
bool TouchSwipe(int sx, int sy, int ex, int ey, int dur, int slow_end, tstring pkgName = {})
{ return m_->TouchSwipe(sx, sy, ex, ey, dur, slow_end, pkgName); }
void WaitInput(tstring pkgName = {}) { m_->WaitInput(pkgName); }
private:
IWSAController* m_;
};
}