Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public static partial class MaaController
public static partial MaaControllerHandle MaaPlayCoverControllerCreate(string address, string uuid);

[LibraryImport("MaaFramework", StringMarshalling = StringMarshalling.Utf8)]
public static partial MaaControllerHandle MaaWlRootsControllerCreate(string wlr_socket_path);
public static partial MaaControllerHandle MaaWlRootsControllerCreate(string wlr_socket_path, [MarshalAs(UnmanagedType.I1)] bool use_win32_vk_code);

/// <summary>
/// Create a virtual gamepad controller for Windows.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,23 @@ public class MaaWlRootsController : MaaController
{
#pragma warning disable IDE0032 // 使用自动属性
private readonly string _debugWlrSocketPath;
private readonly bool _debugUseWin32VkCode;
#pragma warning restore IDE0032 // 使用自动属性

[ExcludeFromCodeCoverage(Justification = "Debugger display.")]
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private string DebuggerDisplay => IsInvalid
? $"Invalid {GetType().Name}"
: $"{GetType().Name} {{ WlrSocketPath = {_debugWlrSocketPath} }}";
: $"{GetType().Name} {{ WlrSocketPath = {_debugWlrSocketPath}, UseWin32VkCode = {_debugUseWin32VkCode} }}";

/// <summary>
/// Creates a <see cref="MaaWlRootsController"/> instance.
/// </summary>
/// <param name="wlrSocketPath">The wayland socket path (e.g., "/run/user/1000/wayland-0").</param>
/// <param name="useWin32VkCode">If true, key codes passed to click_key / key_down / key_up are
/// interpreted as Win32 Virtual-Key codes (VK_*) and translated to Linux evdev codes
/// internally. If false, key codes are passed through as raw evdev codes.
/// </param>
/// <param name="link">Executes <see cref="IMaaController.LinkStart"/> if <see cref="LinkOption.Start"/>; otherwise, not link.</param>
/// <param name="check">Checks LinkStart().Wait() status if <see cref="CheckStatusOption.ThrowIfNotSucceeded"/>; otherwise, not check.</param>
/// <remarks>
Expand All @@ -32,15 +37,16 @@ public class MaaWlRootsController : MaaController
/// </remarks>
/// <exception cref="ArgumentException"/>
/// <exception cref="MaaJobStatusException"/>
public MaaWlRootsController(string wlrSocketPath, LinkOption link = LinkOption.Start, CheckStatusOption check = CheckStatusOption.ThrowIfNotSucceeded)
public MaaWlRootsController(string wlrSocketPath, bool useWin32VkCode = false, LinkOption link = LinkOption.Start, CheckStatusOption check = CheckStatusOption.ThrowIfNotSucceeded)
{
ArgumentException.ThrowIfNullOrEmpty(wlrSocketPath);

var handle = MaaWlRootsControllerCreate(wlrSocketPath);
var handle = MaaWlRootsControllerCreate(wlrSocketPath, useWin32VkCode);
_ = MaaControllerAddSink(handle, MaaEventCallback, (nint)MaaHandleType.Controller);
SetHandle(handle, needReleased: true);

_debugWlrSocketPath = wlrSocketPath;
_debugUseWin32VkCode = useWin32VkCode;

if (link == LinkOption.Start)
LinkStartOnConstructed(check, wlrSocketPath);
Expand Down
Loading