Commit graph

1352 commits

Author SHA1 Message Date
Romain Vimont
229eeb24a2 Merge pull request #1002 into dev
Fix utf-8 char path in windows

<https://github.com/Genymobile/scrcpy/pull/1002>
2019-12-15 13:24:17 +01:00
Yu-Chen Lin
f9786e5034 Get env in windows correctly
Signed-off-by: Yu-Chen Lin <npes87184@gmail.com>
Signed-off-by: Romain Vimont <rom@rom1v.com>
2019-12-14 18:47:54 +01:00
Yu-Chen Lin
78a320a763 Fix utf-8 char path in windows
The file 'E:\安安\scrcpy-win64-v1.12.1-1-g31bd950\scrcpy-server'
exists, however, it will show msg as follow:

    INFO: scrcpy 1.12.1 <https://github.com/Genymobile/scrcpy>
    stat: No such file or directory
    ERROR: 'E:\安安\scrcpy-win64-v1.12.1-1-g31bd950\scrcpy-server' does
    not exist or is not a regular file
    Press any key to continue...

This patch fixes it.

Signed-off-by: Yu-Chen Lin <npes87184@gmail.com>
Signed-off-by: Romain Vimont <rom@rom1v.com>
2019-12-14 18:47:30 +01:00
Romain Vimont
7d5845196e Fix memory leak on portable builds
The function get_server_path() sometimes returned an owned string,
sometimes a non-owned string.

Always return an allocated (owned) string, and free it after usage.
2019-12-14 18:23:25 +01:00
Romain Vimont
31bd95022b Update links to v1.12.1 in README and BUILD 2019-12-10 17:59:44 +01:00
Romain Vimont
4687a0ebac Bump version to 1.12.1 2019-12-10 10:07:48 +01:00
Romain Vimont
6965d051ae Limit bitrate range to 31 bits integer
A proper solution could be to use "long long" instead (guaranteed to be
at least 64 bits), but it adds its own problems (e.g. "%lld" is not
supported as a printf format on all platforms).

In practice, we don't need such high values, so keep it simple.

Fixes #995 <https://github.com/Genymobile/scrcpy/issues/995>
2019-12-10 09:28:27 +01:00
Romain Vimont
71df3175bd Update links to v1.12 in README and BUILD 2019-12-09 23:52:26 +01:00
Romain Vimont
a0f8e7fd9f Bump version to 1.12 2019-12-09 23:24:43 +01:00
Romain Vimont
e4cebc8d4c Do not build tests in release mode
Assertions would not be executed.

And as a side effect, it causes "unused variable" warnings.
2019-12-09 23:24:39 +01:00
Romain Vimont
ba1b36758e Define SDL_MAIN_HANDLED in all tests
Each test defines its own main() function. If this flag is not set, then
SDL redefines it to SDL_main(), causing compilation failures.
2019-12-09 23:24:39 +01:00
Romain Vimont
ad92a192b5 Fix meson.build codestyle 2019-12-09 23:00:55 +01:00
Romain Vimont
81a8e503e5 Describe screen rotation shortcut in README 2019-12-09 22:51:27 +01:00
Romain Vimont
242e57d69b Merge branch 'master' into dev 2019-12-09 22:37:20 +01:00
Romain Vimont
024c2f7e6b Configure log priority early
The log priority must be configured before parsing command-line
arguments, in order to get logs as expected.
2019-12-09 22:31:14 +01:00
Romain Vimont
1eae139b6e Add missing consts
String parsing functions should not be able to modify their input.
2019-12-09 22:30:48 +01:00
Romain Vimont
419c869c9c Use ARRAY_LEN() macro in tests 2019-12-09 20:59:11 +01:00
Romain Vimont
929bf48c7e Add tests for command-line parsing 2019-12-08 23:19:01 +01:00
Romain Vimont
d950383b72 Move command-line parsing to a separate file 2019-12-08 23:18:57 +01:00
Romain Vimont
61274a7cdb Factorize integer argument parsing
Add util functions for integer parsing (with tests), and factorize
integer argument parsing to avoid code duplication.
2019-12-08 21:19:53 +01:00
Romain Vimont
64bcac9157 Refuse to push a non-regular file server
If SCRCPY_SERVER_PATH points to a directory, then a directory will be
pushed to /data/local/tmp/scrcpy-server.jar.

When executing it, app_process will just abort and leave the directory
on the device, causing scrcpy to always fail.

To avoid the problem, check that the server is a regular file before
pushing it.

Closes #956 <https://github.com/Genymobile/scrcpy/issues/956>
2019-12-05 21:07:11 +01:00
Romain Vimont
3259c60b22 Fix test compilation on mingw
Including SDL2/SDL.h redefines main to SDL_main by default.
2019-12-05 21:06:49 +01:00
Romain Vimont
e0b117de13 Fix checkstyle warning 2019-12-05 21:05:45 +01:00
Romain Vimont
eb0f339271 Add shortcut to rotate screen
On Ctrl+r, disable auto-rotation (if enabled), set the screen rotation
and re-enable auto-rotation (if it was enabled).

Closes #11 <https://github.com/Genymobile/scrcpy/issues/11>
2019-12-04 22:03:25 +01:00
Romain Vimont
bdd05b4a16 Refactor wrappers for Android SDK classes
Internally, a failure to invoke a method via reflection was partially
managed using exceptions, partially using a null return value.

