Commit Graph

75 Commits (de192cab1b5f0829fedd34d4feb569445c02346c)
 

Author SHA1 Message Date
Romain Vimont de192cab1b Fix Makefile for Windows
The default value of GRADLE is "./gradlew", which is the correct value
on Linux.

On Windows, it should use gradlew.bat (by calling "gradlew") instead.
6 years ago
Romain Vimont 52c89c7afb Add window icon
Add a bugdroid icon loaded from an XPM.
6 years ago
Romain Vimont 5eb91a4ca7 Fix scrcpy() return value
The scrcpy() function returns a SDL_bool to indicate its success, but
was initialized to 0 (SDL_FALSE) instead of SDL_TRUE.
6 years ago
Romain Vimont 82ee55845c Add "make run"
To run the app during development, add a recipe "run" to the Makefile.
6 years ago
Romain Vimont 1ac37c4291 Hide services in Device
Expose useful methods directly in Device, without exposing the service
managers.
6 years ago
Romain Vimont 06333e1e08 Cache managers in ServiceManager
To guarantee that we instantiate services only one, cache the value the
first time.
6 years ago
Romain Vimont 69a359c7f4 Refactor actions calls
The purpose of handle_shortcut() was to group all actions together,
whether they are initiated from a text input event or a keycode event.

However, it did not handle the case where it was initiated from a mouse
event (a right-click must turn the screen on), since the action was
identified by the shortcut char.

Instead, expose one function per action, to be called directly from
where the event is handled.
6 years ago
Romain Vimont d73dee9833 fixup! Handle all shortcuts in the same function 6 years ago
Romain Vimont 0a70e24e80 Add new shortcuts description in help
Document the new shortcuts in the help (scrcpy --help).
6 years ago
Romain Vimont 3365460658 Turn screen on on start
When starting scrcpy, immediately turn the screen on.
6 years ago
Romain Vimont a139509f11 Turn screen on on right-click
The right-click is almost useless on Android, so use it to turn the
screen on.

Add a new control event type (command) to request the server to turn the
screen on.
6 years ago
Romain Vimont 228545cefd Reformat EventController
Reformated by Android Studio.
6 years ago
Romain Vimont deba69d022 Handle all shortcuts in the same function
Shortcuts are sometimes initiated from a keycode event, and sometimes
from a text input event.

Move the handling to a unique function.
6 years ago
Romain Vimont 7f6a565401 Extract shortcut actions to separate functions
To simplify event handling code, move all actions to separate functions.
6 years ago
Romain Vimont f8ad007a28 Move switch fullscreen logs
Logs were printed by the caller of switch_fullscreen(). Move them inside
the function to simplify event handling code.
6 years ago
Romain Vimont 6fe7b84629 Add shortcuts for physical keys
Add shortcuts for HOME, BACK, APPS, POWER, VOLUME_UP and VOLUME_DOWN.
6 years ago
Romain Vimont 1faf6cfd9d Rename the server scrcpy-server.jar
The server is built as an APK to simplify the build, but in fact this is
a simple jar (it is not even signed).

In order to avoid confusion, rename it to .jar, so that users do not try
to "adb install" it.

Also rename it from "scrcpy" to "scrcpy-server" to distinguish from the
client-side.
6 years ago
Romain Vimont 2172c53b7b Force the server target filename
The server path may be customized using SCRCPY_APK. If its basename is
different from "scrcpy.apk", it will be pushed with a different name,
so the execution would fail.

Therefore, force the push target filename.
6 years ago
Romain Vimont ca44585f96 Do not send simple mouse move events
Moving the mouse without any button pressed has no effect on Android.
Therefore, do not even send these very frequent events.
6 years ago
Romain Vimont 79b28eb68f Enable mouse focus clickthrough
Consider a click to gain focus as a click on the device.
7 years ago
Romain Vimont 6b546a87ab Add bit-rate command-line option
Add a command-line option (-b/--bit-rate) to customize the video
bit-rate.
7 years ago
Romain Vimont 7fe7bbf58c Check empty string before strtol()
There is no need to call strtol() if the input string is empty.
7 years ago
Romain Vimont 3bc63708b4 Remove useless newlines in SDL_Log*
Trailing new line is not necessary in SDL_Log* methods.
7 years ago
Romain Vimont 2683fa20ed Add debug log for shortcuts
Add a debug log for every succeeded shortcut action.
7 years ago
Romain Vimont 274e1ac9ec Fix rotation bug in fullscreen mode on X11
On rotation, scrcpy resize the window to match the new rotation.
However, in fullscreen mode, setting the window size does not change the
windowed size on X11, so the behavior is incorrect.

To avoid the problem, apply the resize only after fullscreen is
disabled.
7 years ago
Romain Vimont 35a111d56e Add --help
Provide command-line help, with -h/--help option.
7 years ago
Romain Vimont ee93f3f23a Rename maximum_size to max_size
The long option is --max-size, so for consistency, adapt the code
accordingly.
7 years ago
Romain Vimont 213b721ff9 Use long command-line options
In addition to the short form (e.g. "-p"), add the long form ("--port").
7 years ago
Romain Vimont 60b2f2ca64 Indent switch blocks content
For readability, indent "case" in switch blocks.

