mirror of
https://github.com/Genymobile/scrcpy
synced 2025-09-05 08:45:47 +00:00
Drag and drop to install apk files from computer
<https://github.com/Genymobile/scrcpy/pull/133>
This commit is contained in:
committed by
Romain Vimont
parent
41419a2e77
commit
e2a2973990
@@ -22,12 +22,14 @@
|
||||
#include "screen.h"
|
||||
#include "server.h"
|
||||
#include "tinyxpm.h"
|
||||
#include "installer.h"
|
||||
|
||||
static struct server server = SERVER_INITIALIZER;
|
||||
static struct screen screen = SCREEN_INITIALIZER;
|
||||
static struct frames frames;
|
||||
static struct decoder decoder;
|
||||
static struct controller controller;
|
||||
static struct installer installer;
|
||||
|
||||
static struct input_manager input_manager = {
|
||||
.controller = &controller,
|
||||
@@ -102,6 +104,9 @@ static void event_loop(void) {
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
input_manager_process_mouse_button(&input_manager, &event.button);
|
||||
break;
|
||||
case SDL_DROPFILE:
|
||||
installer_install_apk(&installer, event.drop.file);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -169,6 +174,12 @@ SDL_bool scrcpy(const struct scrcpy_options *options) {
|
||||
goto finally_destroy_server;
|
||||
}
|
||||
|
||||
if (!installer_init(&installer, server.serial)) {
|
||||
ret = SDL_FALSE;
|
||||
server_stop(&server);
|
||||
goto finally_destroy_frames;
|
||||
}
|
||||
|
||||
decoder_init(&decoder, &frames, device_socket);
|
||||
|
||||
// now we consumed the header values, the socket receives the video stream
|
||||
@@ -176,7 +187,7 @@ SDL_bool scrcpy(const struct scrcpy_options *options) {
|
||||
if (!decoder_start(&decoder)) {
|
||||
ret = SDL_FALSE;
|
||||
server_stop(&server);
|
||||
goto finally_destroy_frames;
|
||||
goto finally_destroy_installer;
|
||||
}
|
||||
|
||||
if (!controller_init(&controller, device_socket)) {
|
||||
@@ -214,6 +225,10 @@ finally_stop_decoder:
|
||||
// stop the server before decoder_join() to wake up the decoder
|
||||
server_stop(&server);
|
||||
decoder_join(&decoder);
|
||||
finally_destroy_installer:
|
||||
installer_stop(&installer);
|
||||
installer_join(&installer);
|
||||
installer_destroy(&installer);
|
||||
finally_destroy_frames:
|
||||
frames_destroy(&frames);
|
||||
finally_destroy_server:
|
||||
|
Reference in New Issue
Block a user