Handle all errors at the same place, by not catching
NoSuchMethodException too early.
2019-12-04 19:34:20 +01:00
Romain Vimont
525d6d4a75 Try new methods before legacy ones
Use the legacy methods when the new ones do not exist.
2019-12-04 19:32:38 +01:00
Romain Vimont
4041043d1c Merge pull request #967 into dev
Add some tests

<https://github.com/Genymobile/scrcpy/pull/967>
2019-12-04 19:25:58 +01:00
Yu-Chen Lin
fbc86a616c Correct coding style
Signed-off-by: Yu-Chen Lin <npes87184@gmail.com>
2019-12-04 19:24:59 +01:00
Yu-Chen Lin
b2bf25c52c Add test_buffer_util
Signed-off-by: Yu-Chen Lin <npes87184@gmail.com>
2019-12-04 19:24:59 +01:00
Yu-Chen Lin
5eeaed09ae Add test_strquote
Signed-off-by: Yu-Chen Lin <npes87184@gmail.com>
2019-12-04 19:24:59 +01:00
Romain Vimont
3100533e56 Fix "natural scrolling"
> Movements down (scroll backward) generate negative y values and up
> (scroll forward) generate positive y values.

> If direction is SDL_MOUSEWHEEL_FLIPPED the values in x and y will be
> opposite. Multiply by -1 to change them back.

<https://wiki.libsdl.org/SDL_MouseWheelEvent#Remarks>

The x and y values already take the scrolling configuration into
account. Reversing the values when the direction is flipped cancels the
scrolling configuration.

Therefore, just ignore the direction field.

Fixes <https://github.com/Genymobile/scrcpy/issues/966>
2019-12-03 21:10:43 +01:00
Seb Leo
684e0abb74 Update BUILD.md to install adb package
PR <https://github.com/Genymobile/scrcpy/pull/965>

Signed-off-by: Romain Vimont <rom@rom1v.com>
2019-12-03 16:05:23 +01:00
Romain Vimont
86fcd89d80 Fix max size default value
Suggested-by: jurkov

Closes <https://github.com/Genymobile/scrcpy/issues/978>
2019-12-03 12:07:36 +01:00
Romain Vimont
8a694a9785 Suggest workaround for error 0xfffffc0e
When the hardware encoder is not able to encode at the given definition,
it fails with an error 0xfffffc0e.

It is documented in the FAQ:
<https://github.com/Genymobile/scrcpy/blob/master/FAQ.md#i-get-an-error-could-not-open-video-stream>

But it is better to directly suggest the workaround in the console.
2019-11-30 10:46:22 +01:00
Romain Vimont
26529d377f Use virtual device id to avoid NPE
Inject mouse events using id -1 (virtual device) instead of 0 which
does not exist (and causes the InputDevice to be null).

Fixes <https://github.com/Genymobile/scrcpy/issues/962>
2019-11-29 14:31:19 +01:00
Romain Vimont
15a206b7fc Assert return value of mutex functions
Mutex functions may only fail due to a programming error.

Use assertions in debug builds, and ignore the value in release builds.
2019-11-27 21:40:58 +01:00
Romain Vimont
d0f5a7fd9f Remove unused includes
No mutex is used in decoder.c and stream.c.
2019-11-27 21:40:54 +01:00
Romain Vimont
510caff0cd Replace SDL_assert() by assert()
SDL_assert() open a dialog on assertion failure.

There is no reason not to use assert() directly.
2019-11-27 21:19:46 +01:00
Romain Vimont
b5ebb234dd Replace BUILD_DEBUG by NDEBUG
Use the "standard" NDEBUG definition, which is used by assert().
2019-11-27 21:11:52 +01:00
Romain Vimont
73e8ec1b35 Remove path argument from cmd_execute()
It is always equal to argv[0] (or not used on Windows).
2019-11-27 21:11:52 +01:00
Romain Vimont
8dc11a0286 Fix warnings on Windows
fix warnings reported with -Dwarning_level=2 on Windows.
2019-11-27 21:11:52 +01:00
Romain Vimont
06104a701b Fix windows build
Utilities have been moved to util/, but includes had not been updated
in Windows-specific files.

Ref: dfd0707a29
2019-11-27 13:25:56 +01:00
yangfl
8bc056b9c6 Fix manpage format 2019-11-27 10:58:17 +01:00
Romain Vimont
7637a113e3 Compile with warning_level=2 by default 2019-11-26 09:22:20 +01:00
Romain Vimont
31d9d56117 Fix warnings
Fix warnings reported with -Dwarning_level=2.
2019-11-26 09:10:41 +01:00
Romain Vimont
6abb8fd0cd Reformat Java code
Reformated by Android studio to match the 150 characters column defined
in checkstyle.
2019-11-25 17:33:42 +01:00
Romain Vimont
2b845680b0 Initialize Application object to avoid NPE
When an ApplicationInfo is set (commit
90293240cc), some devices (Nvidia Shield
TV) attempt to access the Application object, causing a
NullPointerException.

As a workaround, initialize an Application object.

Fixes <https://github.com/Genymobile/scrcpy/issues/940>
2019-11-24 11:58:40 +01:00
Romain Vimont
ebdc2ee8b5 Rename variable for consistency
Use suffix "Field" for fields variables.
2019-11-24 11:55:42 +01:00
Romain Vimont
dfd0707a29 Move utilities to util/ 2019-11-24 11:53:23 +01:00
seoyeonK
8ec077ce1b Add Korean translation for README and FAQ
PR <https://github.com/Genymobile/scrcpy/pull/934>

Signed-off-by: Romain Vimont <rom@rom1v.com>
2019-11-24 11:09:30 +01:00