Skip to content

Commit

Permalink
fix: 修复雷电非0实例截图错误
Browse files Browse the repository at this point in the history
  • Loading branch information
MistEO committed Nov 8, 2024
1 parent 6231baf commit b061348
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
20 changes: 19 additions & 1 deletion source/MaaToolkit/AdbDevice/AdbDeviceWin32Finder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ json::object AdbDeviceWin32Finder::get_adb_config(const Emulator& emulator, cons

ld_cfg["enable"] = true;
ld_cfg["path"] = path_to_utf8_string(dir);
ld_cfg["index"] = 0;
ld_cfg["index"] = get_ld_index(adb_serial);
ld_cfg["pid"] = emulator.process.pid;

LogInfo << "LDPlayer cfg" << VAR(adb_serial) << cfg;
Expand Down Expand Up @@ -112,6 +112,24 @@ int AdbDeviceWin32Finder::get_mumu_index(const std::string& adb_serial)
return index;
}

int AdbDeviceWin32Finder::get_ld_index(const std::string& adb_serial)
{
auto sp = string_split(adb_serial, '-');
if (sp.size() != 2) {
return 0;
}

auto& str_port = sp.at(1);
if (str_port.empty() || !std::ranges::all_of(str_port, [](auto c) { return std::isdigit(c); })) {
return 0;
}

int port = std::stoi(str_port);
int index = (port - 5554) / 2;

return index;
}

MAA_TOOLKIT_NS_END

#endif
1 change: 1 addition & 0 deletions source/MaaToolkit/AdbDevice/AdbDeviceWin32Finder.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class AdbDeviceWin32Finder
AdbDeviceWin32Finder();

static int get_mumu_index(const std::string& adb_serial);
static int get_ld_index(const std::string& adb_serial);
};

MAA_TOOLKIT_NS_END
Expand Down

0 comments on commit b061348

Please sign in to comment.