Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
29 changes: 29 additions & 0 deletions controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,35 @@ func NewWlRootsController(
}, nil
}

// NewKWinController creates a KWin / Linux Wayland controller via PipeWire and /dev/uinput.
//
// Despite the name "KWin", this controller works with any Wayland compositor that
// implements the XDG Screencast Portal and kernel has uinput support (e.g., GNOME).
//
// deviceNode is the uinput device node path (e.g., "/dev/uinput").
// screenWidth and screenHeight are the screen dimensions in pixels.
// useWin32VkCode specifies whether key codes 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.
//
// Dependencies: pipewire (1.0+), xdg-desktop-portal.
func NewKWinController(
deviceNode string,
screenWidth, screenHeight int,
useWin32VkCode bool,
) (*Controller, error) {
handle := native.MaaKWinControllerCreate(deviceNode, screenWidth, screenHeight, useWin32VkCode)
if handle == 0 {
return nil, errors.New("failed to create KWin controller")
}

initControllerStore(handle)

return &Controller{
handle: handle,
}, nil
}

// NewMacOSController creates a macOS controller for native macOS applications.
// windowID is the CGWindowID of the target window (0 for desktop).
// screencapMethod is the macOS screencap method to use.
Expand Down
2 changes: 2 additions & 0 deletions internal/native/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ var (
MaaPlayCoverControllerCreate func(address, uuid string) uintptr
MaaWin32ControllerCreate func(hWnd unsafe.Pointer, screencapMethods uint64, mouseMethod, keyboardMethod uint64) uintptr
MaaWlRootsControllerCreate func(wlrSocketPath string, useWin32VkCode bool) uintptr
MaaKWinControllerCreate func(deviceNode string, screenWidth, screenHeight int, useWin32VkCode bool) uintptr
MaaCustomControllerCreate func(controller unsafe.Pointer, controllerArg uintptr) uintptr
MaaGamepadControllerCreate func(hWnd unsafe.Pointer, gamepadType MaaGamepadType, screencapMethod uint64) uintptr
MaaMacOSControllerCreate func(windowID uint32, screencapMethod MaaMacOSScreencapMethod, inputMethod MaaMacOSInputMethod) uintptr
Expand Down Expand Up @@ -447,6 +448,7 @@ var frameworkEntries = []Entry{
{&MaaPlayCoverControllerCreate, "MaaPlayCoverControllerCreate"},
{&MaaWin32ControllerCreate, "MaaWin32ControllerCreate"},
{&MaaWlRootsControllerCreate, "MaaWlRootsControllerCreate"},
{&MaaKWinControllerCreate, "MaaKWinControllerCreate"},
{&MaaCustomControllerCreate, "MaaCustomControllerCreate"},
{&MaaGamepadControllerCreate, "MaaGamepadControllerCreate"},
{&MaaMacOSControllerCreate, "MaaMacOSControllerCreate"},
Expand Down
Loading