Commit graph

914 commits

Author SHA1 Message Date
Romain Vimont
a01e9c2812 Avoid additional copy on Java text parsing
Directly pass the buffer range to the String constructor.
2020-07-09 12:28:42 +02:00
Romain Vimont
80f5a7c43d Update copy-paste section in README
Update documentation regarding the recent copy-paste changes.
2020-07-09 12:28:42 +02:00
Romain Vimont
ddb36e3436 Forward copy-cut shortcuts
For convenience, forward RCtrl+c (or Cmd+c) and and RCtrl+x (or Cmd+x)
as LCtrl+c and LCtrl+x to the device.

This allows to use the "natural" keys for copy-paste (especially on
macOS).
2020-07-09 12:28:42 +02:00
Romain Vimont
cac1765091 Change "resize to fit" shortcut to RCtrl+w
For convenience, RCtrl+x (and Cmd+x) will be used for "cut text to
clipboard", in addition to LCtrl+x.
2020-07-09 12:28:42 +02:00
Romain Vimont
f5a14b285b Accept Cmd for shortcuts on macOS
For convenience (and to keep the existing behavior), also accept
shortcuts using Cmd instead of RCtrl.
2020-07-09 12:28:42 +02:00
Romain Vimont
65edae0ca6 Reformulate RCtrl+v description
RCtrl+v is the only scrcpy shortcut related to copy-paste. Since it's
not a real "paste", reformulate to indicate that it injects the
clipboard content as text events.
2020-07-09 12:28:42 +02:00
Romain Vimont
e4a0fada10 Remove RCtrl+c copy shortcut
Now that Ctrl+c is forwarded to the device, and that every device
clipboard change is automatically synchronized to the computer, RCtrl+c
is useless.
2020-07-09 12:28:42 +02:00
Romain Vimont
8a037e3d9b Remove RCtrl+Shift+v paste shortcut
Now that LCtrl+v synchronize the computer clipboard to the device
clipboard, RCtrl+Shift+v is not needed anymore.

Note: RCtrl+v is kept to send the computer clipboard content as a
sequence of keys.
2020-07-09 12:28:42 +02:00
Romain Vimont
b3aa88c751 Set device clipboard only if necessary
Do not explicitly set the clipboard text if it already contains the
expected content. This avoids possible copy-paste loops between the
computer and the device.
2020-07-09 12:28:37 +02:00
Romain Vimont
b9602e56d9 Synchronize clipboard on Ctrl+v
Pressing Ctrl+v on the device will typically paste the clipboard
content.

Before sending the key event, synchronize the computer clipboard to the
device clipboard to allow seamless copy-paste.
2020-06-02 18:27:24 +02:00
Romain Vimont
0c01ac34b4 Simplify PASTE option for "set clipboard"
When the client requests to set the clipboard, it may request to press
the PASTE key in addition. To be a bit generic, it was stored as a flag
in ControlMessage.java.

But flags suggest that it represents a bitwise union, which could become
confusing when we add a COPY option for getting the clipboard.
2020-06-02 18:27:24 +02:00
Romain Vimont
82295ef4a7 Forward Shift to the device
This allows to select text using Shift+(arrow keys).

Fixes #942 <https://github.com/Genymobile/scrcpy/issues/942>
2020-06-02 18:27:24 +02:00
Romain Vimont
e62aca59fe Forward LCtrl to the device
Now that only RCtrl is used for scrcpy shortcuts, LCtrl can be forwarded
to the device.

This allows to trigger Android shortcuts.

Fixes #555 <https://github.com/Genymobile/scrcpy/issues/555>
2020-06-02 18:27:24 +02:00
Romain Vimont
fbd2d0bf3e Only use RCtrl for scrcpy shortcuts
This paves the way to forward LCtrl to the device.
2020-06-02 18:27:24 +02:00
Romain Vimont
6e1069a822 Configure log level for application only
Do not expose internal SDL logs to users.

Fixes #1441 <https://github.com/Genymobile/scrcpy/issues/1441>
2020-06-02 18:27:23 +02:00
Romain Vimont
c4323df976 Fix incorrect log return value
The function must return a SDL_LogPriority, but returned an enum
sc_log_level.

