[fix] use original screen render resolution to capturing and fix cursor mapping error

This commit is contained in:
dijunkun
2024-09-13 17:08:58 +08:00
parent fed7c3b103
commit dca18762e0
4 changed files with 28 additions and 15 deletions

View File

@@ -12,14 +12,19 @@ int MouseController::Init(int screen_width, int screen_height) {
screen_width_ = screen_width;
screen_height_ = screen_height;
pixel_width_ =
CGDisplayModeGetPixelWidth(CGDisplayCopyDisplayMode(CGMainDisplayID()));
pixel_height_ =
CGDisplayModeGetPixelHeight(CGDisplayCopyDisplayMode(CGMainDisplayID()));
return 0;
}
int MouseController::Destroy() { return 0; }
int MouseController::SendCommand(RemoteAction remote_action) {
int mouse_pos_x = remote_action.m.x;
int mouse_pos_y = remote_action.m.y;
int mouse_pos_x = remote_action.m.x * screen_width_ / pixel_width_;
int mouse_pos_y = remote_action.m.y * screen_height_ / pixel_height_;
if (remote_action.type == ControlType::mouse) {
CGEventRef mouse_event;

View File

@@ -22,6 +22,9 @@ class MouseController : public DeviceController {
private:
int screen_width_ = 0;
int screen_height_ = 0;
int pixel_width_ = 0;
int pixel_height_ = 0;
};
#endif