-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
410 additions
and
386 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include "control.h" | ||
|
||
bool default_control_init(ControlConfig& control) | ||
{ | ||
int server = 0; | ||
if (!select_server(server)) { | ||
return false; | ||
} | ||
control.set_config_server(server); | ||
return true; | ||
} | ||
|
||
bool select_server(int& server) | ||
{ | ||
std::cout << std::endl | ||
<< "Please select server number: " << std::endl | ||
<< std::endl | ||
<< " 1. Official(CN)\n" | ||
" 2. Bilibili\n" | ||
" 3. Vivo\n" | ||
<< std::endl | ||
<< "Please enter the server number: " << std::endl; | ||
|
||
std::cin >> server; | ||
|
||
if (server < 1 || server > 3) { | ||
std::cout << "Unknown server number: " << server << std::endl; | ||
return false; | ||
} | ||
|
||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#pragma once | ||
|
||
#include "Config/ControlConfig.h" | ||
|
||
bool default_control_init(ControlConfig& control); | ||
|
||
bool select_server(int& server); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
#include "device.h" | ||
|
||
bool default_device_init(DeviceConfig& device) | ||
{ | ||
std::string name, SN, adb; | ||
if (!select_device(name, SN, adb)) { | ||
return false; | ||
} | ||
device.set_config_device_name(name); | ||
device.set_config_device_SN(SN); | ||
device.set_config_adb(adb); | ||
return true; | ||
} | ||
|
||
MaaSize scanning_devices() | ||
{ | ||
std::cout << "Scanning for Devices..." << std::endl; | ||
auto device_size = MaaToolKitFindDevice(); | ||
if (device_size == 0) { | ||
std::cout << "No Devices Found" << std::endl; | ||
return 0; | ||
} | ||
std::cout << "Scanning Finished" << std::endl; | ||
return device_size; | ||
} | ||
|
||
bool select_device(std::string& name, std::string& SN, std::string& adb) | ||
{ | ||
auto device_size = scanning_devices(); | ||
if (!device_size) { | ||
if (!manually_enter_device_info(name, SN, adb)) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
MaaSize number = 0; | ||
if (!select_device_number(device_size, number)) { | ||
return false; | ||
} | ||
if (!number) { | ||
if (!manually_enter_device_info(name, SN, adb)) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
MaaSize device_index = number - 1; | ||
name = MaaToolKitGetDeviceName(device_index); | ||
SN = MaaToolKitGetDeviceAdbSerial(device_index); | ||
adb = MaaToolKitGetDeviceAdbPath(device_index); | ||
AdbConfigCache adb_config_cache; | ||
if (!adb_config_cache.has(name, SN)) { | ||
adb_config_cache.set_adb_config(name, SN, MaaToolKitGetDeviceAdbConfig(device_index)); | ||
} | ||
return true; | ||
} | ||
|
||
bool select_device_number(const MaaSize& device_size, MaaSize& number) | ||
{ | ||
std::cout << std::endl << "Please select a device:" << std::endl << std::endl; | ||
std::cout << " 0. Manual" << std::endl; | ||
print_device_list(device_size); | ||
std::cout << std::endl << "Please enter option number:" << std::endl; | ||
|
||
std::cin >> number; | ||
std::cin.ignore(); | ||
|
||
if (number > device_size) { | ||
std::cout << std::endl << "Unknown option number: " << number << std::endl; | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
void print_device_list(const MaaSize& device_size) | ||
{ | ||
for (MaaSize i = 0; i < device_size; i++) { | ||
std::cout << " " << i + 1 << ". " << MaaToolKitGetDeviceName(i) << " (" << MaaToolKitGetDeviceAdbSerial(i) | ||
<< ")\n"; | ||
} | ||
} | ||
|
||
bool manually_enter_device_info(std::string& name, std::string& SN, std::string& adb) | ||
{ | ||
if (!manually_enter_device_name(name)) { | ||
return false; | ||
} | ||
if (!manually_enter_device_SN(SN)) { | ||
return false; | ||
} | ||
if (!manually_enter_device_adb(adb)) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
bool manually_enter_device_name(std::string& name) | ||
{ | ||
std::cout << std::endl << "Please enter device name: " << std::endl; | ||
std::getline(std::cin, name); | ||
if (name.empty()) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
bool manually_enter_device_SN(std::string& SN) | ||
{ | ||
std::cout << std::endl << "Please enter device serial number: " << std::endl; | ||
std::getline(std::cin, SN); | ||
if (SN.empty()) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
bool manually_enter_device_adb(std::string& adb) | ||
{ | ||
std::cout << std::endl << "Please enter adb path: " << std::endl; | ||
std::getline(std::cin, adb); | ||
if (adb.empty()) { | ||
return false; | ||
} | ||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#pragma once | ||
|
||
#include <MaaToolKit/MaaToolKitAPI.h> | ||
#include <MaaFramework/MaaDef.h> | ||
|
||
#include "Config/DeviceConfig.h" | ||
#include "Cache/AdbConfigCache.h" | ||
|
||
bool default_device_init(DeviceConfig& device); | ||
|
||
MaaSize scanning_devices(); | ||
|
||
bool select_device(std::string& name, std::string& SN, std::string& adb); | ||
|
||
bool select_device_number(const MaaSize& device_size, MaaSize& number); | ||
|
||
void print_device_list(const MaaSize& device_size); | ||
|
||
bool manually_enter_device_info(std::string& name, std::string& SN, std::string& adb); | ||
|
||
bool manually_enter_device_name(std::string& name); | ||
|
||
bool manually_enter_device_SN(std::string& SN); | ||
|
||
bool manually_enter_device_adb(std::string& adb); |
Oops, something went wrong.