Romain Vimont
b52f87a892
Add util function to locate a column in a string
...
This will help to parse the result of "adb shell ip route" to find the
device IP address.
PR #2827 <https://github.com/Genymobile/scrcpy/pull/2827 >
2021-11-29 20:39:03 +01:00
Romain Vimont
007f616302
Add missing includes
...
Include these headers explicitly instead of relying on transitivity.
2021-11-24 21:44:29 +01:00
Romain Vimont
2a0730ee9b
Add device clipboard set acknowledgement
...
Add a device message type so that the device could send acknowledgements
for SET_CLIPBOARD requests.
PR #2814 <https://github.com/Genymobile/scrcpy/pull/2814 >
2021-11-23 21:15:05 +01:00
Romain Vimont
901d837165
Add sequence number to set_clipboard request
...
This will allow the client to request an acknowledgement.
PR #2814 <https://github.com/Genymobile/scrcpy/pull/2814 >
2021-11-23 21:15:05 +01:00
Romain Vimont
0427a981e5
Use UINT64_C macro for uint64_t constant in tests
...
A long constant might not be sufficient.
2021-11-21 22:57:33 +01:00
Romain Vimont
9619ade706
Generalize string trunctation util function
...
Add an additional argument to let the client pass the possible end
chars.
2021-11-18 18:48:16 +01:00
Romain Vimont
f2781a8b6d
Expose util function to truncate first line
...
Move the local implementation from adb functions to the string util
functions.
2021-11-18 18:48:16 +01:00
Romain Vimont
057c7a4df4
Move str_util to str
...
Simplify naming.
2021-11-14 01:22:22 +01:00
Romain Vimont
979ce64dc0
Improve string util API
...
Use prefixed names and improve documentation.
2021-11-14 01:22:22 +01:00
Romain Vimont
9ec3406568
Add line wrapper
...
Add a tool to wrap lines at words boundaries (spaces) to fit in a
specified number of columns, left-indented by a specified number of
spaces.
2021-11-11 14:55:53 +01:00
Romain Vimont
6dba1922c1
Add string buffer util
...
This will help to build strings incrementally.
2021-11-11 14:55:52 +01:00
Romain Vimont
27fa23846d
Define default options as const struct
...
This is more readable than a macro, and we could ifdef some fields.
2021-10-27 18:43:47 +02:00
Romain Vimont
e4d5c1ce36
Move scrcpy option structs to options.h
...
This will allow to define symbols in options.c without all the
dependencies of scrcpy.c.
2021-10-27 18:43:47 +02:00
Romain Vimont
2f03141e9f
Add clock tests
...
The clock rolling sum is not trivial. Test it.
2021-07-14 14:54:22 +02:00
Romain Vimont
099cba07f0
Rename queue to sc_queue
...
Add a scrcpy-specific prefix.
2021-07-14 00:35:10 +02:00
Romain Vimont
f76fe2c0d4
Fix --lock-video-orientation syntax
...
The argument for option --lock-video-orientation has been made optional
by 5af9d0ee0f .
With getopt_long(), contrary to mandatory arguments, optional arguments
must be given with a '=':
--lock-video-orientation 2 # wrong, parse error
--lock-video-orientation=2 # correct
2021-06-11 18:40:12 +02:00
Romain Vimont
ffc00210e9
Add strlist_contains()
...
Add a function to know if a string list, using some separator, contains
a specific string.
2021-04-25 14:38:42 +02:00
Romain Vimont
55806e7d31
Remove option --render-expired-frames
...
This flag forced the decoder to wait for the previous frame to be
consumed by the display.
It was initially implemented as a compilation flag for testing, not
intended to be exposed at runtime. But to remove ifdefs and to allow
users to test this flag easily, it had finally been exposed by commit
ebccb9f6cc .
In practice, it turned out to be useless: it had no practical impact,
and it did not solve or mitigate any performance issues causing frame
skipping.
But that added some complexity to the codebase: it required an
additional condition variable, and made video buffer calls possibly
blocking, which in turn required code to interrupt it on exit.
To prepare support for multiple sinks plugged to the decoder (display
and v4l2 for example), the blocking call used for pacing the decoder
output becomes unacceptable, so just remove this useless "feature".
2021-04-25 14:38:42 +02:00
brunoais
50eecdab28
Add control message to expand settings panel
...
PR #2260 <https://github.com/Genymobile/scrcpy/pull/2260 >
Signed-off-by: Romain Vimont <rom@rom1v.com >
2021-04-25 14:36:48 +02:00
brunoais
66c581851f
Rename control message type to COLLAPSE_PANELS
...
The collapsing action collapses any panels.
By the way, the Android method is named collapsePanels().
PR #2260 <https://github.com/Genymobile/scrcpy/pull/2260 >
Signed-off-by: Romain Vimont <rom@rom1v.com >
2021-04-25 14:36:48 +02:00
Romain Vimont
d0739911a3
Forward DOWN and UP separately for right-click
...
The shortcut "back on screen on" is a bit special: the control is
requested by the client, but the actual event injection (POWER or BACK)
is determined on the device.
To properly inject DOWN and UP events for BACK, transmit the action as
a control parameter.
If the screen is off:
- on DOWN, inject POWER (DOWN and UP) (wake up the device immediately)
- on UP, do nothing
If the screen is on:
- on DOWN, inject BACK DOWN
- on UP, inject BACK UP
A corner case is when the screen turns off between the DOWN and UP
event. In that case, a BACK UP event will be injected, so it's harmless.
As a consequence of this change, the BACK button is now handled by
Android on mouse released. This is consistent with the keyboard shortcut
(Mod+b) behavior.
PR #2259 <https://github.com/Genymobile/scrcpy/pull/2259 >
Refs #2258 <https://github.com/Genymobile/scrcpy/pull/2258 >
2021-04-19 20:16:45 +02:00
Romain Vimont
30e619d37f
Replace SDL_strdup() by strdup()
...
The functions SDL_malloc(), SDL_free() and SDL_strdup() were used only
because strdup() was not available everywhere.
Now that it is available, use the native version of these functions.
2021-02-17 09:54:03 +01:00
Romain Vimont
94eff0a4bb
Fix size_t incorrectly assigned to int
...
The function control_msg_serialize() returns a size_t.
2021-01-17 19:44:23 +01:00
Romain Vimont
ab912c23e7
Define feature test macros in common.h
...
This enables necessary functions once for all.
As a consequence, define common.h before any other header.
2021-01-17 14:08:48 +01:00
Romain Vimont
59feb2a15c
Group common includes into common.h
...
Include config.h and compat.h in common.h, and include common.h from all
source files.
2021-01-08 19:22:10 +01:00
Romain Vimont
1b76d9fd78
Customize shortcut modifier
...
Add --shortcut-mod, and use Alt as default modifier.
This paves the way to forward the Ctrl key to the device.
2020-08-01 16:31:27 +02:00
Romain Vimont
199c74f62f
Declare main() with argc/argv params in tests
...
Declaring the main method as "int main(void)" causes issues with SDL.
Fixes #1209 <https://github.com/Genymobile/scrcpy/issues/1209 >
2020-07-15 12:17:04 +02:00
xeropresence
3c1ed5d86c
Handle repeating keycodes
...
Initialize "repeat" count on key events.
PR #1519 <https://github.com/Genymobile/scrcpy/pull/1519 >
Refs #1013 <https://github.com/Genymobile/scrcpy/pull/1013 >
Signed-off-by: Romain Vimont <rom@rom1v.com >
2020-06-19 22:30:17 +02:00
Romain Vimont
0ba74fbd9a
Make scrcpy.h independant of other headers
...
The header scrcpy.h is intended to be the "public" API. It should not
depend on other internal headers.
Therefore, declare all required structs in this header and adapt
internal code.
2020-06-19 22:30:02 +02:00
Romain Vimont
29e5af76d4
Remove fprintf() call in tests
...
It should never have been committed.
2020-06-19 21:54:46 +02:00
Romain Vimont
245999aec4
Serialize text size on 4 bytes
...
This will allow to send text having a size greater than 65535 bytes.
2020-06-11 23:11:17 +02:00
Romain Vimont
d91c5dcfd5
Rename MSG_SERIALIZED_MAX_SIZE to MSG_MAX_SIZE
...
For simplicity and consistency with the server part.
2020-06-11 23:08:04 +02:00
Romain Vimont
d202d7b205
Add unit test for big clipboard device message
...
Test clipboard synchronization from the device to the computer.
2020-06-11 23:06:02 +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
270d0bf639
Rename max length constant for text injection
...
To avoid confusion with the max text size for clipboard, rename the
constant limiting the text injection length.
2020-04-13 19:38:43 +02:00
George Stamoulis
1982bc439b
Add option to lock video orientation
...
PR #1151 <https://github.com/Genymobile/scrcpy/pull/1151 >
Signed-off-by: Romain Vimont <rom@rom1v.com >
2020-02-27 21:24:37 +01:00
Romain Vimont
dc7fcf3c7a
Accept port range
...
Accept a range of ports to listen to, so that it does not fail if
another instance of scrcpy is currently starting.
The range can be passed via the command line:
scrcpy -p 27183:27186
scrcpy -p 27183 # implicitly 27183:27183, as before
The default is 27183:27199.
Closes #951 <https://github.com/Genymobile/scrcpy/issues/951 >
2020-01-18 17:21:00 +01:00
Romain Vimont
2a3a9d4ea9
Add util function to parse a list of integers
...
This will help parsing arguments like '1234:5678' into a list of
integers.
2020-01-18 17:21:00 +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
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
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
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
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
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
dfd0707a29
Move utilities to util/
2019-11-24 11:53:23 +01:00
Romain Vimont
6220456def
Merge mouse and touch events
...
Both are handled the very same way on the device.
2019-10-03 20:37:49 +02:00
Romain Vimont
77f876e29c
Add "inject touch" control message
...
Add a control message type in the protocol to forward touch events to
the device.
2019-10-03 20:05:27 +02:00