Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fb5e619636 |
13
BUILD.md
13
BUILD.md
@@ -176,8 +176,8 @@ Additionally, if you want to build the server, install Java 8 from Caskroom, and
|
|||||||
make it avaliable from the `PATH`:
|
make it avaliable from the `PATH`:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
brew tap homebrew/cask-versions
|
brew tap caskroom/versions
|
||||||
brew cask install adoptopenjdk/openjdk/adoptopenjdk8
|
brew cask install java8
|
||||||
export JAVA_HOME="$(/usr/libexec/java_home --version 1.8)"
|
export JAVA_HOME="$(/usr/libexec/java_home --version 1.8)"
|
||||||
export PATH="$JAVA_HOME/bin:$PATH"
|
export PATH="$JAVA_HOME/bin:$PATH"
|
||||||
```
|
```
|
||||||
@@ -190,17 +190,12 @@ See [pierlon/scrcpy-docker](https://github.com/pierlon/scrcpy-docker).
|
|||||||
## Common steps
|
## Common steps
|
||||||
|
|
||||||
If you want to build the server, install the [Android SDK] (_Android Studio_),
|
If you want to build the server, install the [Android SDK] (_Android Studio_),
|
||||||
and set `ANDROID_SDK_ROOT` to its directory. For example:
|
and set `ANDROID_HOME` to its directory. For example:
|
||||||
|
|
||||||
[Android SDK]: https://developer.android.com/studio/index.html
|
[Android SDK]: https://developer.android.com/studio/index.html
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Linux
|
export ANDROID_HOME=~/android/sdk
|
||||||
export ANDROID_SDK_ROOT=~/Android/Sdk
|
|
||||||
# Mac
|
|
||||||
export ANDROID_SDK_ROOT=~/Library/Android/sdk
|
|
||||||
# Windows
|
|
||||||
set ANDROID_SDK_ROOT=%LOCALAPPDATA%\Android\sdk
|
|
||||||
```
|
```
|
||||||
|
|
||||||
If you don't want to build the server, use the [prebuilt server].
|
If you don't want to build the server, use the [prebuilt server].
|
||||||
|
|||||||
@@ -49,11 +49,6 @@ A [Snap] package is available: [`scrcpy`][snap-link].
|
|||||||
|
|
||||||
[snap]: https://en.wikipedia.org/wiki/Snappy_(package_manager)
|
[snap]: https://en.wikipedia.org/wiki/Snappy_(package_manager)
|
||||||
|
|
||||||
For Fedora, a [COPR] package is available: [`scrcpy`][copr-link].
|
|
||||||
|
|
||||||
[COPR]: https://fedoraproject.org/wiki/Category:Copr
|
|
||||||
[copr-link]: https://copr.fedorainfracloud.org/coprs/zeno/scrcpy/
|
|
||||||
|
|
||||||
For Arch Linux, an [AUR] package is available: [`scrcpy`][aur-link].
|
For Arch Linux, an [AUR] package is available: [`scrcpy`][aur-link].
|
||||||
|
|
||||||
[AUR]: https://wiki.archlinux.org/index.php/Arch_User_Repository
|
[AUR]: https://wiki.archlinux.org/index.php/Arch_User_Repository
|
||||||
@@ -446,7 +441,7 @@ Or by pressing `Ctrl`+`o` at any time.
|
|||||||
|
|
||||||
To turn it back on, press `Ctrl`+`Shift`+`o` (or `POWER`, `Ctrl`+`p`).
|
To turn it back on, press `Ctrl`+`Shift`+`o` (or `POWER`, `Ctrl`+`p`).
|
||||||
|
|
||||||
It can also be useful to prevent the device from sleeping:
|
It can be useful to also prevent the device to sleep:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
scrcpy --turn-screen-off --stay-awake
|
scrcpy --turn-screen-off --stay-awake
|
||||||
|
|||||||
@@ -427,7 +427,7 @@ convert_mouse_motion(const SDL_MouseMotionEvent *from, struct screen *screen,
|
|||||||
to->inject_touch_event.pointer_id = POINTER_ID_MOUSE;
|
to->inject_touch_event.pointer_id = POINTER_ID_MOUSE;
|
||||||
to->inject_touch_event.position.screen_size = screen->frame_size;
|
to->inject_touch_event.position.screen_size = screen->frame_size;
|
||||||
to->inject_touch_event.position.point =
|
to->inject_touch_event.position.point =
|
||||||
screen_convert_to_frame_coords(screen, from->x, from->y);
|
screen_convert_window_to_frame_coords(screen, from->x, from->y);
|
||||||
to->inject_touch_event.pressure = 1.f;
|
to->inject_touch_event.pressure = 1.f;
|
||||||
to->inject_touch_event.buttons = convert_mouse_buttons(from->state);
|
to->inject_touch_event.buttons = convert_mouse_buttons(from->state);
|
||||||
|
|
||||||
@@ -465,15 +465,15 @@ convert_touch(const SDL_TouchFingerEvent *from, struct screen *screen,
|
|||||||
to->inject_touch_event.pointer_id = from->fingerId;
|
to->inject_touch_event.pointer_id = from->fingerId;
|
||||||
to->inject_touch_event.position.screen_size = screen->frame_size;
|
to->inject_touch_event.position.screen_size = screen->frame_size;
|
||||||
|
|
||||||
int ww;
|
int dw;
|
||||||
int wh;
|
int dh;
|
||||||
SDL_GL_GetDrawableSize(screen->window, &ww, &wh);
|
SDL_GL_GetDrawableSize(screen->window, &dw, &dh);
|
||||||
|
|
||||||
// SDL touch event coordinates are normalized in the range [0; 1]
|
// SDL touch event coordinates are normalized in the range [0; 1]
|
||||||
int32_t x = from->x * ww;
|
int32_t x = from->x * dw;
|
||||||
int32_t y = from->y * wh;
|
int32_t y = from->y * dh;
|
||||||
to->inject_touch_event.position.point =
|
to->inject_touch_event.position.point =
|
||||||
screen_convert_to_frame_coords(screen, x, y);
|
screen_convert_drawable_to_frame_coords(screen, x, y);
|
||||||
|
|
||||||
to->inject_touch_event.pressure = from->pressure;
|
to->inject_touch_event.pressure = from->pressure;
|
||||||
to->inject_touch_event.buttons = 0;
|
to->inject_touch_event.buttons = 0;
|
||||||
@@ -503,7 +503,7 @@ convert_mouse_button(const SDL_MouseButtonEvent *from, struct screen *screen,
|
|||||||
to->inject_touch_event.pointer_id = POINTER_ID_MOUSE;
|
to->inject_touch_event.pointer_id = POINTER_ID_MOUSE;
|
||||||
to->inject_touch_event.position.screen_size = screen->frame_size;
|
to->inject_touch_event.position.screen_size = screen->frame_size;
|
||||||
to->inject_touch_event.position.point =
|
to->inject_touch_event.position.point =
|
||||||
screen_convert_to_frame_coords(screen, from->x, from->y);
|
screen_convert_window_to_frame_coords(screen, from->x, from->y);
|
||||||
to->inject_touch_event.pressure = 1.f;
|
to->inject_touch_event.pressure = 1.f;
|
||||||
to->inject_touch_event.buttons =
|
to->inject_touch_event.buttons =
|
||||||
convert_mouse_buttons(SDL_BUTTON(from->button));
|
convert_mouse_buttons(SDL_BUTTON(from->button));
|
||||||
@@ -568,7 +568,8 @@ convert_mouse_wheel(const SDL_MouseWheelEvent *from, struct screen *screen,
|
|||||||
|
|
||||||
struct position position = {
|
struct position position = {
|
||||||
.screen_size = screen->frame_size,
|
.screen_size = screen->frame_size,
|
||||||
.point = screen_convert_to_frame_coords(screen, mouse_x, mouse_y),
|
.point = screen_convert_window_to_frame_coords(screen,
|
||||||
|
mouse_x, mouse_y),
|
||||||
};
|
};
|
||||||
|
|
||||||
to->type = CONTROL_MSG_TYPE_INJECT_SCROLL_EVENT;
|
to->type = CONTROL_MSG_TYPE_INJECT_SCROLL_EVENT;
|
||||||
|
|||||||
@@ -579,14 +579,14 @@ screen_handle_window_event(struct screen *screen,
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct point
|
struct point
|
||||||
screen_convert_to_frame_coords(struct screen *screen, int32_t x, int32_t y) {
|
screen_convert_drawable_to_frame_coords(struct screen *screen,
|
||||||
|
int32_t x, int32_t y) {
|
||||||
unsigned rotation = screen->rotation;
|
unsigned rotation = screen->rotation;
|
||||||
assert(rotation < 4);
|
assert(rotation < 4);
|
||||||
|
|
||||||
int32_t w = screen->content_size.width;
|
int32_t w = screen->content_size.width;
|
||||||
int32_t h = screen->content_size.height;
|
int32_t h = screen->content_size.height;
|
||||||
|
|
||||||
screen_hidpi_scale_coords(screen, &x, &y);
|
|
||||||
|
|
||||||
x = (int64_t) (x - screen->rect.x) * w / screen->rect.w;
|
x = (int64_t) (x - screen->rect.x) * w / screen->rect.w;
|
||||||
y = (int64_t) (y - screen->rect.y) * h / screen->rect.h;
|
y = (int64_t) (y - screen->rect.y) * h / screen->rect.h;
|
||||||
@@ -615,6 +615,13 @@ screen_convert_to_frame_coords(struct screen *screen, int32_t x, int32_t y) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct point
|
||||||
|
screen_convert_window_to_frame_coords(struct screen *screen,
|
||||||
|
int32_t x, int32_t y) {
|
||||||
|
screen_hidpi_scale_coords(screen, &x, &y);
|
||||||
|
return screen_convert_drawable_to_frame_coords(screen, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
screen_hidpi_scale_coords(struct screen *screen, int32_t *x, int32_t *y) {
|
screen_hidpi_scale_coords(struct screen *screen, int32_t *x, int32_t *y) {
|
||||||
// take the HiDPI scaling (dw/ww and dh/wh) into account
|
// take the HiDPI scaling (dw/ww and dh/wh) into account
|
||||||
|
|||||||
@@ -126,7 +126,14 @@ screen_handle_window_event(struct screen *screen, const SDL_WindowEvent *event);
|
|||||||
// convert point from window coordinates to frame coordinates
|
// convert point from window coordinates to frame coordinates
|
||||||
// x and y are expressed in pixels
|
// x and y are expressed in pixels
|
||||||
struct point
|
struct point
|
||||||
screen_convert_to_frame_coords(struct screen *screen, int32_t x, int32_t y);
|
screen_convert_window_to_frame_coords(struct screen *screen,
|
||||||
|
int32_t x, int32_t y);
|
||||||
|
|
||||||
|
// convert point from drawable coordinates to frame coordinates
|
||||||
|
// x and y are expressed in pixels
|
||||||
|
struct point
|
||||||
|
screen_convert_drawable_to_frame_coords(struct screen *screen,
|
||||||
|
int32_t x, int32_t y);
|
||||||
|
|
||||||
// Convert coordinates from window to drawable.
|
// Convert coordinates from window to drawable.
|
||||||
// Events are expressed in window coordinates, but content is expressed in
|
// Events are expressed in window coordinates, but content is expressed in
|
||||||
|
|||||||
Reference in New Issue
Block a user