diff --git a/app/src/aoa_hid.h b/app/src/aoa_hid.h index 11cc57b8..24cef502 100644 --- a/app/src/aoa_hid.h +++ b/app/src/aoa_hid.h @@ -6,7 +6,6 @@ #include -#include "scrcpy.h" #include "util/cbuf.h" #include "util/thread.h" #include "util/tick.h" diff --git a/app/src/cli.c b/app/src/cli.c index a0a508af..cab25772 100644 --- a/app/src/cli.c +++ b/app/src/cli.c @@ -6,7 +6,7 @@ #include #include -#include "scrcpy.h" +#include "options.h" #include "util/log.h" #include "util/str_util.h" diff --git a/app/src/cli.h b/app/src/cli.h index 419f156f..b9361a9c 100644 --- a/app/src/cli.h +++ b/app/src/cli.h @@ -5,7 +5,7 @@ #include -#include "scrcpy.h" +#include "options.h" struct scrcpy_cli_args { struct scrcpy_options opts; diff --git a/app/src/input_manager.h b/app/src/input_manager.h index bd9d7a1b..f018f98a 100644 --- a/app/src/input_manager.h +++ b/app/src/input_manager.h @@ -9,7 +9,7 @@ #include "controller.h" #include "fps_counter.h" -#include "scrcpy.h" +#include "options.h" #include "screen.h" #include "trait/key_processor.h" #include "trait/mouse_processor.h" diff --git a/app/src/keyboard_inject.h b/app/src/keyboard_inject.h index e59de46d..f4ebe40e 100644 --- a/app/src/keyboard_inject.h +++ b/app/src/keyboard_inject.h @@ -6,7 +6,7 @@ #include #include "controller.h" -#include "scrcpy.h" +#include "options.h" #include "trait/key_processor.h" struct sc_keyboard_inject { diff --git a/app/src/main.c b/app/src/main.c index 2afa3c4e..51c13fd5 100644 --- a/app/src/main.c +++ b/app/src/main.c @@ -1,5 +1,3 @@ -#include "scrcpy.h" - #include "common.h" #include @@ -13,6 +11,8 @@ #include #include "cli.h" +#include "options.h" +#include "scrcpy.h" #include "util/log.h" static void diff --git a/app/src/mouse_inject.h b/app/src/mouse_inject.h index d5220db9..7dcf7e83 100644 --- a/app/src/mouse_inject.h +++ b/app/src/mouse_inject.h @@ -6,7 +6,6 @@ #include #include "controller.h" -#include "scrcpy.h" #include "screen.h" #include "trait/mouse_processor.h" diff --git a/app/src/options.h b/app/src/options.h new file mode 100644 index 00000000..04b8f6d2 --- /dev/null +++ b/app/src/options.h @@ -0,0 +1,160 @@ +#ifndef SCRCPY_OPTIONS_H +#define SCRCPY_OPTIONS_H + +#include "common.h" + +#include +#include +#include + +#include "util/tick.h" + +enum sc_log_level { + SC_LOG_LEVEL_VERBOSE, + SC_LOG_LEVEL_DEBUG, + SC_LOG_LEVEL_INFO, + SC_LOG_LEVEL_WARN, + SC_LOG_LEVEL_ERROR, +}; + +enum sc_record_format { + SC_RECORD_FORMAT_AUTO, + SC_RECORD_FORMAT_MP4, + SC_RECORD_FORMAT_MKV, +}; + +enum sc_lock_video_orientation { + SC_LOCK_VIDEO_ORIENTATION_UNLOCKED = -1, + // lock the current orientation when scrcpy starts + SC_LOCK_VIDEO_ORIENTATION_INITIAL = -2, + SC_LOCK_VIDEO_ORIENTATION_0 = 0, + SC_LOCK_VIDEO_ORIENTATION_1, + SC_LOCK_VIDEO_ORIENTATION_2, + SC_LOCK_VIDEO_ORIENTATION_3, +}; + +enum sc_keyboard_input_mode { + SC_KEYBOARD_INPUT_MODE_INJECT, + SC_KEYBOARD_INPUT_MODE_HID, +}; + +#define SC_MAX_SHORTCUT_MODS 8 + +enum sc_shortcut_mod { + SC_MOD_LCTRL = 1 << 0, + SC_MOD_RCTRL = 1 << 1, + SC_MOD_LALT = 1 << 2, + SC_MOD_RALT = 1 << 3, + SC_MOD_LSUPER = 1 << 4, + SC_MOD_RSUPER = 1 << 5, +}; + +struct sc_shortcut_mods { + unsigned data[SC_MAX_SHORTCUT_MODS]; + unsigned count; +}; + +struct sc_port_range { + uint16_t first; + uint16_t last; +}; + +#define SC_WINDOW_POSITION_UNDEFINED (-0x8000) + +struct scrcpy_options { + const char *serial; + const char *crop; + const char *record_filename; + const char *window_title; + const char *push_target; + const char *render_driver; + const char *codec_options; + const char *encoder_name; + const char *v4l2_device; + enum sc_log_level log_level; + enum sc_record_format record_format; + enum sc_keyboard_input_mode keyboard_input_mode; + struct sc_port_range port_range; + struct sc_shortcut_mods shortcut_mods; + uint16_t max_size; + uint32_t bit_rate; + uint16_t max_fps; + enum sc_lock_video_orientation lock_video_orientation; + uint8_t rotation; + int16_t window_x; // SC_WINDOW_POSITION_UNDEFINED for "auto" + int16_t window_y; // SC_WINDOW_POSITION_UNDEFINED for "auto" + uint16_t window_width; + uint16_t window_height; + uint32_t display_id; + sc_tick display_buffer; + sc_tick v4l2_buffer; + bool show_touches; + bool fullscreen; + bool always_on_top; + bool control; + bool display; + bool turn_screen_off; + bool prefer_text; + bool window_borderless; + bool mipmaps; + bool stay_awake; + bool force_adb_forward; + bool disable_screensaver; + bool forward_key_repeat; + bool forward_all_clicks; + bool legacy_paste; + bool power_off_on_close; +}; + +#define SCRCPY_OPTIONS_DEFAULT { \ + .serial = NULL, \ + .crop = NULL, \ + .record_filename = NULL, \ + .window_title = NULL, \ + .push_target = NULL, \ + .render_driver = NULL, \ + .codec_options = NULL, \ + .encoder_name = NULL, \ + .v4l2_device = NULL, \ + .log_level = SC_LOG_LEVEL_INFO, \ + .record_format = SC_RECORD_FORMAT_AUTO, \ + .keyboard_input_mode = SC_KEYBOARD_INPUT_MODE_INJECT, \ + .port_range = { \ + .first = DEFAULT_LOCAL_PORT_RANGE_FIRST, \ + .last = DEFAULT_LOCAL_PORT_RANGE_LAST, \ + }, \ + .shortcut_mods = { \ + .data = {SC_MOD_LALT, SC_MOD_LSUPER}, \ + .count = 2, \ + }, \ + .max_size = 0, \ + .bit_rate = DEFAULT_BIT_RATE, \ + .max_fps = 0, \ + .lock_video_orientation = SC_LOCK_VIDEO_ORIENTATION_UNLOCKED, \ + .rotation = 0, \ + .window_x = SC_WINDOW_POSITION_UNDEFINED, \ + .window_y = SC_WINDOW_POSITION_UNDEFINED, \ + .window_width = 0, \ + .window_height = 0, \ + .display_id = 0, \ + .display_buffer = 0, \ + .v4l2_buffer = 0, \ + .show_touches = false, \ + .fullscreen = false, \ + .always_on_top = false, \ + .control = true, \ + .display = true, \ + .turn_screen_off = false, \ + .prefer_text = false, \ + .window_borderless = false, \ + .mipmaps = true, \ + .stay_awake = false, \ + .force_adb_forward = false, \ + .disable_screensaver = false, \ + .forward_key_repeat = true, \ + .forward_all_clicks = false, \ + .legacy_paste = false, \ + .power_off_on_close = false, \ +} + +#endif diff --git a/app/src/recorder.h b/app/src/recorder.h index 96caaf5f..f14523ff 100644 --- a/app/src/recorder.h +++ b/app/src/recorder.h @@ -7,7 +7,7 @@ #include #include "coords.h" -#include "scrcpy.h" +#include "options.h" #include "trait/packet_sink.h" #include "util/queue.h" #include "util/thread.h" diff --git a/app/src/scrcpy.h b/app/src/scrcpy.h index 8cf4a917..cdcecda7 100644 --- a/app/src/scrcpy.h +++ b/app/src/scrcpy.h @@ -4,158 +4,7 @@ #include "common.h" #include -#include -#include - -#include "util/tick.h" - -enum sc_log_level { - SC_LOG_LEVEL_VERBOSE, - SC_LOG_LEVEL_DEBUG, - SC_LOG_LEVEL_INFO, - SC_LOG_LEVEL_WARN, - SC_LOG_LEVEL_ERROR, -}; - -enum sc_record_format { - SC_RECORD_FORMAT_AUTO, - SC_RECORD_FORMAT_MP4, - SC_RECORD_FORMAT_MKV, -}; - -enum sc_lock_video_orientation { - SC_LOCK_VIDEO_ORIENTATION_UNLOCKED = -1, - // lock the current orientation when scrcpy starts - SC_LOCK_VIDEO_ORIENTATION_INITIAL = -2, - SC_LOCK_VIDEO_ORIENTATION_0 = 0, - SC_LOCK_VIDEO_ORIENTATION_1, - SC_LOCK_VIDEO_ORIENTATION_2, - SC_LOCK_VIDEO_ORIENTATION_3, -}; - -enum sc_keyboard_input_mode { - SC_KEYBOARD_INPUT_MODE_INJECT, - SC_KEYBOARD_INPUT_MODE_HID, -}; - -#define SC_MAX_SHORTCUT_MODS 8 - -enum sc_shortcut_mod { - SC_MOD_LCTRL = 1 << 0, - SC_MOD_RCTRL = 1 << 1, - SC_MOD_LALT = 1 << 2, - SC_MOD_RALT = 1 << 3, - SC_MOD_LSUPER = 1 << 4, - SC_MOD_RSUPER = 1 << 5, -}; - -struct sc_shortcut_mods { - unsigned data[SC_MAX_SHORTCUT_MODS]; - unsigned count; -}; - -struct sc_port_range { - uint16_t first; - uint16_t last; -}; - -#define SC_WINDOW_POSITION_UNDEFINED (-0x8000) - -struct scrcpy_options { - const char *serial; - const char *crop; - const char *record_filename; - const char *window_title; - const char *push_target; - const char *render_driver; - const char *codec_options; - const char *encoder_name; - const char *v4l2_device; - enum sc_log_level log_level; - enum sc_record_format record_format; - enum sc_keyboard_input_mode keyboard_input_mode; - struct sc_port_range port_range; - struct sc_shortcut_mods shortcut_mods; - uint16_t max_size; - uint32_t bit_rate; - uint16_t max_fps; - enum sc_lock_video_orientation lock_video_orientation; - uint8_t rotation; - int16_t window_x; // SC_WINDOW_POSITION_UNDEFINED for "auto" - int16_t window_y; // SC_WINDOW_POSITION_UNDEFINED for "auto" - uint16_t window_width; - uint16_t window_height; - uint32_t display_id; - sc_tick display_buffer; - sc_tick v4l2_buffer; - bool show_touches; - bool fullscreen; - bool always_on_top; - bool control; - bool display; - bool turn_screen_off; - bool prefer_text; - bool window_borderless; - bool mipmaps; - bool stay_awake; - bool force_adb_forward; - bool disable_screensaver; - bool forward_key_repeat; - bool forward_all_clicks; - bool legacy_paste; - bool power_off_on_close; -}; - -#define SCRCPY_OPTIONS_DEFAULT { \ - .serial = NULL, \ - .crop = NULL, \ - .record_filename = NULL, \ - .window_title = NULL, \ - .push_target = NULL, \ - .render_driver = NULL, \ - .codec_options = NULL, \ - .encoder_name = NULL, \ - .v4l2_device = NULL, \ - .log_level = SC_LOG_LEVEL_INFO, \ - .record_format = SC_RECORD_FORMAT_AUTO, \ - .keyboard_input_mode = SC_KEYBOARD_INPUT_MODE_INJECT, \ - .port_range = { \ - .first = DEFAULT_LOCAL_PORT_RANGE_FIRST, \ - .last = DEFAULT_LOCAL_PORT_RANGE_LAST, \ - }, \ - .shortcut_mods = { \ - .data = {SC_MOD_LALT, SC_MOD_LSUPER}, \ - .count = 2, \ - }, \ - .max_size = 0, \ - .bit_rate = DEFAULT_BIT_RATE, \ - .max_fps = 0, \ - .lock_video_orientation = SC_LOCK_VIDEO_ORIENTATION_UNLOCKED, \ - .rotation = 0, \ - .window_x = SC_WINDOW_POSITION_UNDEFINED, \ - .window_y = SC_WINDOW_POSITION_UNDEFINED, \ - .window_width = 0, \ - .window_height = 0, \ - .display_id = 0, \ - .display_buffer = 0, \ - .v4l2_buffer = 0, \ - .show_touches = false, \ - .fullscreen = false, \ - .always_on_top = false, \ - .control = true, \ - .display = true, \ - .turn_screen_off = false, \ - .prefer_text = false, \ - .window_borderless = false, \ - .mipmaps = true, \ - .stay_awake = false, \ - .force_adb_forward = false, \ - .disable_screensaver = false, \ - .forward_key_repeat = true, \ - .forward_all_clicks = false, \ - .legacy_paste = false, \ - .power_off_on_close = false, \ -} +#include "options.h" bool scrcpy(struct scrcpy_options *options); diff --git a/app/src/screen.c b/app/src/screen.c index 8a2748a9..7f442143 100644 --- a/app/src/screen.c +++ b/app/src/screen.c @@ -6,7 +6,7 @@ #include "events.h" #include "icon.h" -#include "scrcpy.h" +#include "options.h" #include "video_buffer.h" #include "util/log.h" diff --git a/app/src/server.h b/app/src/server.h index 141075f7..75594522 100644 --- a/app/src/server.h +++ b/app/src/server.h @@ -9,7 +9,7 @@ #include "adb.h" #include "coords.h" -#include "scrcpy.h" +#include "options.h" #include "util/log.h" #include "util/net.h" #include "util/thread.h" diff --git a/app/src/util/log.h b/app/src/util/log.h index 30934b5c..4157d6e5 100644 --- a/app/src/util/log.h +++ b/app/src/util/log.h @@ -5,7 +5,7 @@ #include -#include "scrcpy.h" +#include "options.h" #define LOGV(...) SDL_LogVerbose(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__) #define LOGD(...) SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__) diff --git a/app/tests/test_cli.c b/app/tests/test_cli.c index 94740a9a..1682a72d 100644 --- a/app/tests/test_cli.c +++ b/app/tests/test_cli.c @@ -4,7 +4,7 @@ #include #include "cli.h" -#include "scrcpy.h" +#include "options.h" static void test_flag_version(void) { struct scrcpy_cli_args args = {