mirror of https://github.com/Genymobile/scrcpy
Scale mouse events
The video screen size on the client may differ from the real device screen size (e.g. the video stream may be scaled down). As a consequence, mouse events must be scaled to match the real device coordinates. For this purpose, make the client send the video screen size along with the absolute pointer location, and the server scale the location to match the real device size before injecting mouse events.hidpi
parent
11a60e5767
commit
8984c1a7c4
@ -0,0 +1,26 @@
|
||||
#ifndef COMMON_H
|
||||
#define COMMON_H
|
||||
|
||||
#include <SDL2/SDL_stdinc.h>
|
||||
|
||||
#define MIN(X,Y) (X) < (Y) ? (X) : (Y)
|
||||
#define MAX(X,Y) (X) > (Y) ? (X) : (Y)
|
||||
|
||||
struct size {
|
||||
Uint16 width;
|
||||
Uint16 height;
|
||||
};
|
||||
|
||||
struct position {
|
||||
Uint16 x;
|
||||
Uint16 y;
|
||||
};
|
||||
|
||||
struct point {
|
||||
// The video screen size may be different from the real device screen size,
|
||||
// so store to which size the absolute position apply, to scale it accordingly.
|
||||
struct size screen_size;
|
||||
struct position position;
|
||||
};
|
||||
|
||||
#endif
|
@ -0,0 +1,33 @@
|
||||
package com.genymobile.scrcpy;
|
||||
|
||||
public class Point {
|
||||
|
||||
private int x;
|
||||
private int y;
|
||||
private int screenWidth;
|
||||
private int screenHeight;
|
||||
|
||||
public Point(int x, int y, int screenWidth, int screenHeight) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.screenWidth = screenWidth;
|
||||
this.screenHeight = screenHeight;
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public int getScreenWidth() {
|
||||
return screenWidth;
|
||||
}
|
||||
|
||||
public int getScreenHeight() {
|
||||
return screenHeight;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.genymobile.scrcpy;
|
||||
|
||||
public class RawPoint {
|
||||
private int x;
|
||||
private int y;
|
||||
|
||||
public RawPoint(int x, int y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue