native

package
v4.0.0-beta.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 13, 2026 License: LGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// I don't recommend setting up MaaResOption_InferenceDevice in this case,
	// because you don't know which EP will be used on different user devices.
	MaaInferenceExecutionProvider_Auto = 0

	// MaaResOption_InferenceDevice will not work.
	MaaInferenceExecutionProvider_CPU = 1

	// MaaResOption_InferenceDevice will be used to set adapter id,
	// It's from Win32 API `EnumAdapters1`.
	MaaInferenceExecutionProvider_DirectML = 2

	// MaaResOption_InferenceDevice will be used to set coreml_flag,
	// Reference to
	// https://github.com/microsoft/onnxruntime/blob/main/include/onnxruntime/core/providers/coreml/coreml_provider_factory.h
	// But you need to pay attention to the onnxruntime version we use, the latest flag may not be supported.
	MaaInferenceExecutionProvider_CoreML = 3

	// MaaResOption_InferenceDevice will be used to set NVIDIA GPU ID
	// TODO!
	MaaInferenceExecutionProvider_CUDA = 4
)

Variables

View Source
var (
	MaaAgentClientCreateV2                 func(identifier uintptr) uintptr
	MaaAgentClientCreateTcp                func(port uint16) uintptr
	MaaAgentClientDestroy                  func(client uintptr)
	MaaAgentClientIdentifier               func(client uintptr, identifier uintptr) bool
	MaaAgentClientBindResource             func(client uintptr, res uintptr) bool
	MaaAgentClientRegisterResourceSink     func(client uintptr, res uintptr) bool
	MaaAgentClientRegisterControllerSink   func(client uintptr, ctrl uintptr) bool
	MaaAgentClientRegisterTaskerSink       func(client uintptr, tasker uintptr) bool
	MaaAgentClientConnect                  func(client uintptr) bool
	MaaAgentClientDisconnect               func(client uintptr) bool
	MaaAgentClientConnected                func(client uintptr) bool
	MaaAgentClientAlive                    func(client uintptr) bool
	MaaAgentClientSetTimeout               func(client uintptr, milliseconds int64) bool
	MaaAgentClientGetCustomRecognitionList func(client uintptr, buffer uintptr) bool
	MaaAgentClientGetCustomActionList      func(client uintptr, buffer uintptr) bool
)
View Source
var (
	MaaAgentServerRegisterCustomRecognition func(name string, recognition MaaCustomRecognitionCallback, transArg unsafe.Pointer) bool
	MaaAgentServerRegisterCustomAction      func(name string, action MaaCustomActionCallback, transArg unsafe.Pointer) bool
	MaaAgentServerAddResourceSink           func(sink MaaEventCallback, transArg unsafe.Pointer) int64
	MaaAgentServerAddControllerSink         func(sink MaaEventCallback, transArg unsafe.Pointer) int64
	MaaAgentServerAddTaskerSink             func(sink MaaEventCallback, transArg unsafe.Pointer) int64
	MaaAgentServerAddContextSink            func(sink MaaEventCallback, transArg unsafe.Pointer) int64
	MaaAgentServerStartUp                   func(identifier string) bool
	MaaAgentServerShutDown                  func()
	MaaAgentServerJoin                      func()
	MaaAgentServerDetach                    func()
)
View Source
var (
	MaaTaskerCreate               func() uintptr
	MaaTaskerDestroy              func(tasker uintptr)
	MaaTaskerAddSink              func(tasker uintptr, sink MaaEventCallback, transArg uintptr) int64
	MaaTaskerRemoveSink           func(tasker uintptr, sinkId int64)
	MaaTaskerClearSinks           func(tasker uintptr)
	MaaTaskerAddContextSink       func(tasker uintptr, sink MaaEventCallback, transArg uintptr) int64
	MaaTaskerRemoveContextSink    func(tasker uintptr, sinkId int64)
	MaaTaskerClearContextSinks    func(tasker uintptr)
	MaaTaskerSetOption            func(tasker uintptr, key MaaTaskerOption, value unsafe.Pointer, valSize uint64) bool
	MaaTaskerBindResource         func(tasker uintptr, res uintptr) bool
	MaaTaskerBindController       func(tasker uintptr, ctrl uintptr) bool
	MaaTaskerInited               func(tasker uintptr) bool
	MaaTaskerPostTask             func(tasker uintptr, entry, pipelineOverride string) int64
	MaaTaskerPostRecognition      func(tasker uintptr, recognitionType, recognitionParam string, image uintptr) int64
	MaaTaskerPostAction           func(tasker uintptr, actionType, actionParam string, box uintptr, recoDetail string) int64
	MaaTaskerStatus               func(tasker uintptr, id int64) int32
	MaaTaskerWait                 func(tasker uintptr, id int64) int32
	MaaTaskerRunning              func(tasker uintptr) bool
	MaaTaskerPostStop             func(tasker uintptr) int64
	MaaTaskerStopping             func(tasker uintptr) bool
	MaaTaskerGetResource          func(tasker uintptr) uintptr
	MaaTaskerGetController        func(tasker uintptr) uintptr
	MaaTaskerClearCache           func(tasker uintptr) bool
	MaaTaskerGetRecognitionDetail func(tasker uintptr, recoId int64, nodeName uintptr, algorithm uintptr, hit *bool, box uintptr, detailJson uintptr, raw uintptr, draws uintptr) bool
	MaaTaskerGetActionDetail      func(tasker uintptr, actionId int64, nodeName uintptr, action uintptr, box uintptr, success *bool, detailJson uintptr) bool
	MaaTaskerGetNodeDetail        func(tasker uintptr, nodeId int64, nodeName uintptr, recoId *int64, actionId *int64, completed *bool) bool
	MaaTaskerGetTaskDetail        func(tasker uintptr, taskId int64, entry uintptr, nodeIdList uintptr, nodeIdListSize *uint64, status *int32) bool
	MaaTaskerGetLatestNode        func(tasker uintptr, taskName string, latestId *int64) bool
	MaaTaskerOverridePipeline     func(tasker uintptr, taskId int64, pipelineOverride string) bool
)
View Source
var (
	MaaResourceCreate                      func() uintptr
	MaaResourceDestroy                     func(res uintptr)
	MaaResourceAddSink                     func(res uintptr, sink MaaEventCallback, transArg uintptr) int64
	MaaResourceRemoveSink                  func(res uintptr, sinkId int64)
	MaaResourceClearSinks                  func(res uintptr)
	MaaResourceRegisterCustomRecognition   func(res uintptr, name string, recognition MaaCustomRecognitionCallback, transArg uintptr) bool
	MaaResourceUnregisterCustomRecognition func(res uintptr, name string) bool
	MaaResourceClearCustomRecognition      func(res uintptr) bool
	MaaResourceRegisterCustomAction        func(res uintptr, name string, action MaaCustomActionCallback, transArg uintptr) bool
	MaaResourceUnregisterCustomAction      func(res uintptr, name string) bool
	MaaResourceClearCustomAction           func(res uintptr) bool
	MaaResourcePostBundle                  func(res uintptr, path string) int64
	MaaResourcePostOcrModel                func(res uintptr, path string) int64
	MaaResourcePostPipeline                func(res uintptr, path string) int64
	MaaResourcePostImage                   func(res uintptr, path string) int64
	MaaResourceOverridePipeline            func(res uintptr, pipelineOverride string) bool
	MaaResourceOverrideNext                func(res uintptr, nodeName string, nextList uintptr) bool
	MaaResourceOverrideImage               func(res uintptr, imageName string, image uintptr) bool
	MaaResourceGetNodeData                 func(res uintptr, nodeName string, buffer uintptr) bool
	MaaResourceClear                       func(res uintptr) bool
	MaaResourceStatus                      func(res uintptr, id int64) int32
	MaaResourceWait                        func(res uintptr, id int64) int32
	MaaResourceLoaded                      func(res uintptr) bool
	MaaResourceSetOption                   func(res uintptr, key MaaResOption, value unsafe.Pointer, valSize uint64) bool
	MaaResourceGetHash                     func(res uintptr, buffer uintptr) bool
	MaaResourceGetNodeList                 func(res uintptr, buffer uintptr) bool
	MaaResourceGetCustomRecognitionList    func(res uintptr, buffer uintptr) bool
	MaaResourceGetCustomActionList         func(res uintptr, buffer uintptr) bool
	MaaResourceGetDefaultRecognitionParam  func(res uintptr, recoType string, buffer uintptr) bool
	MaaResourceGetDefaultActionParam       func(res uintptr, actionType string, buffer uintptr) bool
)
View Source
var (
	MaaAdbControllerCreate       func(adbPath, address string, screencapMethods uint64, inputMethods uint64, config, agentPath string) uintptr
	MaaPlayCoverControllerCreate func(address, uuid string) uintptr
	MaaWin32ControllerCreate     func(hWnd unsafe.Pointer, screencapMethods uint64, mouseMethod, keyboardMethod uint64) uintptr
	MaaCustomControllerCreate    func(controller unsafe.Pointer, controllerArg uintptr) uintptr
	MaaGamepadControllerCreate   func(hWnd unsafe.Pointer, gamepadType MaaGamepadType, screencapMethod uint64) uintptr
	MaaControllerDestroy         func(ctrl uintptr)
	MaaControllerAddSink         func(ctrl uintptr, sink MaaEventCallback, transArg uintptr) int64
	MaaControllerRemoveSink      func(ctrl uintptr, sinkId int64)
	MaaControllerClearSinks      func(ctrl uintptr)
	MaaControllerSetOption       func(ctrl uintptr, key MaaCtrlOption, value unsafe.Pointer, valSize uint64) bool
	MaaControllerPostConnection  func(ctrl uintptr) int64
	MaaControllerPostClick       func(ctrl uintptr, x, y int32) int64
	// for adb controller, contact means finger id (0 for first finger, 1 for second finger, etc)
	// for win32 controller, contact means mouse button id (0 for left, 1 for right, 2 for middle)
	MaaControllerPostClickV2    func(ctrl uintptr, x, y, contact, pressure int32) int64
	MaaControllerPostSwipe      func(ctrl uintptr, x1, y1, x2, y2, duration int32) int64
	MaaControllerPostSwipeV2    func(ctrl uintptr, x1, y1, x2, y2, duration, contact, pressure int32) int64
	MaaControllerPostClickKey   func(ctrl uintptr, keycode int32) int64
	MaaControllerPostInputText  func(ctrl uintptr, text string) int64
	MaaControllerPostStartApp   func(ctrl uintptr, intent string) int64
	MaaControllerPostStopApp    func(ctrl uintptr, intent string) int64
	MaaControllerPostTouchDown  func(ctrl uintptr, contact, x, y, pressure int32) int64
	MaaControllerPostTouchMove  func(ctrl uintptr, contact, x, y, pressure int32) int64
	MaaControllerPostTouchUp    func(ctrl uintptr, contact int32) int64
	MaaControllerPostKeyDown    func(ctrl uintptr, keycode int32) int64
	MaaControllerPostKeyUp      func(ctrl uintptr, keycode int32) int64
	MaaControllerPostScreencap  func(ctrl uintptr) int64
	MaaControllerPostScroll     func(ctrl uintptr, dx, dy int32) int64
	MaaControllerPostShell      func(ctrl uintptr, cmd string, timeout int64) int64
	MaaControllerGetShellOutput func(ctrl uintptr, buffer uintptr) bool
	MaaControllerStatus         func(ctrl uintptr, id int64) int32
	MaaControllerWait           func(ctrl uintptr, id int64) int32
	MaaControllerConnected      func(ctrl uintptr) bool
	MaaControllerCachedImage    func(ctrl uintptr, buffer uintptr) bool
	MaaControllerGetUuid        func(ctrl uintptr, buffer uintptr) bool
	MaaControllerGetResolution  func(ctrl uintptr, width, height *int32) bool
)
View Source
var (
	MaaContextRunTask              func(context uintptr, entry, pipelineOverride string) int64
	MaaContextRunRecognition       func(context uintptr, entry, pipelineOverride string, image uintptr) int64
	MaaContextRunAction            func(context uintptr, entry, pipelineOverride string, box uintptr, recoDetail string) int64
	MaaContextRunRecognitionDirect func(context uintptr, recoType, recoParam string, image uintptr) int64
	MaaContextRunActionDirect      func(context uintptr, actionType, actionParam string, box uintptr, recoDetail string) int64
	MaaContextWaitFreezes          func(context uintptr, time uint64, box uintptr, waitFreezesParam string) bool
	MaaContextOverridePipeline     func(context uintptr, pipelineOverride string) bool
	MaaContextOverrideNext         func(context uintptr, nodeName string, nextList uintptr) bool
	MaaContextOverrideImage        func(context uintptr, imageName string, image uintptr) bool
	MaaContextGetNodeData          func(context uintptr, nodeName string, buffer uintptr) bool
	MaaContextGetTaskId            func(context uintptr) int64
	MaaContextGetTasker            func(context uintptr) uintptr
	MaaContextClone                func(context uintptr) uintptr
	MaaContextSetAnchor            func(context uintptr, anchorName, nodeName string) bool
	MaaContextGetAnchor            func(context uintptr, anchorName string, buffer uintptr) bool
	MaaContextGetHitCount          func(context uintptr, nodeName string, count *uint64) bool
	MaaContextClearHitCount        func(context uintptr, nodeName string) bool
)
View Source
var (
	MaaStringBufferCreate  func() uintptr
	MaaStringBufferDestroy func(handle uintptr)
	MaaStringBufferIsEmpty func(handle uintptr) bool
	MaaStringBufferClear   func(handle uintptr) bool
	MaaStringBufferGet     func(handle uintptr) string
	MaaStringBufferSize    func(handle uintptr) uint64
	MaaStringBufferSet     func(handle uintptr, str string) bool
	MaaStringBufferSetEx   func(handle uintptr, str string, size uint64) bool

	MaaStringListBufferCreate  func() uintptr
	MaaStringListBufferDestroy func(handle uintptr)
	MaaStringListBufferIsEmpty func(handle uintptr) bool
	MaaStringListBufferSize    func(handle uintptr) uint64
	MaaStringListBufferAt      func(handle uintptr, index uint64) uintptr
	MaaStringListBufferAppend  func(handle uintptr, value uintptr) bool
	MaaStringListBufferRemove  func(handle uintptr, index uint64) bool
	MaaStringListBufferClear   func(handle uintptr) bool

	MaaImageBufferCreate     func() uintptr
	MaaImageBufferDestroy    func(handle uintptr)
	MaaImageBufferIsEmpty    func(handle uintptr) bool
	MaaImageBufferClear      func(handle uintptr) bool
	MaaImageBufferGetRawData func(handle uintptr) unsafe.Pointer
	MaaImageBufferWidth      func(handle uintptr) int32
	MaaImageBufferHeight     func(handle uintptr) int32
	MaaImageBufferChannels   func(handle uintptr) int32
	MaaImageBufferType       func(handle uintptr) int32
	MaaImageBufferSetRawData func(handle uintptr, data unsafe.Pointer, width, height, imageType int32) bool
	MaaImageBufferResize     func(handle uintptr, width, height int32) bool

	MaaImageListBufferCreate  func() uintptr
	MaaImageListBufferDestroy func(handle uintptr)
	MaaImageListBufferIsEmpty func(handle uintptr) bool
	MaaImageListBufferSize    func(handle uintptr) uint64
	MaaImageListBufferAt      func(handle uintptr, index uint64) uintptr
	MaaImageListBufferAppend  func(handle uintptr, value uintptr) bool
	MaaImageListBufferRemove  func(handle uintptr, index uint64) bool
	MaaImageListBufferClear   func(handle uintptr) bool

	MaaRectCreate  func() uintptr
	MaaRectDestroy func(handle uintptr)
	MaaRectGetX    func(handle uintptr) int32
	MaaRectGetY    func(handle uintptr) int32
	MaaRectGetW    func(handle uintptr) int32
	MaaRectGetH    func(handle uintptr) int32
	MaaRectSet     func(handle uintptr, x, y, w, h int32) bool
)
View Source
var (
	MaaGlobalSetOption  func(key MaaGlobalOption, value unsafe.Pointer, valSize uint64) bool
	MaaGlobalLoadPlugin func(path string) bool
)
View Source
var (
	MaaToolkitAdbDeviceListCreate          func() uintptr
	MaaToolkitAdbDeviceListDestroy         func(handle uintptr)
	MaaToolkitAdbDeviceFind                func(buffer uintptr) bool
	MaaToolkitAdbDeviceFindSpecified       func(adbPath string, buffer uintptr) bool
	MaaToolkitAdbDeviceListSize            func(list uintptr) uint64
	MaaToolkitAdbDeviceListAt              func(list uintptr, index uint64) uintptr
	MaaToolkitAdbDeviceGetName             func(device uintptr) string
	MaaToolkitAdbDeviceGetAdbPath          func(device uintptr) string
	MaaToolkitAdbDeviceGetAddress          func(device uintptr) string
	MaaToolkitAdbDeviceGetScreencapMethods func(device uintptr) int32
	MaaToolkitAdbDeviceGetInputMethods     func(device uintptr) int32
	MaaToolkitAdbDeviceGetConfig           func(device uintptr) string
)
View Source
var (
	MaaToolkitDesktopWindowListCreate    func() uintptr
	MaaToolkitDesktopWindowListDestroy   func(handle uintptr)
	MaaToolkitDesktopWindowFindAll       func(buffer uintptr) bool
	MaaToolkitDesktopWindowListSize      func(list uintptr) uint64
	MaaToolkitDesktopWindowListAt        func(list uintptr, index uint64) uintptr
	MaaToolkitDesktopWindowGetHandle     func(window uintptr) unsafe.Pointer
	MaaToolkitDesktopWindowGetClassName  func(window uintptr) string
	MaaToolkitDesktopWindowGetWindowName func(window uintptr) string
)
View Source
var MaaToolkitConfigInitOption func(userPath, defaultJson string) bool
View Source
var (
	MaaVersion func() string
)

