Commit Graph

39 Commits (7458d8271e89408c12b691f7440969771db11e31)

Author SHA1 Message Date
Romain Vimont 127e56780a Fix deadlock on exit if SKIP_FRAMES disabled
On exit, the renderer will not consume frames anymore, so signal the
condition variable to wake up the decoder.
6 years ago
Romain Vimont 629c296207 Move frame swapping logic to frame.c
Expose frames_offer_decoded_frame() and frames_consume_rendered_frame()
so that callers are not exposed to frame swapping (between the decoding
and rendering frames) details.
6 years ago
Romain Vimont 0d7f050389 Unlock mutex on screen update failure
The mutex was not unlocked on all code paths.
6 years ago
Romain Vimont e8dfb723af Move control-related code to screencontrol.c
Move the code handling user input from scrcpy.c to a separate file,
screencontrol.c.
6 years ago
Romain Vimont e1749a0c09 Remove the "adb reverse" tunnel immediately
As soon as we accepted a connection, we can remove the "adb reverse"
tunnel.
6 years ago
Romain Vimont 3b06e7d500 Move device-related code to device.c
Move the code to read the initial device info from scrcpy.c to a
separate file, device.c.
6 years ago
Romain Vimont 28c5cc030b Move server-related code to server.c
The file server.c already existed, but exposed a low-level API. Make it
higher-level, so that scrcpy.c does not handle server details directly.
6 years ago
Romain Vimont 6c578b5caa Move screen-related code to screen.c
The file scrcpy.c contains too many different things in addition to the
main logic, so move the screen code to a separate file, screen.c.
6 years ago
Romain Vimont ffae15e36a Rename control to controller
The struct decoder is defined in decoder.h.

For naming consistency, define the struct controller in controller.h.
6 years ago
Romain Vimont 7b7fd77134 Add missing static
Some functions in scrcpy.c are not used outside the file, so declare
them static.
6 years ago
Romain Vimont f39de46a39 Add delay before stopping server
Let some time to print any exception trace before killing it.
6 years ago
Romain Vimont cb1428223f Log user request to quit
Log at debug level user requests to quit.
6 years ago
Romain Vimont 8d30d40b79 Make SKIP_FRAMES a compilation flag
The skip_frames flag was a non-configurable runtime flag. Since it is
not exposed to the user, there is no need for a (possible) runtime cost.

For testing purpose, we still want it to be configurable, so make it a
compilation flag.
6 years ago
Romain Vimont 71c2bfdd22 Parse XPM without SDL_image
We encounter some problems with SDL2_image on MSYS2 (Windows), so
implement our own XPM parsing which does not depend on SDL_image.

The input XPM is considered safe (it's in our source repo), so do not
check XPM format errors. This implies that read_xpm() is not safe to
call on any unsafe input.

Although less straightforward, use SDL_CreateRGBSurfaceFrom() instead of
SDL_CreateRGBSurfaceWithFormatFrom() because it is available with SDL
versions older than 2.0.5.
6 years ago
Romain Vimont f22d4decca Enable mouse focus clickthrough only if available
The hint SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH appeared in SDL 2.0.5. Ignore
it if the SDL version is older.
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 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 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 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 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.
6 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.
6 years ago
Romain Vimont 2683fa20ed Add debug log for shortcuts
Add a debug log for every succeeded shortcut action.
6 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.
6 years ago
Romain Vimont ee93f3f23a Rename maximum_size to max_size
The long option is --max-size, so for consistency, adapt the code
accordingly.
6 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;
            // ...
        }
    }
6 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.
6 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.
6 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).
6 years ago
Romain Vimont ab2c3de9f5 Capture all Ctrl events
For consistency, capture all Ctrl events (not only those we react to).
6 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 de106747b6 Improve main() error handling
Parse the command-line arguments first, and do not ignore avformat
network init failure. At the end, deinit the avformat network.
7 years ago
Romain Vimont 37d88b8a6a Use SDL_bool return type instead of int
Many functions returned an int to indicate their success. For clarity,
use SDL_bool instead.
7 years ago
Romain Vimont 54d9148a36 Initial commit
Start a new clean history from here.
7 years ago