Skip to content

Commit

Permalink
Merge branch 'main' into restful
Browse files Browse the repository at this point in the history
  • Loading branch information
neko-para committed Nov 11, 2023
2 parents 7f33898 + c8a5369 commit a5e1ff7
Show file tree
Hide file tree
Showing 132 changed files with 2,351 additions and 2,362 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ jobs:
with:
submodules: true

# Download host arch tools for Thrift of CustomThriftController
# Download host arch tools for Thrift of ThriftControlUnit
- name: Download host tools from MaaDeps
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -161,7 +161,7 @@ jobs:
with:
remove_stale_cache: false

# Download host arch tools for Thrift of CustomThriftController
# Download host arch tools for Thrift of ThriftControlUnit
- name: Download host tools from MaaDeps
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -230,7 +230,7 @@ jobs:
brew install llvm
# 16

# Download host arch tools for Thrift of CustomThriftController
# Download host arch tools for Thrift of ThriftControlUnit
- name: Download host tools from MaaDeps
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
14 changes: 3 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -434,16 +434,8 @@ FodyWeavers.xsd
.idea/
*.sln.iml

enc_temp_folder/*

# Nuke
# chore
.DS_Store
.nuke/temp/*

# test install dir
enc_temp_folder/*
install

.DS_Store

source/MaaRpc/generated/*.h
source/MaaRpc/generated/*.cc
source/MaaRpc/generated/*.timestamp
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.24)
project(MAA)
project(MaaFw)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/modules")

Expand All @@ -9,13 +9,16 @@ set(CMAKE_MAP_IMPORTED_CONFIG_DebWithRelDeps "DebWithRelDeps;Release;")
set(Boost_NO_WARN_NEW_VERSIONS 1)

option(USE_MAADEPS "use third-party libraries built by MaaDeps" ON)

option(WITH_ADB_CONTROLLER "build with adb controller" ON)
option(WITH_THRIFT_CONTROLLER "build with thrift controller" ON)
option(WITH_DBG_CONTROLLER "build with debugging controller" ON)
option(WITH_GRPC "build with protobuf and grpc" ON)
option(WITH_RESTFUL "build with beast for restful server" ON)
option(BUILD_GRPC_CLI "build grpc CLI exec" ON)
option(WITH_RESTFUL "build with beast for restful server" ON)

option(BUILD_SAMPLE "build a demo" OFF)

option(BUILD_PIPELINE_TESTING "build pipeline testing" OFF)
option(BUILD_GRPC_TESTING "build grpc testing" OFF)

Expand Down
2 changes: 2 additions & 0 deletions cmake/grpc-gen.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ macro(GENERATE_GRPC_LIB LIB_NAME IN_DIR OUT_DIR GEN_SRCS)
set(${LIB_NAME}_INCLUDE_DIRS ${OUT_DIR})
set(${GEN_SRCS} ${SRCS})

set_target_properties(${LIB_NAME} PROPERTIES FOLDER "Generated")

source_group("generated" FILES ${SRCS})
source_group("proto" FILES ${PROTOS})
endmacro()
4 changes: 3 additions & 1 deletion cmake/thrift-gen.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ macro(GENERATE_THRIFT_LIB LIB_NAME FILENAME OUTPUTDIR SOURCES)
if(CMD_RESULT)
message(FATAL_ERROR "Error generating ${FILENAME} with generator ${GENERATOR}")
endif()
file(GLOB_RECURSE GENERATED_SOURCES ${OUTPUTDIR}/*)
file(GLOB_RECURSE GENERATED_SOURCES ${OUTPUTDIR}/*.cpp ${OUTPUTDIR}/*.h ${OUTPUTDIR}/*.hpp)
add_library(${LIB_NAME} STATIC ${GENERATED_SOURCES} ${FILENAME})
set_target_properties(${LIB_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_link_libraries(${LIB_NAME} thrift::thrift)
set(${LIB_NAME}_INCLUDE_DIRS
${OUTPUTDIR}
PARENT_SCOPE)
set(${SOURCES} ${GENERATED_SOURCES})

set_target_properties(${LIB_NAME} PROPERTIES FOLDER "Generated")

source_group("generated" FILES ${GENERATED_SOURCES})
source_group("thrift" FILES ${FILENAME})
Expand Down
23 changes: 10 additions & 13 deletions include/Interface/ThriftController.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,20 @@ struct Size {
}

struct CustomImage {
1: Size size,
2: i32 type,
3: binary data,
1: binary png_data,
}

service ThriftController {
bool set_option(1: string key, 2: string value),

bool connect(),

string request_uuid(),
Size request_resolution(),

bool start_app(1: string entry),
bool stop_app(1: string entry),

CustomImage screencap(),

bool click(1: ClickParam param),
bool swipe(1: SwipeParam param),

Expand All @@ -48,12 +53,4 @@ service ThriftController {
bool touch_up(1: TouchParam param),

bool press_key(1: PressKeyParam param),

bool start_game(1: string activity),
bool stop_game(1: string activity),

Size get_resolution(),

string get_uuid(),
CustomImage screencap(),
}
27 changes: 13 additions & 14 deletions include/Interface/proto/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ message CustomControllerRequest {
oneof result {
string init = 101;

Size resolution = 201;
string uuid = 202;
string uuid = 201;
Size resolution = 202;
}
}

Expand All @@ -142,18 +142,17 @@ message CustomControllerResponse {
string init = 101; // handle

bool connect = 201; // void
ClickParam click = 202;
SwipeParam swipe = 203;
KeyParam key = 204;
TouchParam touch_down = 205;
TouchParam touch_move = 206;
TouchParam touch_up = 207;
string start = 208;
string stop = 209;
bool resolution = 210; // void
string image = 211;
bool uuid = 212; // void
CustomControllerSetOptionParam set_option = 213;
bool request_uuid = 202; // void
bool request_resolution = 203; // void
string start_app = 301;
string stop_app = 302;
string screencap = 401;
ClickParam click = 501;
SwipeParam swipe = 502;
TouchParam touch_down = 601;
TouchParam touch_move = 602;
TouchParam touch_up = 603;
KeyParam press_key = 701;
}
}

Expand Down
29 changes: 16 additions & 13 deletions include/MaaFramework/Instance/MaaController.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,24 @@ extern "C"
{
#endif

/* Deprecated, please use MaaAdbControllerCreateV2 */ MaaControllerHandle MAA_FRAMEWORK_API MaaAdbControllerCreate(
// Deprecated, please use MaaAdbControllerCreateV2
MaaControllerHandle MAA_FRAMEWORK_API MaaAdbControllerCreate( //
MaaStringView adb_path, MaaStringView address, MaaAdbControllerType type, MaaStringView config,
MaaControllerCallback callback, MaaCallbackTransparentArg callback_arg);
MaaControllerHandle MAA_FRAMEWORK_API MaaAdbControllerCreateV2(MaaStringView adb_path, MaaStringView address,
MaaAdbControllerType type, MaaStringView config,
MaaStringView agent_path,
MaaControllerCallback callback,
MaaCallbackTransparentArg callback_arg);
MaaControllerHandle MAA_FRAMEWORK_API MaaCustomControllerCreate(MaaCustomControllerHandle handle,
MaaTransparentArg handle_arg,
MaaControllerCallback callback,
MaaCallbackTransparentArg callback_arg);
MaaControllerHandle MAA_FRAMEWORK_API MaaThriftControllerCreate(MaaStringView param, MaaControllerCallback callback,
MaaCallbackTransparentArg callback_arg);
MaaControllerHandle MAA_FRAMEWORK_API MaaDbgControllerCreate(

MaaControllerHandle MAA_FRAMEWORK_API MaaAdbControllerCreateV2( //
MaaStringView adb_path, MaaStringView address, MaaAdbControllerType type, MaaStringView config,
MaaStringView agent_path, MaaControllerCallback callback, MaaCallbackTransparentArg callback_arg);

MaaControllerHandle MAA_FRAMEWORK_API MaaCustomControllerCreate( //
MaaCustomControllerHandle handle, MaaTransparentArg handle_arg, MaaControllerCallback callback,
MaaCallbackTransparentArg callback_arg);

MaaControllerHandle MAA_FRAMEWORK_API MaaThriftControllerCreate( //
MaaThriftControllerType type, MaaStringView host, int32_t port, MaaStringView config,
MaaControllerCallback callback, MaaCallbackTransparentArg callback_arg);

MaaControllerHandle MAA_FRAMEWORK_API MaaDbgControllerCreate( //
MaaStringView read_path, MaaStringView write_path, MaaDbgControllerType type, MaaStringView config,
MaaControllerCallback callback, MaaCallbackTransparentArg callback_arg);

Expand Down
23 changes: 11 additions & 12 deletions include/MaaFramework/Instance/MaaCustomController.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,25 @@ extern "C"

struct MaaCustomControllerAPI
{
MaaBool (*set_option)(MaaCtrlOption key, MaaStringView value, MaaTransparentArg handle_arg);

MaaBool (*connect)(MaaTransparentArg handle_arg);

MaaBool (*request_uuid)(MaaTransparentArg handle_arg, /* out */ MaaStringBufferHandle buffer);
MaaBool (*request_resolution)(MaaTransparentArg handle_arg, /* out */ int32_t* width,
/* out */ int32_t* height);

MaaBool (*start_app)(MaaStringView intent, MaaTransparentArg handle_arg);
MaaBool (*stop_app)(MaaStringView intent, MaaTransparentArg handle_arg);

MaaBool (*screencap)(MaaTransparentArg handle_arg, /* out */ MaaImageBufferHandle buffer);

MaaBool (*click)(int32_t x, int32_t y, MaaTransparentArg handle_arg);
MaaBool (*swipe)(int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t duration,
MaaTransparentArg handle_arg);
MaaBool (*press_key)(int32_t keycode, MaaTransparentArg handle_arg);

MaaBool (*touch_down)(int32_t contact, int32_t x, int32_t y, int32_t pressure, MaaTransparentArg handle_arg);
MaaBool (*touch_move)(int32_t contact, int32_t x, int32_t y, int32_t pressure, MaaTransparentArg handle_arg);
MaaBool (*touch_up)(int32_t contact, MaaTransparentArg handle_arg);

MaaBool (*start_app)(MaaStringView package_name, MaaTransparentArg handle_arg);
MaaBool (*stop_app)(MaaStringView package_name, MaaTransparentArg handle_arg);

MaaBool (*get_resolution)(MaaTransparentArg handle_arg, /* out */ int32_t* width,
/* out */ int32_t* height);

MaaBool (*get_image)(MaaTransparentArg handle_arg, /* out */ MaaImageBufferHandle buffer);
MaaBool (*get_uuid)(MaaTransparentArg handle_arg, /* out */ MaaStringBufferHandle buffer);
MaaBool (*press_key)(int32_t keycode, MaaTransparentArg handle_arg);
};

#ifdef __cplusplus
Expand Down
9 changes: 9 additions & 0 deletions include/MaaFramework/MaaDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,15 @@ enum MaaDbgControllerTypeEnum
MaaDbgControllerType_ReplayRecording = 2,
};

typedef int32_t MaaThriftControllerType;
enum MaaThriftControllerTypeEnum
{
MaaThriftController_Invalid = 0,

MaaThriftControllerType_Socket = 1,
MaaThriftControllerType_UnixDomainSocket = 2,
};

typedef void* MaaTransparentArg;
typedef MaaTransparentArg MaaCallbackTransparentArg;

Expand Down
2 changes: 2 additions & 0 deletions include/MaaToolKit/Device/MaaToolKitDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ extern "C"
{
#endif

/* For AdbController */

MaaSize MAA_TOOLKIT_API MaaToolKitFindDevice();
MaaSize MAA_TOOLKIT_API MaaToolKitFindDeviceWithAdb(MaaStringView adb_path);
MaaStringView MAA_TOOLKIT_API MaaToolKitGetDeviceName(MaaSize index);
Expand Down
2 changes: 1 addition & 1 deletion source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ if(WITH_ADB_CONTROLLER)
add_subdirectory(MaaAdbControlUnit)
endif(WITH_ADB_CONTROLLER)
if(WITH_THRIFT_CONTROLLER AND NOT MAA_CROSSCOMPILE)
add_subdirectory(MaaThriftController)
add_subdirectory(MaaThriftControlUnit)
endif(WITH_THRIFT_CONTROLLER AND NOT MAA_CROSSCOMPILE)
if(WITH_DBG_CONTROLLER)
add_subdirectory(MaaDbgControlUnit)
Expand Down
Loading

0 comments on commit a5e1ff7

Please sign in to comment.