@@ -113,7 +113,8 @@ std::shared_ptr<DeviceListAPI> create_adb_device_list_obj(MaaStringView adb_path
113
113
}
114
114
115
115
std::shared_ptr<ControlUnitAPI> create_adb_controller_unit (MaaStringView adb_path, MaaStringView adb_serial,
116
- MaaAdbControllerType type, MaaStringView config)
116
+ MaaAdbControllerType type, MaaStringView agent_path,
117
+ MaaStringView config)
117
118
{
118
119
LogFunc << VAR (adb_path) << VAR (adb_serial) << VAR (type) << VAR (config);
119
120
@@ -127,19 +128,32 @@ std::shared_ptr<ControlUnitAPI> create_adb_controller_unit(MaaStringView adb_pat
127
128
128
129
std::shared_ptr<MaatouchInput> maatouch_unit = nullptr ;
129
130
131
+ auto agent_stdpath = MAA_NS::path (agent_path);
132
+ auto minitouch_path = agent_stdpath / MAA_NS::path (" minitouch" );
133
+ auto maatouch_path = agent_stdpath / MAA_NS::path (" maatouch" );
134
+ auto minicap_path = agent_stdpath / MAA_NS::path (" minicap" );
135
+
130
136
switch (touch_type) {
131
137
case MaaAdbControllerType_Touch_Adb:
132
138
LogInfo << " touch_type: TapTouchInput" ;
133
139
touch_unit = std::make_shared<TapTouchInput>();
134
140
break ;
135
141
case MaaAdbControllerType_Touch_MiniTouch:
136
142
LogInfo << " touch_type: MinitouchInput" ;
137
- touch_unit = std::make_shared<MinitouchInput>();
143
+ if (!std::filesystem::exists (minitouch_path)) {
144
+ LogError << " minitouch path not exists" << VAR (minitouch_path);
145
+ return nullptr ;
146
+ }
147
+ touch_unit = std::make_shared<MinitouchInput>(minitouch_path);
138
148
break ;
139
149
case MaaAdbControllerType_Touch_MaaTouch:
140
150
LogInfo << " touch_type: MaatouchInput" ;
151
+ if (!std::filesystem::exists (maatouch_path)) {
152
+ LogError << " maatouch path not exists" << VAR (maatouch_path);
153
+ return nullptr ;
154
+ }
141
155
if (!maatouch_unit) {
142
- maatouch_unit = std::make_shared<MaatouchInput>();
156
+ maatouch_unit = std::make_shared<MaatouchInput>(maatouch_path );
143
157
}
144
158
touch_unit = maatouch_unit;
145
159
break ;
@@ -155,8 +169,12 @@ std::shared_ptr<ControlUnitAPI> create_adb_controller_unit(MaaStringView adb_pat
155
169
break ;
156
170
case MaaAdbControllerType_Key_MaaTouch:
157
171
LogInfo << " key_type: MaatouchInput" ;
172
+ if (!std::filesystem::exists (maatouch_path)) {
173
+ LogError << " maatouch path not exists" << VAR (maatouch_path);
174
+ return nullptr ;
175
+ }
158
176
if (!maatouch_unit) {
159
- maatouch_unit = std::make_shared<MaatouchInput>();
177
+ maatouch_unit = std::make_shared<MaatouchInput>(maatouch_path );
160
178
}
161
179
key_unit = maatouch_unit;
162
180
break ;
@@ -168,7 +186,11 @@ std::shared_ptr<ControlUnitAPI> create_adb_controller_unit(MaaStringView adb_pat
168
186
switch (screencap_type) {
169
187
case MaaAdbControllerType_Screencap_FastestWay:
170
188
LogInfo << " screencap_type: ScreencapFastestWay" ;
171
- screencap_unit = std::make_shared<ScreencapFastestWay>();
189
+ if (!std::filesystem::exists (minicap_path)) {
190
+ LogError << " minicap path not exists" << VAR (minicap_path);
191
+ return nullptr ;
192
+ }
193
+ screencap_unit = std::make_shared<ScreencapFastestWay>(minicap_path);
172
194
break ;
173
195
case MaaAdbControllerType_Screencap_RawByNetcat:
174
196
LogInfo << " screencap_type: ScreencapRawByNetcat" ;
@@ -188,11 +210,19 @@ std::shared_ptr<ControlUnitAPI> create_adb_controller_unit(MaaStringView adb_pat
188
210
break ;
189
211
case MaaAdbControllerType_Screencap_MinicapDirect:
190
212
LogInfo << " screencap_type: MinicapDirect" ;
191
- screencap_unit = std::make_shared<MinicapDirect>();
213
+ if (!std::filesystem::exists (minicap_path)) {
214
+ LogError << " minicap path not exists" << VAR (minicap_path);
215
+ return nullptr ;
216
+ }
217
+ screencap_unit = std::make_shared<MinicapDirect>(minicap_path);
192
218
break ;
193
219
case MaaAdbControllerType_Screencap_MinicapStream:
194
220
LogInfo << " screencap_type: MinicapStream" ;
195
- screencap_unit = std::make_shared<MinicapStream>();
221
+ if (!std::filesystem::exists (minicap_path)) {
222
+ LogError << " minicap path not exists" << VAR (minicap_path);
223
+ return nullptr ;
224
+ }
225
+ screencap_unit = std::make_shared<MinicapStream>(minicap_path);
196
226
break ;
197
227
default :
198
228
LogError << " Unknown screencap type" << VAR (screencap_type);
@@ -334,14 +364,19 @@ std::shared_ptr<ActivityAPI> create_adb_activity(MaaStringView adb_path, MaaStri
334
364
}
335
365
336
366
std::shared_ptr<TouchInputAPI> create_adb_touch_input (MaaStringView adb_path, MaaStringView adb_serial,
337
- MaaAdbControllerType type, MaaStringView config)
367
+ MaaAdbControllerType type, MaaStringView agent_path,
368
+ MaaStringView config)
338
369
{
339
370
auto json_opt = json::parse (std::string_view (config));
340
371
if (!json_opt) {
341
372
LogError << " Parse config failed, invalid config:" << config;
342
373
return nullptr ;
343
374
}
344
375
376
+ auto agent_stdpath = MAA_NS::path (agent_path);
377
+ auto minitouch_path = agent_stdpath / MAA_NS::path (" minitouch" );
378
+ auto maatouch_path = agent_stdpath / MAA_NS::path (" maatouch" );
379
+
345
380
std::shared_ptr<TouchInputBase> touch_unit = nullptr ;
346
381
switch (type & MaaAdbControllerType_Touch_Mask) {
347
382
case MaaAdbControllerType_Touch_Adb:
@@ -350,11 +385,19 @@ std::shared_ptr<TouchInputAPI> create_adb_touch_input(MaaStringView adb_path, Ma
350
385
break ;
351
386
case MaaAdbControllerType_Touch_MiniTouch:
352
387
LogInfo << " touch_type: MinitouchInput" ;
353
- touch_unit = std::make_shared<MinitouchInput>();
388
+ if (!std::filesystem::exists (minitouch_path)) {
389
+ LogError << " minitouch path not exists" << VAR (minitouch_path);
390
+ return nullptr ;
391
+ }
392
+ touch_unit = std::make_shared<MinitouchInput>(minitouch_path);
354
393
break ;
355
394
case MaaAdbControllerType_Touch_MaaTouch:
356
395
LogInfo << " touch_type: MaatouchInput" ;
357
- touch_unit = std::make_shared<MaatouchInput>();
396
+ if (!std::filesystem::exists (maatouch_path)) {
397
+ LogError << " maatouch path not exists" << VAR (maatouch_path);
398
+ return nullptr ;
399
+ }
400
+ touch_unit = std::make_shared<MaatouchInput>(maatouch_path);
358
401
break ;
359
402
default :
360
403
LogError << " Unknown touch input type" << VAR (type);
@@ -382,13 +425,16 @@ std::shared_ptr<TouchInputAPI> create_adb_touch_input(MaaStringView adb_path, Ma
382
425
}
383
426
384
427
std::shared_ptr<KeyInputAPI> create_adb_key_input (MaaStringView adb_path, MaaStringView adb_serial,
385
- MaaAdbControllerType type, MaaStringView config)
428
+ MaaAdbControllerType type, MaaStringView agent_path,
429
+ MaaStringView config)
386
430
{
387
431
auto json_opt = json::parse (std::string_view (config));
388
432
if (!json_opt) {
389
433
LogError << " Parse config failed, invalid config:" << config;
390
434
return nullptr ;
391
435
}
436
+ auto agent_stdpath = MAA_NS::path (agent_path);
437
+ auto maatouch_path = agent_stdpath / MAA_NS::path (" maatouch" );
392
438
393
439
std::shared_ptr<KeyInputBase> key_unit = nullptr ;
394
440
switch (type & MaaAdbControllerType_Key_Mask) {
@@ -398,7 +444,11 @@ std::shared_ptr<KeyInputAPI> create_adb_key_input(MaaStringView adb_path, MaaStr
398
444
break ;
399
445
case MaaAdbControllerType_Key_MaaTouch:
400
446
LogInfo << " key_type: MaatouchInput" ;
401
- key_unit = std::make_shared<MaatouchInput>();
447
+ if (!std::filesystem::exists (maatouch_path)) {
448
+ LogError << " maatouch path not exists" << VAR (maatouch_path);
449
+ return nullptr ;
450
+ }
451
+ key_unit = std::make_shared<MaatouchInput>(maatouch_path);
402
452
break ;
403
453
default :
404
454
LogError << " Unknown key input type" << VAR (type);
@@ -426,19 +476,27 @@ std::shared_ptr<KeyInputAPI> create_adb_key_input(MaaStringView adb_path, MaaStr
426
476
}
427
477
428
478
std::shared_ptr<ScreencapAPI> create_adb_screencap (MaaStringView adb_path, MaaStringView adb_serial,
429
- MaaAdbControllerType type, MaaStringView config)
479
+ MaaAdbControllerType type, MaaStringView agent_path,
480
+ MaaStringView config)
430
481
{
431
482
auto json_opt = json::parse (std::string_view (config));
432
483
if (!json_opt) {
433
484
LogError << " Parse config failed, invalid config:" << config;
434
485
return nullptr ;
435
486
}
436
487
488
+ auto agent_stdpath = MAA_NS::path (agent_path);
489
+ auto minicap_path = agent_stdpath / MAA_NS::path (" minicap" );
490
+
437
491
std::shared_ptr<ScreencapBase> screencap_unit = nullptr ;
438
492
switch (type & MaaAdbControllerType_Screencap_Mask) {
439
493
case MaaAdbControllerType_Screencap_FastestWay:
440
494
LogInfo << " screencap_type: ScreencapFastestWay" ;
441
- screencap_unit = std::make_shared<ScreencapFastestWay>();
495
+ if (!std::filesystem::exists (minicap_path)) {
496
+ LogError << " minicap path not exists" << VAR (minicap_path);
497
+ return nullptr ;
498
+ }
499
+ screencap_unit = std::make_shared<ScreencapFastestWay>(minicap_path);
442
500
break ;
443
501
case MaaAdbControllerType_Screencap_RawByNetcat:
444
502
LogInfo << " screencap_type: ScreencapRawByNetcat" ;
@@ -458,11 +516,19 @@ std::shared_ptr<ScreencapAPI> create_adb_screencap(MaaStringView adb_path, MaaSt
458
516
break ;
459
517
case MaaAdbControllerType_Screencap_MinicapDirect:
460
518
LogInfo << " screencap_type: MinicapDirect" ;
461
- screencap_unit = std::make_shared<MinicapDirect>();
519
+ if (!std::filesystem::exists (minicap_path)) {
520
+ LogError << " minicap path not exists" << VAR (minicap_path);
521
+ return nullptr ;
522
+ }
523
+ screencap_unit = std::make_shared<MinicapDirect>(minicap_path);
462
524
break ;
463
525
case MaaAdbControllerType_Screencap_MinicapStream:
464
526
LogInfo << " screencap_type: MinicapStream" ;
465
- screencap_unit = std::make_shared<MinicapStream>();
527
+ if (!std::filesystem::exists (minicap_path)) {
528
+ LogError << " minicap path not exists" << VAR (minicap_path);
529
+ return nullptr ;
530
+ }
531
+ screencap_unit = std::make_shared<MinicapStream>(minicap_path);
466
532
break ;
467
533
default :
468
534
LogError << " Unknown screencap type" << VAR (type);
0 commit comments