Functions

func Init

func Init(libDir string) error

func Release

func Release() error

Types

type LibraryLoadError

type LibraryLoadError struct {
	// LibraryName is the name of the library that failed to load (e.g., "MaaFramework", "MaaToolkit").
	LibraryName string
	// LibraryPath is the full path to the library file that was attempted to load.
	LibraryPath string
	// Err is the underlying error from the system's library loading mechanism.
	Err error
}

LibraryLoadError represents an error that occurs when loading a dynamic library.

func (*LibraryLoadError) Error

func (e *LibraryLoadError) Error() string

func (*LibraryLoadError) Unwrap

func (e *LibraryLoadError) Unwrap() error

type MaaCtrlOption

type MaaCtrlOption int32
const (
	MaaCtrlOption_Invalid MaaCtrlOption = 0

	// MaaCtrlOptionScreenshotTargetLongSide specifies that only the long side can be set, and the short side
	// is automatically scaled according to the aspect ratio.
	MaaCtrlOption_ScreenshotTargetLongSide MaaCtrlOption = 1

	// MaaCtrlOptionScreenshotTargetShortSide specifies that only the short side can be set, and the long side
	// is automatically scaled according to the aspect ratio.
	MaaCtrlOption_ScreenshotTargetShortSide MaaCtrlOption = 2

	// MaaCtrlOptionScreenshotUseRawSize specifies that the screenshot uses the raw size without scaling.
	// Note that this option may cause incorrect coordinates on user devices with different resolutions if scaling is not performed.
	MaaCtrlOption_ScreenshotUseRawSize MaaCtrlOption = 3
)

