| 17 | } |
| 18 | |
| 19 | bool MacOSControlUnitMgr::connect() |
| 20 | { |
| 21 | connected_ = false; |
| 22 | |
| 23 | switch (screencap_method_) { |
| 24 | case MaaMacOSScreencapMethod_ScreenCaptureKit: |
| 25 | // 检查macOS版本 |
| 26 | if (__builtin_available(macOS 14.0, *)) { |
| 27 | screencap_ = std::make_shared<ScreenCaptureKitScreencap>(window_id_); |
| 28 | } |
| 29 | else { |
| 30 | LogError << "macOS 14.0 or later required for ScreenCaptureKit"; |
| 31 | return false; |
| 32 | } |
| 33 | break; |
| 34 | case MaaMacOSScreencapMethod_None: |
| 35 | LogWarn << "No screencap method specified, screencap will not work"; |
| 36 | break; |
| 37 | default: |
| 38 | LogError << "Unknown screencap method: " << static_cast<int>(screencap_method_); |
| 39 | break; |
| 40 | } |
| 41 | |
| 42 | switch (input_method_) { |
| 43 | case MaaMacOSInputMethod_GlobalEvent: |
| 44 | input_ = std::make_shared<GlobalEventInput>(window_id_); |
| 45 | break; |
| 46 | case MaaMacOSInputMethod_PostToPid: |
| 47 | input_ = std::make_shared<PostToPidInput>(window_id_); |
| 48 | break; |
| 49 | case MaaMacOSInputMethod_None: |
| 50 | LogWarn << "No input method specified, input will not work"; |
| 51 | break; |
| 52 | default: |
| 53 | LogError << "Unknown input method: " << static_cast<int>(input_method_); |
| 54 | break; |
| 55 | } |
| 56 | |
| 57 | connected_ = true; |
| 58 | return true; |
| 59 | } |
| 60 | |
| 61 | bool MacOSControlUnitMgr::connected() const |
| 62 | { |
nothing calls this directly
no outgoing calls
no test coverage detected