(It was harmless because this specific return should never happen, as
asserted.)
2020-06-02 18:27:14 +02:00
Romain Vimont
8ff07e0c88 Git-ignore release directories 2020-06-02 18:25:22 +02:00
Romain Vimont
e4efd75766 Avoid repetition for some shortcuts
Keeping the key pressed generate "repeat" events. It does not make sense
to repeat the event for rotation or turn screen off.
2020-05-29 22:02:41 +02:00
Romain Vimont
0e4a6f462b Mention stay awake limitation
The "stay awake" feature only works when the device is plugged in.

Refs #1445 <https://github.com/Genymobile/scrcpy/issues/1445>
2020-05-28 23:07:28 +02:00
Romain Vimont
8b73c90427 Mention how to turn the screen on in README
Now that Ctrl+Shift+o has been reactivated, mention it in the "turn
screen off" section.
2020-05-27 19:32:02 +02:00
Romain Vimont
ef91ab2841 Update links to v1.14 in README and BUILD 2020-05-27 19:31:12 +02:00
Romain Vimont
44fa4a090e Bump version to 1.14 2020-05-27 18:26:46 +02:00
Romain Vimont
dcde578a50 Reactivate "turn device screen on" feature
This reverts commit 8c8649cfcd.

I cannot reproduce the issue with Ctrl+Shift+o on any device, so in
practice it works, it's too bad to remove the feature for a random bug
on some Android versions on some devices.
2020-05-27 18:26:46 +02:00
Romain Vimont
93a5c5149d Push clipboard text only if not null
In practice, it does not change anything (it just avoids a spurious
wake-up), but semantically, it makes no sense to call
pushClipboardText() with a null value.
2020-05-27 18:26:39 +02:00
Romain Vimont
2ca8318b9d Improve manpage formatting
Add a new line to avoid unwanted text justification
2020-05-27 12:39:42 +02:00
Romain Vimont
d499ee53c9 Initialize a default log level
Clean up has been broken by 3df63c579d.

The verbosity was correctly initialized for the Server process, but not
for the CleanUp process.

To avoid the problem, initialize a default log level.
2020-05-27 12:05:29 +02:00
Romain Vimont
8f619f337b Upgrade platform-tools (30.0.0) for Windows
Include the latest version of adb in Windows releases.
2020-05-26 19:21:05 +02:00
Romain Vimont
fc1dec0270 Paste on "set clipboard" if possible
Ctrl+Shift+v synchronizes the computer clipboard to the Android device
clipboard. This feature had been added to provide a way to copy UTF-8
text from the computer to the device.

To make such a paste more straightforward, if the device runs at least
Android 7, also send a PASTE keycode to paste immediately.

<https://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_PASTE>

Fixes #786 <https://github.com/Genymobile/scrcpy/issues/786>
2020-05-25 20:59:21 +02:00
Romain Vimont
274b591d18 Fix union typo
The "set clipboard" event used the wrong union type to store its text.

In practice, it worked because both are at the same offset.
2020-05-25 18:41:05 +02:00
Romain Vimont
4bbabfb4ef Move injection methods to Device
Only the main injection method was exposed on Device, the convenience
methods were implemented in Controller.

For consistency, move them all to the Device class.
2020-05-25 03:28:33 +02:00
Romain Vimont
ffc57512b3 Avoid clipboard synchronization loop
The Android device listens for clipboard changes to synchronize with the
computer clipboard.

However, if the change comes from scrcpy (for example via Ctrl+Shift+v),
do not notify the change.
2020-05-25 03:28:33 +02:00
Romain Vimont
c7a33fac36 Log actions on the caller side
Some actions are exposed by the Device class, but logging success should
be done by the caller.
2020-05-25 03:28:33 +02:00
Romain Vimont
81573d81a0 Pass a Locale to toUpperCase()
Make lint happy.
2020-05-25 03:28:15 +02:00
Romain Vimont
5c2cf88a1d Rename THRESHOLD to threshold
Since the field is not final anymore, lint expects the name not to be
capitalized.
2020-05-25 03:22:07 +02:00
Romain Vimont
8f46e18426 Add --force-adb-forward
Add a command-line option to force "adb forward", without attempting
"adb reverse" first.

This is especially useful for using SSH tunnels without enabling remote
port forwarding.
2020-05-24 23:28:31 +02:00
Romain Vimont
ee3882f8be Fix typo in manpage 2020-05-24 23:14:30 +02:00
Romain Vimont
a3ef461d73 Add cli option to set the verbosity level
The verbosity was set either to info (in release mode) or debug (in
debug mode).

Add a command-line argument to change it, so that users can enable debug
logs using the release:

    scrcpy -Vdebug
