| 223 | } |
| 224 | |
| 225 | MaaBool CustomScreencap(void* trans_arg, MaaImageBuffer* buffer) |
| 226 | { |
| 227 | auto customCtx = reinterpret_cast<CustomControllerContext*>(trans_arg); |
| 228 | auto ctx = customCtx->callbacks["screencap"]; |
| 229 | return ctx->Call<bool>( |
| 230 | [&](maajs::FunctionType func) { return func.Call({ }); }, |
| 231 | [buffer](maajs::ValueType result) { |
| 232 | try { |
| 233 | auto data = maajs::JSConvert<std::optional<maajs::ArrayBufferType>>::from_value(result); |
| 234 | if (data) { |
| 235 | ImageBuffer(buffer, false).set(*data); |
| 236 | return true; |
| 237 | } |
| 238 | else { |
| 239 | return false; |
| 240 | } |
| 241 | } |
| 242 | catch (const maajs::MaaError& err) { |
| 243 | std::cerr << err.what() << std::endl; |
| 244 | return false; |
| 245 | } |
| 246 | }); |
| 247 | } |
| 248 | |
| 249 | MaaBool CustomClick(int32_t x, int32_t y, void* trans_arg) |
| 250 | { |
nothing calls this directly
no test coverage detected