Skip to content

Commit 22557de

Browse files
committed
Implementing mac
1 parent 5b50b26 commit 22557de

File tree

1 file changed

+24
-50
lines changed

1 file changed

+24
-50
lines changed

src/ios/Input.cpp

Lines changed: 24 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -5,48 +5,22 @@ namespace SL
55
{
66
namespace Input_Lite
77
{
8-
9-
void SendKeyUp(char key) {
10-
11-
}
12-
void SendKeyUp(wchar_t key) {
13-
14-
}
15-
void SendKeyDown(wchar_t key) {
16-
17-
}
18-
void SendKeyDown(char key) {
19-
20-
}
21-
void SendKeyUp(SpecialKeyCodes key) {
8+
void SendInput(const KeyEvent& e){
229

2310
}
24-
void SendKeyDown(SpecialKeyCodes key) {
25-
26-
}
27-
28-
void SendMouseScroll(int offset)
29-
{
30-
auto ev = CGEventCreateScrollWheelEvent(NULL, kCGScrollEventUnitLine, 1, -offset);
31-
if(ev){
32-
CGEventPost(kCGHIDEventTap, ev);
33-
CFRelease(ev);
34-
}
35-
}
36-
void SendMouse_Impl(const MouseButtons button, bool pressed)
37-
{
11+
void SendInput(const MouseButtonEvent& e){
3812
auto msevent = CGEventCreate(NULL);
3913
auto loc = CGEventGetLocation(msevent);
4014
CFRelease(msevent);
4115

4216
CGEventRef ev = nullptr;
43-
switch(button) {
17+
switch(e.Button) {
4418
case MouseButtons::LEFT:
45-
ev = CGEventCreateMouseEvent(NULL, pressed ? kCGEventLeftMouseDown: kCGEventLeftMouseUp, loc, kCGMouseButtonLeft);
19+
ev = CGEventCreateMouseEvent(NULL, e.Pressed ? kCGEventLeftMouseDown: kCGEventLeftMouseUp, loc, kCGMouseButtonLeft);
4620
case MouseButtons::MIDDLE:
47-
ev = CGEventCreateMouseEvent(NULL, pressed ? kCGEventOtherMouseDown: kCGEventOtherMouseUp, loc, kCGMouseButtonCenter);
21+
ev = CGEventCreateMouseEvent(NULL, e.Pressed ? kCGEventOtherMouseDown: kCGEventOtherMouseUp, loc, kCGMouseButtonCenter);
4822
case MouseButtons::RIGHT:
49-
ev = CGEventCreateMouseEvent(NULL, pressed ? kCGEventRightMouseDown: kCGEventRightMouseUp, loc, kCGMouseButtonRight);
23+
ev = CGEventCreateMouseEvent(NULL, e.Pressed ? kCGEventRightMouseDown: kCGEventRightMouseUp, loc, kCGMouseButtonRight);
5024
default:
5125
break;
5226
}
@@ -55,27 +29,27 @@ namespace SL
5529
CFRelease(ev);
5630
}
5731
}
58-
void SendMouseUp(const MouseButtons button){
59-
SendMouse_Impl(button, false);
60-
}
61-
void SendMouseDown(const MouseButtons button){
62-
SendMouse_Impl(button, true);
63-
}
64-
65-
void SendMousePosition(const Offset& offset){
32+
void SendInput(const MouseScrollEvent& e){
33+
auto ev = CGEventCreateScrollWheelEvent(NULL, kCGScrollEventUnitLine, 1, -e.Offset);
34+
if(ev){
35+
CGEventPost(kCGHIDEventTap, ev);
36+
CFRelease(ev);
37+
}
38+
}
39+
void SendInput(const MousePositionOffsetEvent& e){
6640
auto msevent = CGEventCreate(NULL);
6741
auto loc = CGEventGetLocation(msevent);
6842
CFRelease(msevent);
69-
loc.x+=offset.X;
70-
loc.y += offset.Y;
71-
CGWarpMouseCursorPosition(loc);
72-
}
73-
void SendMousePosition(const AbsolutePos& absolute){
43+
loc.x+=e.X;
44+
loc.y += e.Y;
45+
CGWarpMouseCursorPosition(loc);
46+
}
47+
void SendInput(const MousePositionAbsoluteEvent& e){
7448
CGPoint p;
75-
p.x = absolute.X;
76-
p.y = absolute.Y;
77-
CGWarpMouseCursorPosition(p);
78-
79-
}
49+
p.x = e.X;
50+
p.y = e.Y;
51+
CGWarpMouseCursorPosition(p);
52+
}
53+
8054
}
8155
}

0 commit comments

Comments
 (0)