Skip to content

Commit df33f69

Browse files
committed
feat: 忘记pull了,补上
1 parent 0583ea6 commit df33f69

7 files changed

Lines changed: 35 additions & 1 deletion

File tree

src/MaaFramework.Binding.Native/Interop/Framework/Instance/MaaController.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ public static partial class MaaController
8686
[LibraryImport("MaaFramework", StringMarshalling = StringMarshalling.Utf8)]
8787
public static partial MaaCtrlId MaaControllerPostScreencap(MaaControllerHandle ctrl);
8888

89+
[LibraryImport("MaaFramework", StringMarshalling = StringMarshalling.Utf8)]
90+
public static partial MaaCtrlId MaaControllerPostScroll(MaaControllerHandle ctrl, int dx, int dy);
91+
8992
[LibraryImport("MaaFramework", StringMarshalling = StringMarshalling.Utf8)]
9093
public static partial MaaStatus MaaControllerStatus(MaaControllerHandle ctrl, MaaCtrlId id);
9194

src/MaaFramework.Binding.Native/Interop/Framework/Instance/MaaCustomController.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ private sealed class Delegates(IMaaCustomController managed)
108108
public InputTextDelegate InputText = (string text, nint transArg) => managed.InputText(text);
109109
public KeyDownDelegate KeyDown = (int keycode, nint transArg) => managed.KeyDown(keycode);
110110
public KeyUpDelegate KeyUp = (int keycode, nint transArg) => managed.KeyUp(keycode);
111+
public ScrollDelegate Scroll = (int dx, int dy, nint transArg) => managed.Scroll(dx, dy);
111112
};
112113

113114
/// <summary>
@@ -135,6 +136,7 @@ private sealed class Unmanaged(Delegates delegates)
135136
public nint InputText = Marshal.GetFunctionPointerForDelegate(delegates.InputText);
136137
public nint KeyDown = Marshal.GetFunctionPointerForDelegate(delegates.KeyDown);
137138
public nint KeyUp = Marshal.GetFunctionPointerForDelegate(delegates.KeyUp);
139+
public nint Scroll = Marshal.GetFunctionPointerForDelegate(delegates.Scroll);
138140
}
139141

140142
[return: MarshalAs(UnmanagedType.U1)]
@@ -201,4 +203,8 @@ private sealed class Unmanaged(Delegates delegates)
201203
[return: MarshalAs(UnmanagedType.U1)]
202204
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
203205
public delegate bool KeyUpDelegate(int keycode, nint transArg);
206+
207+
[return: MarshalAs(UnmanagedType.U1)]
208+
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
209+
public delegate bool ScrollDelegate(int dx, int dy, nint transArg);
204210
}

src/MaaFramework.Binding.Native/MaaController.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,13 @@ public MaaJob KeyUp(int keyCode)
182182
public MaaJob Screencap()
183183
=> CreateJob(MaaControllerPostScreencap(Handle));
184184

185+
/// <inheritdoc/>
186+
/// <remarks>
187+
/// Wrapper of <see cref="MaaControllerPostScroll"/>.
188+
/// </remarks>
189+
public MaaJob Scroll(int dx, int dy)
190+
=> CreateJob(MaaControllerPostScroll(Handle, dx, dy));
191+
185192
/// <inheritdoc/>
186193
/// <remarks>
187194
/// Wrapper of <see cref="MaaControllerStatus"/>.

src/MaaFramework.Binding.Native/MaaGlobal.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ public bool SetOption<T>(GlobalOption opt, T value)
3333
(int vvvv, GlobalOption.StdoutLevel) => vvvv.ToMaaOptionValue(),
3434
(string v, GlobalOption.LogDir) => v.ToMaaOptionValue(),
3535
(bool vvv, GlobalOption.SaveDraw
36-
or GlobalOption.DebugMode) => vvv.ToMaaOptionValue(),
36+
or GlobalOption.DebugMode
37+
or GlobalOption.SaveOnError) => vvv.ToMaaOptionValue(),
3738

3839
(LoggingLevel v, GlobalOption.StdoutLevel) => ((int)v).ToMaaOptionValue(),
3940

src/MaaFramework.Binding/Custom/IMaaCustomController.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,5 @@ public interface IMaaCustomController : IMaaCustomResource, IDisposable
3737
bool InputText(string text);
3838
bool KeyDown(int keycode);
3939
bool KeyUp(int keycode);
40+
bool Scroll(int dx, int dy);
4041
}

src/MaaFramework.Binding/Enums/Options/GlobalOption.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,12 @@ public enum GlobalOption : System.Int32
4444
/// <para>value: bool, eg: true; val_size: sizeof(bool)</para>
4545
/// </remarks>
4646
DebugMode = 6,
47+
/// <summary>
48+
/// Whether to save screenshot on error
49+
/// </summary>
50+
/// <remarks>
51+
/// <para>value: bool, eg: true; val_size: sizeof(bool)</para>
52+
/// </remarks>
53+
SaveOnError = 7,
4754
}
4855

src/MaaFramework.Binding/IMaaController.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,15 @@ public interface IMaaController : IMaaCommon, IMaaOption<ControllerOption>, IMaa
128128
/// <returns>A screen capture <see cref="MaaJob"/>.</returns>
129129
MaaJob Screencap();
130130

131+
/// <summary>
132+
/// Posts a scroll action.
133+
/// </summary>
134+
/// <param name="dx">The horizontal scroll delta. Positive values scroll right, negative values scroll left.</param>
135+
/// <param name="dy">The vertical scroll delta. Positive values scroll down, negative values scroll up.</param>
136+
/// <returns>A scroll <see cref="MaaJob"/>.</returns>
137+
/// <remarks>Not all controllers support scroll. If not supported, the action will fail.</remarks>
138+
MaaJob Scroll(int dx, int dy);
139+
131140
/// <summary>
132141
/// Gets whether the <see cref="IMaaController"/> is connected to the device specified by the constructor.
133142
/// </summary>

0 commit comments

Comments
 (0)