2020-05-24 22:01:51 +02:00
Romain Vimont
3df63c579d Configure server verbosity from the client
Send the requested log level from the client.

This paves the way to configure it via a command-line argument.
2020-05-24 21:14:25 +02:00
Romain Vimont
56bff2f718 Avoid compiler warning
The field lock_video_orientation may only take values between -1 and 3
(included). But the compiler may trigger a warning on the sprintf()
call, because its type could represent values which could overflow the
string (like "-128"):

> warning: ‘%i’ directive writing between 1 and 4 bytes into a region of
> size 3 [-Wformat-overflow=]

Increase the buffer size to remove the warning.
2020-05-24 21:11:21 +02:00
Tzah Mazuz
080a4ee365 Add --codec-options
Add a command-line parameter to pass custom options to the device
encoder (as a comma-separated list of "key[:type]=value").

The list of possible codec options is available in the Android
documentation:
<https://d.android.com/reference/android/media/MediaFormat>

PR #1325 <https://github.com/Genymobile/scrcpy/pull/1325>
Refs #1226 <https://github.com/Genymobile/scrcpy/pull/1226>

Co-authored-by: Romain Vimont <rom@rom1v.com>
2020-05-24 14:54:34 +02:00
Romain Vimont
c7155a1954 Add unit test for big "set clipboard" event
Add a unit test to avoid regressions.

Refs #1425 <https://github.com/Genymobile/scrcpy/issues/1425>
2020-05-24 14:33:43 +02:00
Romain Vimont
517dbd9c85 Increase buffer size to fix "set clipboard" event
The buffer size must be greater than any event message.

Clipboard events may take up to 4096 bytes, so increase the buffer size.

Fixes #1425 <https://github.com/Genymobile/scrcpy/issues/1425>
2020-05-24 14:33:23 +02:00
Romain Vimont
acc4ef31df Synchronize device clipboard to computer
Automatically synchronize the device clipboard to the computer any time
it changes.

This allows seamless copy-paste from Android to the computer.

Fixes #1056 <https://github.com/Genymobile/scrcpy/issues/1056#issuecomment-631363684>
PR #1423 <https://github.com/Genymobile/scrcpy/pull/1423>
2020-05-24 14:31:49 +02:00
Romain Vimont
73e722784d Remove useless exception declaration
The interface declares it can throw a RemoteException, but the
implementation never throws such exception.
2020-05-23 18:21:54 +02:00
Romain Vimont
e1cd75792c Simplify rotation watcher call
Remove unnecessary private method (which was wrongly public).
2020-05-23 14:39:09 +02:00
Romain Vimont
ac4c8b4a3f Increase LOD bias for mipmapping
Mipmapping caused too much blurring.

Using a LOD bias of -1 instead of -0.5 seems a better compromise to
avoid low-quality downscaling while keeping sharp edges in any case.

Refs <https://github.com/Genymobile/scrcpy/issues/1394>
Refs <https://github.com/Genymobile/scrcpy/issues/40#issuecomment-591917787>
2020-05-23 14:32:16 +02:00
Romain Vimont
fae3f9eeab Remove warning when renderer is not OpenGL
Trilinear filtering can currently only be enabled for OpenGL renderers.

Do not print a warning if the renderer is not OpenGL, as it can confuses
users, while nothing is wrong.
2020-05-23 14:23:30 +02:00
Romain Vimont
f5aeecbc62 Reset window size on initialization
On macOS with renderer "metal", HiDPI scaling may be incorrect on
initialization when several displays are connected.

Resetting the window size fixes the problem.

Refs #15 <https://github.com/Genymobile/scrcpy/issues/15>
2020-05-23 14:19:09 +02:00
Romain Vimont
e40532a376 Manually position and scale the content
Position and scale the content "manually" instead of relying on the
renderer "logical size".

This avoids possible rounding differences between the computed window
size and the content size, causing one row or column of black pixels on
the bottom or on the right.

This also avoids HiDPI scale issues, by computing the scaling manually.

This will also enable to draw items at their expected size on the screen
(unscaled).

Fixes #15 <https://github.com/Genymobile/scrcpy/issues/15>
2020-05-23 14:19:09 +02:00
Romain Vimont
d860ad48e6 Extract optimal window size detection
Extract the computation to detect whether the current size of the window
is already optimal.

This will allow to reuse it for rendering.
2020-05-23 14:19:09 +02:00