Feature: Add remote_mouse MCP tool
Add the remote_mouse tool to the MCP remote control surface, injecting mouse events (move / down / up / click / right_click / middle_click / drag / scroll) into an established remote_open session. Normalized 0..1 coordinates are mapped to physical pixels via the session's captured resolution and clamped to screen bounds. Scroll follows the existing web console's wheel sign convention (positive delta scrolls down) and is vertical-only. Extract BuildMouseMsg64 into WebService.h as a shared helper, reused by both the web console's HandleMouse and the new MCP handler so the two injection paths cannot drift. Co-Authored-By: deepseek-v4-pro
This commit is contained in:
@@ -799,34 +799,18 @@ void CWebService::HandleMouse(void* ws_ptr, const std::string& msg) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Build MSG64 structure
|
||||
MSG64 msg64;
|
||||
memset(&msg64, 0, sizeof(MSG64));
|
||||
msg64.pt.x = x;
|
||||
msg64.pt.y = y;
|
||||
msg64.lParam = MAKELPARAM(x, y);
|
||||
msg64.time = GetTickCount();
|
||||
// Build MSG64 structure(共享 helper,见 WebService.h;与 MCP remote_mouse 复用)
|
||||
MSG64 msg64 = BuildMouseMsg64(x, y, 0, 0); // 默认 WM_NULL;未知 button 时仍发送(保持原行为)
|
||||
|
||||
// Map type and button to Windows message
|
||||
if (type == "down") {
|
||||
if (button == 0) {
|
||||
msg64.message = WM_LBUTTONDOWN;
|
||||
msg64.wParam = MK_LBUTTON;
|
||||
} else if (button == 1) {
|
||||
msg64.message = WM_MBUTTONDOWN;
|
||||
msg64.wParam = MK_MBUTTON;
|
||||
} else if (button == 2) {
|
||||
msg64.message = WM_RBUTTONDOWN;
|
||||
msg64.wParam = MK_RBUTTON;
|
||||
}
|
||||
if (button == 0) { msg64.message = WM_LBUTTONDOWN; msg64.wParam = MK_LBUTTON; }
|
||||
else if (button == 1) { msg64.message = WM_MBUTTONDOWN; msg64.wParam = MK_MBUTTON; }
|
||||
else if (button == 2) { msg64.message = WM_RBUTTONDOWN; msg64.wParam = MK_RBUTTON; }
|
||||
} else if (type == "up") {
|
||||
if (button == 0) {
|
||||
msg64.message = WM_LBUTTONUP;
|
||||
} else if (button == 1) {
|
||||
msg64.message = WM_MBUTTONUP;
|
||||
} else if (button == 2) {
|
||||
msg64.message = WM_RBUTTONUP;
|
||||
}
|
||||
if (button == 0) { msg64.message = WM_LBUTTONUP; }
|
||||
else if (button == 1) { msg64.message = WM_MBUTTONUP; }
|
||||
else if (button == 2) { msg64.message = WM_RBUTTONUP; }
|
||||
} else if (type == "move") {
|
||||
msg64.message = WM_MOUSEMOVE;
|
||||
} else if (type == "wheel") {
|
||||
@@ -845,13 +829,8 @@ void CWebService::HandleMouse(void* ws_ptr, const std::string& msg) {
|
||||
if (clientType != GetClientType(CLIENT_TYPE_MACOS) && clientType != "macOS") {
|
||||
return; // Skip dblclick for non-macOS clients
|
||||
}
|
||||
if (button == 0) {
|
||||
msg64.message = WM_LBUTTONDBLCLK;
|
||||
msg64.wParam = MK_LBUTTON;
|
||||
} else if (button == 2) {
|
||||
msg64.message = WM_RBUTTONDBLCLK;
|
||||
msg64.wParam = MK_RBUTTON;
|
||||
}
|
||||
if (button == 0) { msg64.message = WM_LBUTTONDBLCLK; msg64.wParam = MK_LBUTTON; }
|
||||
else if (button == 2) { msg64.message = WM_RBUTTONDBLCLK; msg64.wParam = MK_RBUTTON; }
|
||||
} else {
|
||||
return; // Unknown type
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user