MCPcopy Create free account
hub / github.com/MaaXYZ/MaaFramework / CustomScreencap

Function CustomScreencap

source/binding/NodeJS/src/apis/callback.cpp:225–247  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

223}
224
225MaaBool 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
249MaaBool CustomClick(int32_t x, int32_t y, void* trans_arg)
250{

Callers

nothing calls this directly

Calls 4

whatMethod · 0.80
ImageBufferClass · 0.70
CallMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected