Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions bindings/go/dll_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,23 @@ var (
procLeftDown *windows.LazyProc
procLeftUp *windows.LazyProc
procMiddleClick *windows.LazyProc
procMiddleDoubleClick *windows.LazyProc
procMiddleDown *windows.LazyProc
procMiddleUp *windows.LazyProc
procRightClick *windows.LazyProc
procRightDoubleClick *windows.LazyProc
procRightDown *windows.LazyProc
procRightUp *windows.LazyProc
procXButton1Click *windows.LazyProc
procXButton1DoubleClick *windows.LazyProc
procXButton1Down *windows.LazyProc
procXButton1Up *windows.LazyProc
procXButton2Click *windows.LazyProc
procXButton2DoubleClick *windows.LazyProc
procXButton2Down *windows.LazyProc
procXButton2Up *windows.LazyProc
procWheel *windows.LazyProc
procHWheel *windows.LazyProc
procWheelDown *windows.LazyProc
procWheelUp *windows.LazyProc
procSetMouseDelay *windows.LazyProc
Expand Down Expand Up @@ -286,11 +298,23 @@ func bindProcs() {
procLeftDown = dll.NewProc("OpLeftDown")
procLeftUp = dll.NewProc("OpLeftUp")
procMiddleClick = dll.NewProc("OpMiddleClick")
procMiddleDoubleClick = dll.NewProc("OpMiddleDoubleClick")
procMiddleDown = dll.NewProc("OpMiddleDown")
procMiddleUp = dll.NewProc("OpMiddleUp")
procRightClick = dll.NewProc("OpRightClick")
procRightDoubleClick = dll.NewProc("OpRightDoubleClick")
procRightDown = dll.NewProc("OpRightDown")
procRightUp = dll.NewProc("OpRightUp")
procXButton1Click = dll.NewProc("OpXButton1Click")
procXButton1DoubleClick = dll.NewProc("OpXButton1DoubleClick")
procXButton1Down = dll.NewProc("OpXButton1Down")
procXButton1Up = dll.NewProc("OpXButton1Up")
procXButton2Click = dll.NewProc("OpXButton2Click")
procXButton2DoubleClick = dll.NewProc("OpXButton2DoubleClick")
procXButton2Down = dll.NewProc("OpXButton2Down")
procXButton2Up = dll.NewProc("OpXButton2Up")
procWheel = dll.NewProc("OpWheel")
procHWheel = dll.NewProc("OpHWheel")
procWheelDown = dll.NewProc("OpWheelDown")
procWheelUp = dll.NewProc("OpWheelUp")
procSetMouseDelay = dll.NewProc("OpSetMouseDelay")
Expand Down
58 changes: 58 additions & 0 deletions bindings/go/input_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ func (o *Op) MiddleClick() int {
return o.callNoArgs(procMiddleClick)
}

func (o *Op) MiddleDoubleClick() int {
return o.callNoArgs(procMiddleDoubleClick)
}

func (o *Op) MiddleDown() int {
return o.callNoArgs(procMiddleDown)
}
Expand All @@ -80,6 +84,10 @@ func (o *Op) RightClick() int {
return o.callNoArgs(procRightClick)
}

func (o *Op) RightDoubleClick() int {
return o.callNoArgs(procRightDoubleClick)
}

func (o *Op) RightDown() int {
return o.callNoArgs(procRightDown)
}
Expand All @@ -88,6 +96,56 @@ func (o *Op) RightUp() int {
return o.callNoArgs(procRightUp)
}

func (o *Op) XButton1Click() int {
return o.callNoArgs(procXButton1Click)
}

func (o *Op) XButton1DoubleClick() int {
return o.callNoArgs(procXButton1DoubleClick)
}

func (o *Op) XButton1Down() int {
return o.callNoArgs(procXButton1Down)
}

func (o *Op) XButton1Up() int {
return o.callNoArgs(procXButton1Up)
}

func (o *Op) XButton2Click() int {
return o.callNoArgs(procXButton2Click)
}

func (o *Op) XButton2DoubleClick() int {
return o.callNoArgs(procXButton2DoubleClick)
}

func (o *Op) XButton2Down() int {
return o.callNoArgs(procXButton2Down)
}

func (o *Op) XButton2Up() int {
return o.callNoArgs(procXButton2Up)
}

func (o *Op) Wheel(delta int) int {
if !o.valid() {
return 0
}

ret, _, _ := procWheel.Call(o.handle, uintptr(delta))
return int(ret)
}

func (o *Op) HWheel(delta int) int {
if !o.valid() {
return 0
}

ret, _, _ := procHWheel.Call(o.handle, uintptr(delta))
return int(ret)
}

func (o *Op) WheelDown() int {
return o.callNoArgs(procWheelDown)
}
Expand Down
12 changes: 12 additions & 0 deletions bindings/python/op/_ffi.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,23 @@ def _bind(dll: ctypes.WinDLL) -> ctypes.WinDLL:
("OpLeftDown", c_int, [op_handle]),
("OpLeftUp", c_int, [op_handle]),
("OpMiddleClick", c_int, [op_handle]),
("OpMiddleDoubleClick", c_int, [op_handle]),
("OpMiddleDown", c_int, [op_handle]),
("OpMiddleUp", c_int, [op_handle]),
("OpRightClick", c_int, [op_handle]),
("OpRightDoubleClick", c_int, [op_handle]),
("OpRightDown", c_int, [op_handle]),
("OpRightUp", c_int, [op_handle]),
("OpXButton1Click", c_int, [op_handle]),
("OpXButton1DoubleClick", c_int, [op_handle]),
("OpXButton1Down", c_int, [op_handle]),
("OpXButton1Up", c_int, [op_handle]),
("OpXButton2Click", c_int, [op_handle]),
("OpXButton2DoubleClick", c_int, [op_handle]),
("OpXButton2Down", c_int, [op_handle]),
("OpXButton2Up", c_int, [op_handle]),
("OpWheel", c_int, [op_handle, c_int]),
("OpHWheel", c_int, [op_handle, c_int]),
("OpWheelDown", c_int, [op_handle]),
("OpWheelUp", c_int, [op_handle]),
("OpSetMouseDelay", c_int, [op_handle, c_wchar_p, c_int]),
Expand Down
36 changes: 36 additions & 0 deletions bindings/python/op/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,9 @@ def left_up(self) -> bool:
def middle_click(self) -> bool:
return self._call_ok("OpMiddleClick")

def middle_double_click(self) -> bool:
return self._call_ok("OpMiddleDoubleClick")

def middle_down(self) -> bool:
return self._call_ok("OpMiddleDown")

Expand All @@ -442,12 +445,45 @@ def middle_up(self) -> bool:
def right_click(self) -> bool:
return self._call_ok("OpRightClick")

def right_double_click(self) -> bool:
return self._call_ok("OpRightDoubleClick")

def right_down(self) -> bool:
return self._call_ok("OpRightDown")

def right_up(self) -> bool:
return self._call_ok("OpRightUp")

def xbutton1_click(self) -> bool:
return self._call_ok("OpXButton1Click")

def xbutton1_double_click(self) -> bool:
return self._call_ok("OpXButton1DoubleClick")

def xbutton1_down(self) -> bool:
return self._call_ok("OpXButton1Down")

def xbutton1_up(self) -> bool:
return self._call_ok("OpXButton1Up")

def xbutton2_click(self) -> bool:
return self._call_ok("OpXButton2Click")

def xbutton2_double_click(self) -> bool:
return self._call_ok("OpXButton2DoubleClick")

def xbutton2_down(self) -> bool:
return self._call_ok("OpXButton2Down")

def xbutton2_up(self) -> bool:
return self._call_ok("OpXButton2Up")

def wheel(self, delta: int) -> bool:
return self._call_ok("OpWheel", int(delta))

def hwheel(self, delta: int) -> bool:
return self._call_ok("OpHWheel", int(delta))

def wheel_down(self) -> bool:
return self._call_ok("OpWheelDown")

Expand Down
30 changes: 27 additions & 3 deletions include/libop.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,17 +250,41 @@ class OP_API Client {
// 弹起鼠标左键
void LeftUp(_Out_ long *ret);
// 按下鼠标中键
void MiddleClick(_Out_ long *ret);
void MiddleClick(long *ret);
// 双击鼠标中键
void MiddleDoubleClick(long *ret);
// 按住鼠标中键
void MiddleDown(_Out_ long *ret);
// 弹起鼠标中键
void MiddleUp(_Out_ long *ret);
// 按下鼠标右键
void RightClick(_Out_ long *ret);
void RightClick(long *ret);
// 双击鼠标右键
void RightDoubleClick(long *ret);
// 按住鼠标右键
void RightDown(_Out_ long *ret);
// 弹起鼠标右键
void RightUp(_Out_ long *ret);
void RightUp(long *ret);
// 按下鼠标侧键1
void XButton1Click(long *ret);
// 双击鼠标侧键1
void XButton1DoubleClick(long *ret);
// 按住鼠标侧键1
void XButton1Down(long *ret);
// 弹起鼠标侧键1
void XButton1Up(long *ret);
// 按下鼠标侧键2
void XButton2Click(long *ret);
// 双击鼠标侧键2
void XButton2DoubleClick(long *ret);
// 按住鼠标侧键2
void XButton2Down(long *ret);
// 弹起鼠标侧键2
void XButton2Up(long *ret);
// 垂直滚轮滚动指定 delta
void Wheel(long delta, long *ret);
// 水平滚轮滚动指定 delta
void HWheel(long delta, long *ret);
// 滚轮向下滚
void WheelDown(_Out_ long *ret);
// 滚轮向上滚
Expand Down
12 changes: 12 additions & 0 deletions include/op_c_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,23 @@ OP_C_API int OP_CALL OpLeftDoubleClick(op_handle handle);
OP_C_API int OP_CALL OpLeftDown(op_handle handle);
OP_C_API int OP_CALL OpLeftUp(op_handle handle);
OP_C_API int OP_CALL OpMiddleClick(op_handle handle);
OP_C_API int OP_CALL OpMiddleDoubleClick(op_handle handle);
OP_C_API int OP_CALL OpMiddleDown(op_handle handle);
OP_C_API int OP_CALL OpMiddleUp(op_handle handle);
OP_C_API int OP_CALL OpRightClick(op_handle handle);
OP_C_API int OP_CALL OpRightDoubleClick(op_handle handle);
OP_C_API int OP_CALL OpRightDown(op_handle handle);
OP_C_API int OP_CALL OpRightUp(op_handle handle);
OP_C_API int OP_CALL OpXButton1Click(op_handle handle);
OP_C_API int OP_CALL OpXButton1DoubleClick(op_handle handle);
OP_C_API int OP_CALL OpXButton1Down(op_handle handle);
OP_C_API int OP_CALL OpXButton1Up(op_handle handle);
OP_C_API int OP_CALL OpXButton2Click(op_handle handle);
OP_C_API int OP_CALL OpXButton2DoubleClick(op_handle handle);
OP_C_API int OP_CALL OpXButton2Down(op_handle handle);
OP_C_API int OP_CALL OpXButton2Up(op_handle handle);
OP_C_API int OP_CALL OpWheel(op_handle handle, int delta);
OP_C_API int OP_CALL OpHWheel(op_handle handle, int delta);
OP_C_API int OP_CALL OpWheelDown(op_handle handle);
OP_C_API int OP_CALL OpWheelUp(op_handle handle);
OP_C_API int OP_CALL OpSetMouseDelay(op_handle handle, const wchar_t *type, int delay);
Expand Down
4 changes: 3 additions & 1 deletion libop/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,8 @@ set(OP_COM_SOURCES

set(OP_C_API_SOURCES
"c_api/op_c_api.cpp"
"hook/HookExport.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/c_api/op_c_api.rc"
)

set(OP_COMMON_DEFINITIONS
Expand All @@ -283,7 +285,7 @@ set(OP_COMMON_DEFINITIONS
_SILENCE_CXX17_ADAPTOR_TYPEDEFS_DEPRECATION_WARNING
_UNICODE
UNICODE
OP_VERSION="0.4.7.0"
OP_VERSION="0.4.8.1"
)
if(DEFINED OP_ARCH_DEFINITION AND NOT OP_ARCH_DEFINITION STREQUAL "")
list(APPEND OP_COMMON_DEFINITIONS "${OP_ARCH_DEFINITION}")
Expand Down
12 changes: 6 additions & 6 deletions libop/binding/BindingSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,21 +543,21 @@ bool BindingSession::requestCapture(int x1, int y1, int w, int h, Image &img) {
return false;
}

std::unique_ptr<ICaptureBackend> BindingSession::createDisplay(int mode) {
std::shared_ptr<ICaptureBackend> BindingSession::createDisplay(int mode) {
if (mode == RDT_NORMAL || GET_RENDER_TYPE(mode) == RENDER_TYPE::GDI) {
return std::make_unique<GdiCapture>();
return std::make_shared<GdiCapture>();
} else if (mode == RDT_NORMAL_DXGI) {
return std::make_unique<DxgiCapture>();
return std::make_shared<DxgiCapture>();
}
#ifdef OP_ENABLE_WGC
else if (mode == RDT_NORMAL_WGC) {
return std::make_unique<WgcCapture>();
return std::make_shared<WgcCapture>();
}
#endif
else if (GET_RENDER_TYPE(mode) == RENDER_TYPE::DX) {
return std::make_unique<HookCapture>();
return std::make_shared<HookCapture>();
} else if (GET_RENDER_TYPE(mode) == RENDER_TYPE::OPENGL)
return std::make_unique<HookCapture>();
return std::make_shared<HookCapture>();
return nullptr;
}

Expand Down
4 changes: 2 additions & 2 deletions libop/binding/BindingSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ class BindingSession {
Image _pic;

long reset_bind_state(bool restore_default_input);
std::unique_ptr<op::capture::ICaptureBackend> createDisplay(int mode);
std::shared_ptr<op::capture::ICaptureBackend> createDisplay(int mode);
std::unique_ptr<op::input::WinMouse> createMouse(int mode);
std::unique_ptr<op::input::KeyboardBackend> createKeypad(int mode);

public:
std::unique_ptr<op::capture::ICaptureBackend> _capture;
std::shared_ptr<op::capture::ICaptureBackend> _capture;
std::unique_ptr<op::input::WinMouse> _mouse;
std::unique_ptr<op::input::KeyboardBackend> _keyboard;
wstring _curr_path;
Expand Down
26 changes: 26 additions & 0 deletions libop/c_api/op_c_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "../../include/libop.h"
#include "../memory/ProcessMemory.h"
#include "../runtime/RuntimeEnvironment.h"

#include <Windows.h>
#include <cstdint>
Expand All @@ -12,6 +13,13 @@
#undef FindWindowEx
#undef SetWindowText

extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD reason, LPVOID) {
if (reason == DLL_PROCESS_ATTACH) {
RuntimeEnvironment::setInstance(hInstance);
}
return TRUE;
}

#define OP_WIDEN_TEXT2(text) L##text
#define OP_WIDEN_TEXT(text) OP_WIDEN_TEXT2(text)

Expand Down Expand Up @@ -515,16 +523,34 @@ OP_MOUSE_RET(OpLeftDoubleClick, LeftDoubleClick)
OP_MOUSE_RET(OpLeftDown, LeftDown)
OP_MOUSE_RET(OpLeftUp, LeftUp)
OP_MOUSE_RET(OpMiddleClick, MiddleClick)
OP_MOUSE_RET(OpMiddleDoubleClick, MiddleDoubleClick)
OP_MOUSE_RET(OpMiddleDown, MiddleDown)
OP_MOUSE_RET(OpMiddleUp, MiddleUp)
OP_MOUSE_RET(OpRightClick, RightClick)
OP_MOUSE_RET(OpRightDoubleClick, RightDoubleClick)
OP_MOUSE_RET(OpRightDown, RightDown)
OP_MOUSE_RET(OpRightUp, RightUp)
OP_MOUSE_RET(OpXButton1Click, XButton1Click)
OP_MOUSE_RET(OpXButton1DoubleClick, XButton1DoubleClick)
OP_MOUSE_RET(OpXButton1Down, XButton1Down)
OP_MOUSE_RET(OpXButton1Up, XButton1Up)
OP_MOUSE_RET(OpXButton2Click, XButton2Click)
OP_MOUSE_RET(OpXButton2DoubleClick, XButton2DoubleClick)
OP_MOUSE_RET(OpXButton2Down, XButton2Down)
OP_MOUSE_RET(OpXButton2Up, XButton2Up)
OP_MOUSE_RET(OpWheelDown, WheelDown)
OP_MOUSE_RET(OpWheelUp, WheelUp)

#undef OP_MOUSE_RET

int OP_CALL OpWheel(op_handle handle, int delta) {
return call_ret(handle, [&](op::Client &op, long *ret) { op.Wheel(delta, ret); });
}

int OP_CALL OpHWheel(op_handle handle, int delta) {
return call_ret(handle, [&](op::Client &op, long *ret) { op.HWheel(delta, ret); });
}

int OP_CALL OpSetMouseDelay(op_handle handle, const wchar_t *type, int delay) {
return call_ret(handle, [&](op::Client &op, long *ret) { op.SetMouseDelay(safe_text(type), delay, ret); });
}
Expand Down
Loading
Loading