mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-27 04:35:34 +08:00
[fix] fix mouse wheel mapping on Windows
This commit is contained in:
@@ -28,9 +28,9 @@ typedef enum {
|
|||||||
} MouseFlag;
|
} MouseFlag;
|
||||||
typedef enum { key_down = 0, key_up } KeyFlag;
|
typedef enum { key_down = 0, key_up } KeyFlag;
|
||||||
typedef struct {
|
typedef struct {
|
||||||
size_t x;
|
int x;
|
||||||
size_t y;
|
int y;
|
||||||
size_t s;
|
int s;
|
||||||
MouseFlag flag;
|
MouseFlag flag;
|
||||||
} Mouse;
|
} Mouse;
|
||||||
|
|
||||||
|
|||||||
@@ -44,21 +44,17 @@ int MouseController::SendMouseCommand(RemoteAction remote_action) {
|
|||||||
break;
|
break;
|
||||||
case MouseFlag::wheel_vertical:
|
case MouseFlag::wheel_vertical:
|
||||||
ip.mi.dwFlags = MOUSEEVENTF_WHEEL;
|
ip.mi.dwFlags = MOUSEEVENTF_WHEEL;
|
||||||
ip.mi.mouseData = remote_action.m.s;
|
ip.mi.mouseData = remote_action.m.s * 120;
|
||||||
break;
|
break;
|
||||||
case MouseFlag::wheel_horizontal:
|
case MouseFlag::wheel_horizontal:
|
||||||
ip.mi.dwFlags = MOUSEEVENTF_HWHEEL;
|
ip.mi.dwFlags = MOUSEEVENTF_HWHEEL;
|
||||||
ip.mi.mouseData = remote_action.m.s;
|
ip.mi.mouseData = remote_action.m.s * 120;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ip.mi.dwFlags = MOUSEEVENTF_MOVE;
|
ip.mi.dwFlags = MOUSEEVENTF_MOVE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ip.mi.mouseData = (remote_action.m.flag == MouseFlag::wheel_vertical ||
|
|
||||||
remote_action.m.flag == MouseFlag::wheel_horizontal)
|
|
||||||
? remote_action.m.s
|
|
||||||
: 0;
|
|
||||||
ip.mi.time = 0;
|
ip.mi.time = 0;
|
||||||
|
|
||||||
SetCursorPos(ip.mi.dx, ip.mi.dy);
|
SetCursorPos(ip.mi.dx, ip.mi.dy);
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ int Render::ProcessMouseEvent(SDL_Event &event) {
|
|||||||
controlled_remote_id_ = "";
|
controlled_remote_id_ = "";
|
||||||
int video_width, video_height = 0;
|
int video_width, video_height = 0;
|
||||||
int render_width, render_height = 0;
|
int render_width, render_height = 0;
|
||||||
|
float ratio_x, ratio_y = 0;
|
||||||
RemoteAction remote_action;
|
RemoteAction remote_action;
|
||||||
|
|
||||||
for (auto &it : client_properties_) {
|
for (auto &it : client_properties_) {
|
||||||
@@ -61,10 +62,8 @@ int Render::ProcessMouseEvent(SDL_Event &event) {
|
|||||||
last_mouse_event.button.x = event.button.x;
|
last_mouse_event.button.x = event.button.x;
|
||||||
last_mouse_event.button.y = event.button.y;
|
last_mouse_event.button.y = event.button.y;
|
||||||
|
|
||||||
float ratio_x =
|
ratio_x = (float)props->original_display_width_ / (float)render_width;
|
||||||
(float)props->original_display_width_ / (float)render_width;
|
ratio_y = (float)props->original_display_height_ / (float)render_height;
|
||||||
float ratio_y =
|
|
||||||
(float)props->original_display_height_ / (float)render_height;
|
|
||||||
|
|
||||||
remote_action.m.x =
|
remote_action.m.x =
|
||||||
(size_t)((event.button.x - props->stream_render_rect_.x) * ratio_x);
|
(size_t)((event.button.x - props->stream_render_rect_.x) * ratio_x);
|
||||||
@@ -122,6 +121,17 @@ int Render::ProcessMouseEvent(SDL_Event &event) {
|
|||||||
remote_action.m.s = scroll_x;
|
remote_action.m.s = scroll_x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
render_width = props->stream_render_rect_.w;
|
||||||
|
render_height = props->stream_render_rect_.h;
|
||||||
|
ratio_x = (float)props->original_display_width_ / (float)render_width;
|
||||||
|
ratio_y = (float)props->original_display_height_ / (float)render_height;
|
||||||
|
remote_action.m.x =
|
||||||
|
(size_t)((last_mouse_event.button.x - props->stream_render_rect_.x) *
|
||||||
|
ratio_x);
|
||||||
|
remote_action.m.y =
|
||||||
|
(size_t)((last_mouse_event.button.y - props->stream_render_rect_.y) *
|
||||||
|
ratio_y);
|
||||||
|
|
||||||
SendDataFrame(props->peer_, (const char *)&remote_action,
|
SendDataFrame(props->peer_, (const char *)&remote_action,
|
||||||
sizeof(remote_action));
|
sizeof(remote_action));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user