type MaaCustomActionCallback

type MaaCustomActionCallback func(context uintptr, taskId int64, currentTaskName, customActionName, customActionParam *byte, recoId int64, box, transArg uintptr) uintptr

type MaaCustomRecognitionCallback

type MaaCustomRecognitionCallback func(context uintptr, taskId int64, currentTaskName, customRecognitionName, customRecognitionParam *byte, image, roi, transArg, outBox, outDetail uintptr) uintptr

type MaaEventCallback

type MaaEventCallback func(handle uintptr, message, detailsJson *byte, transArg uintptr) uintptr

type MaaGamepadType

type MaaGamepadType uint64
const (
	MaaGamepadType_Xbox360    MaaGamepadType = 0
	MaaGamepadType_DualShock4 MaaGamepadType = 1
)

type MaaGlobalOption

type MaaGlobalOption int32
const (
	MaaGlobalOption_Invalid MaaGlobalOption = 0

	// MaaGlobalOption_LogDir Log dir
	//
	// value: string, eg: "C:\\Users\\Administrator\\Desktop\\log"; val_size: string length
	MaaGlobalOption_LogDir MaaGlobalOption = 1

	// MaaGlobalOption_SaveDraw Whether to save draw
	//
	// value: bool, eg: true; val_size: sizeof(bool)
	MaaGlobalOption_SaveDraw MaaGlobalOption = 2

	// MaaGlobalOption_StdoutLevel The level of log output to stdout
	//
	// value: MaaLoggingLevel, val_size: sizeof(MaaLoggingLevel)
	// default value is MaaLoggingLevel_Error
	MaaGlobalOption_StdoutLevel MaaGlobalOption = 4

	// MaaGlobalOption_DebugMode Whether to debug
	//
	// value: bool, eg: true; val_size: sizeof(bool)
	MaaGlobalOption_DebugMode MaaGlobalOption = 6

	// MaaGlobalOption_SaveOnError Whether to save screenshot on error
	//
	// value: bool, eg: true; val_size: sizeof(bool)
	MaaGlobalOption_SaveOnError MaaGlobalOption = 7

	// MaaGlobalOption_DrawQuality Image quality for draw images
	//
	// value: int, eg: 85; val_size: sizeof(int)
	// default value is 85, range: [0, 100]
	MaaGlobalOption_DrawQuality MaaGlobalOption = 8

	// MaaGlobalOption_RecoImageCacheLimit Recognition image cache limit
	//
	// value: size_t, eg: 4096; val_size: sizeof(size_t)
	// default value is 4096
	MaaGlobalOption_RecoImageCacheLimit MaaGlobalOption = 9
)

type MaaInferenceDevice

type MaaInferenceDevice int32
const (
	MaaInferenceDevice_CPU  MaaInferenceDevice = -2
	MaaInferenceDevice_Auto MaaInferenceDevice = -1
	MaaInferenceDevice_0    MaaInferenceDevice = 0
	MaaInferenceDevice_1    MaaInferenceDevice = 1
)

type MaaInferenceExecutionProvider

type MaaInferenceExecutionProvider int32

type MaaResOption

type MaaResOption int32
const (
	MaaResOption_Invalid MaaResOption = 0

	/// Use the specified inference device.
	/// Please set this option before loading the model.
	///
	/// value: MaaInferenceDevice, eg: 0; val_size: sizeof(MaaInferenceDevice)
	/// default value is MaaInferenceDevice_Auto
	MaaResOption_InferenceDevice MaaResOption = 1

	/// Use the specified inference execution provider
	/// Please set this option before loading the model.
	///
	/// value: MaaInferenceExecutionProvider, eg: 0; val_size: sizeof(MaaInferenceExecutionProvider)
	/// default value is MaaInferenceExecutionProvider_Auto
	MaaResOption_InferenceExecutionProvider MaaResOption = 2
)

type MaaTaskerOption

type MaaTaskerOption int32

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL