Skip to content

Commit 9bdf6ed

Browse files
committed
review round
1 parent 08be9f7 commit 9bdf6ed

3 files changed

Lines changed: 19 additions & 8 deletions

File tree

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ docker run --rm -v "$PWD:/src" scrcpy-rfb-builder
2525
# -> dist/scrcpy-rfb-linux-<arch>
2626
```
2727

28-
Local build (needs cmake, git, libjpeg-turbo, zlib and FFmpeg dev packages):
28+
Local build (Linux only; needs cmake, git, libjpeg-turbo, zlib and FFmpeg dev
29+
packages):
2930

3031
```sh
3132
make # cmake configure + build into build/
@@ -46,7 +47,10 @@ docker run --rm --network host ghcr.io/cocoonstack/scrcpy-rfb:master \
4647

4748
## Running
4849

49-
Start a scrcpy 4.x server with H.264 video and a TCP listener, then:
50+
Start a scrcpy 4.x server with H.264 video and a TCP listener. The bridge
51+
expects `video_codec=h264 audio=false send_device_meta=false
52+
send_dummy_byte=false`: any extra preamble bytes on the video socket break
53+
its handshake. Then:
5054

5155
```sh
5256
scrcpy-rfb [--scrcpy-host 127.0.0.1] [--scrcpy-port 27183] \

patches/apply.cmake

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
11
# Applied by FetchContent's patch step with the libvncserver source tree as
22
# the working directory. Idempotent: a patch that already applies in reverse
33
# is skipped so reconfigures don't fail.
4+
# GIT_CEILING_DIRECTORIES stops git apply from discovering an enclosing git
5+
# repository (a build/ dir inside this checkout): with one found, git resolves
6+
# patch paths against that repo instead of the CWD and silently applies nothing.
7+
get_filename_component(ceiling ".." ABSOLUTE)
48
file(GLOB patches "${CMAKE_CURRENT_LIST_DIR}/*.patch")
59
list(SORT patches)
610
foreach(patch IN LISTS patches)
711
execute_process(
8-
COMMAND git apply --reverse --check "${patch}"
12+
COMMAND ${CMAKE_COMMAND} -E env "GIT_CEILING_DIRECTORIES=${ceiling}"
13+
git apply --reverse --check "${patch}"
914
RESULT_VARIABLE already_applied
1015
OUTPUT_QUIET ERROR_QUIET
1116
)
1217
if(already_applied EQUAL 0)
1318
continue()
1419
endif()
1520
execute_process(
16-
COMMAND git apply --whitespace=nowarn "${patch}"
21+
COMMAND ${CMAKE_COMMAND} -E env "GIT_CEILING_DIRECTORIES=${ceiling}"
22+
git apply --whitespace=nowarn "${patch}"
1723
RESULT_VARIABLE result
1824
)
1925
if(NOT result EQUAL 0)

src/scrcpy-rfb.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -881,17 +881,18 @@ static int send_touch(uint8_t action, int x, int y, int pressed) {
881881
return send_control(message, sizeof(message));
882882
}
883883

884-
/* hscroll/vscroll are one wheel click each, encoded as scrcpy i16
885-
* fixed-point where 32767 is 1.0. Positive vscroll scrolls up. */
884+
/* hscroll/vscroll are one wheel click each. scrcpy's i16 fixed-point spans
885+
* [-16, 16] clicks full-scale (the server multiplies the [-1, 1] decode by
886+
* 16), so one click is 32768 / 16 = 2048. Positive vscroll scrolls up. */
886887
static int send_scroll(int x, int y, int hscroll, int vscroll) {
887888
uint8_t message[21] = {0};
888889
message[0] = SCRCPY_MSG_INJECT_SCROLL;
889890
AV_WB32(message + 1, (uint32_t) x);
890891
AV_WB32(message + 5, (uint32_t) y);
891892
AV_WB16(message + 9, (uint16_t) video_width);
892893
AV_WB16(message + 11, (uint16_t) video_height);
893-
AV_WB16(message + 13, (uint16_t) (int16_t) (hscroll * 32767));
894-
AV_WB16(message + 15, (uint16_t) (int16_t) (vscroll * 32767));
894+
AV_WB16(message + 13, (uint16_t) (int16_t) (hscroll * 2048));
895+
AV_WB16(message + 15, (uint16_t) (int16_t) (vscroll * 2048));
895896
AV_WB32(message + 17, 0);
896897
return send_control(message, sizeof(message));
897898
}

0 commit comments

Comments
 (0)