Replace:

    switch (x) {
    case 1:
        // ...
    case 2:
        // ...
    case 3: { // a local scope block
        int i = 42;
        // ...
    }
    }

By:

    switch (x) {
        case 1:
            // ...
        case 2:
            // ...
        case 3: { // a local scope block
            int i = 42;
            // ...
        }
    }
7 years ago
Romain Vimont 628f88ab89 Use ADB environment variable
Use the ADB environment variable to provide a custom adb path.
7 years ago
Romain Vimont 865ebb3862 Encode video using MediaCodec API
Replace screenrecord execution by manual screen encoding using the
MediaCodec API.

The "screenrecord" solution had several drawbacks:
 - screenrecord output is buffered, so tiny frames may not be accessible
   immediately;
 - it did not output a frame until the surface changed, leading to a
   black screen on start;
 - it is limited to 3 minutes recording, so it needed to be restarted;
 - screenrecord added black borders in the video when the requested
   dimensions did not preserve aspect-ratio exactly (sometimes
   unavoidable since video dimensions must be multiple of 8);
 - rotation handling was hacky (killing the process and starting a new
   one).

Handling the encoding manually allows to solve all these problems.
7 years ago
Romain Vimont 7ed334915e Register uncaught exception handler
Never miss an exception by using an uncaught exception handler.
7 years ago
Romain Vimont 8c4a454d68 Extract argument parsing
Move argument parsing to a separate method.
7 years ago
Romain Vimont 73831a0837 Use the Point class from the framework
Replace our custom Point class by android.graphics.Point.
7 years ago
Romain Vimont b67907e24e Convert server to an Android project
To simplify the device server-side build, use gradle to create an APK,
even if we use it as a simple jar, by running its main() method.
7 years ago
Romain Vimont 89f6a3cfe7 Handle resized video stream
Accept a parameter to limit the video size.

For instance, with "-m 960", the great side of the video will be scaled
down to 960 (if necessary), while the other side will be scaled down so
that the aspect ratio is preserved. Both dimensions must be a multiple
of 8, so black bands might be added, and the mouse positions must be
computed accordingly.
7 years ago
Romain Vimont 2c4ea6869e Do not use device as a singleton
The device instance should be able to store a state (e.g. the maximum
size requested by the user), so it should not be a singleton.
7 years ago
Romain Vimont 879941355d Swap position/point names
A point is a 2D vector. A position represent a point relative to the
screen size.
7 years ago
Romain Vimont f70359f14f Inject mouse events as touchscreen
As a mouse, some clicks on close prositions are sometimes not generated
on some devices.
7 years ago
Romain Vimont 1930c81062 Add toString() methods to java point classes
Useful for debugging.
7 years ago
Romain Vimont dca53ff931 Add missing source files in server Makefile
All classes were still built, but make was not able to detect changes on
missing files.
7 years ago
Romain Vimont 2aa15db210 Add shortcut to resize to ratio 1:1
Make Ctrl+g resize the window to the size of the video (pixel-perfect).
7 years ago
Romain Vimont ab2c3de9f5 Capture all Ctrl events
For consistency, capture all Ctrl events (not only those we react to).
7 years ago
Romain Vimont 2c35220618 Rename screen -> scrcpy -> main
Rename scrcpy.c to main.c (this file handles the command line parsing),
and screen.c to scrcpy.c (it exposes the entry point scrcpy()).
7 years ago
Romain Vimont 8984c1a7c4 Scale mouse events
The video screen size on the client may differ from the real device
screen size (e.g. the video stream may be scaled down). As a
consequence, mouse events must be scaled to match the real device
coordinates.

For this purpose, make the client send the video screen size along with
the absolute pointer location, and the server scale the location to
match the real device size before injecting mouse events.
7 years ago
Romain Vimont 11a60e5767 Keep screen info in cache
Currently, we only use screen information (width, height, rotation)
once at initialization, to send the device size to the client.

To be able to scale mouse events, make it accessible in memory. For this
purpose, replace the "static" DeviceUtil to a singleton Device, and
update it on every screen rotation.
7 years ago
Romain Vimont d7b00a9bab Move server-related functions to server.c
In addition to the functions to start/stop the server, move the
functions to push the jar and enable/disable the "adb reverse" tunnel.
7 years ago
Romain Vimont 3078894d1f Add debug log on new screenrecord execution
To easily notice problems with screenrecord execution, log every new
instance started.
7 years ago
Romain Vimont 7d67696b7e Extract server-related functions
To lighten screen.c, move start_server() and stop_server() to a separate
file.
7 years ago
Romain Vimont 52af91f6b0 Add unit tests for control event serialization
Test serialization of the 4 types of events (keycode, text, mouse,
scroll).
7 years ago