Skip to content

Commit 1b66e12

Browse files
feat(sys): update bindings for MaaFramework v5.11.1 (#51)
Co-authored-by: Lemon-miaow <admin@lemonmiaow.xyz>
1 parent 793bb4a commit 1b66e12

7 files changed

Lines changed: 42 additions & 9 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ homepage = "https://github.com/MaaXYZ/MaaFramework"
1111
repository = "https://github.com/MaaXYZ/MaaFramework"
1212

1313
[workspace.dependencies]
14-
maa-framework-sys = { path = "maa-framework-sys", version = "5.11.0" }
14+
maa-framework-sys = { path = "maa-framework-sys", version = "5.11.1" }

maa-framework-sys/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "maa-framework-sys"
3-
version = "5.11.0"
3+
version = "5.11.1"
44
authors.workspace = true
55
edition.workspace = true
66
description = "Low-level Rust bindings for MaaFramework"

maa-framework-sys/src/bindings/dynamic_bindings.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,7 @@ pub struct MaaFramework {
900900
device_node: *const ::std::os::raw::c_char,
901901
screen_width: ::std::os::raw::c_int,
902902
screen_height: ::std::os::raw::c_int,
903+
use_win32_vk_code: MaaBool,
903904
) -> *mut MaaController,
904905
::libloading::Error,
905906
>,
@@ -3146,19 +3147,23 @@ impl MaaFramework {
31463147
)
31473148
}
31483149
}
3149-
#[doc = " @brief Create a KWin (pure Wayland) controller for Linux.\n\n @param device_node The uinput device node path (e.g., \"/dev/uinput\").\n @param screen_width The screen width in pixels.\n @param screen_height The screen height in pixels.\n @return The controller handle, or nullptr on failure.\n\n @note This controller is designed for KWin (pure Wayland) on Linux.\n @note Input is simulated via /dev/uinput (kernel-level virtual touchscreen).\n @note Screencap is implemented via PipeWire / xdg-desktop-portal (KDE/KWin).\n Captures the foreground monitor in fullscreen mode.\n @note Requires user authorization via the screen sharing dialog (xdg-desktop-portal).\n @note Requires write permission to /dev/uinput (typically via the \"input\" group).\n @note Only single touch is supported (contact must be 0)."]
3150+
#[doc = " @brief Create a KWin (pure Wayland) controller for Linux.\n\n @param device_node The uinput device node path (e.g., \"/dev/uinput\").\n @param screen_width The screen width in pixels.\n @param screen_height The screen height in pixels.\n @param use_win32_vk_code If true, key codes passed to click_key / key_down / key_up are\n interpreted as Win32 Virtual-Key codes (VK_*) and translated to Linux evdev codes\n internally. If false, key codes are passed through as raw evdev codes.\n @return The controller handle, or nullptr on failure.\n\n @note This controller is designed for KWin (pure Wayland) on Linux.\n @note Input is simulated via /dev/uinput (kernel-level virtual touchscreen).\n @note Screencap is implemented via PipeWire / xdg-desktop-portal (KDE/KWin).\n Captures the foreground monitor in fullscreen mode.\n @note Requires user authorization via the screen sharing dialog (xdg-desktop-portal).\n @note Requires write permission to /dev/uinput (typically via the \"input\" group).\n @note Only single touch is supported (contact must be 0)."]
31503151
pub unsafe fn MaaKWinControllerCreate(
31513152
&self,
31523153
device_node: *const ::std::os::raw::c_char,
31533154
screen_width: ::std::os::raw::c_int,
31543155
screen_height: ::std::os::raw::c_int,
3156+
use_win32_vk_code: MaaBool,
31553157
) -> *mut MaaController {
31563158
unsafe {
31573159
(self
31583160
.MaaKWinControllerCreate
31593161
.as_ref()
31603162
.expect("Expected function, got error."))(
3161-
device_node, screen_width, screen_height
3163+
device_node,
3164+
screen_width,
3165+
screen_height,
3166+
use_win32_vk_code,
31623167
)
31633168
}
31643169
}

maa-framework-sys/src/bindings/shims.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ shim ! (MaaReplayControllerCreate (recording_path : * const :: std :: os :: raw
6868
shim ! (MaaRecordControllerCreate (inner : * mut MaaController , recording_path : * const :: std :: os :: raw :: c_char) -> * mut MaaController) ;
6969
shim ! (MaaPlayCoverControllerCreate (address : * const :: std :: os :: raw :: c_char , uuid : * const :: std :: os :: raw :: c_char) -> * mut MaaController) ;
7070
shim ! (MaaWlRootsControllerCreate (wlr_socket_path : * const :: std :: os :: raw :: c_char , use_win32_vk_code : MaaBool) -> * mut MaaController) ;
71-
shim ! (MaaKWinControllerCreate (device_node : * const :: std :: os :: raw :: c_char , screen_width : :: std :: os :: raw :: c_int , screen_height : :: std :: os :: raw :: c_int) -> * mut MaaController) ;
71+
shim ! (MaaKWinControllerCreate (device_node : * const :: std :: os :: raw :: c_char , screen_width : :: std :: os :: raw :: c_int , screen_height : :: std :: os :: raw :: c_int , use_win32_vk_code : MaaBool) -> * mut MaaController) ;
7272
shim ! (MaaGamepadControllerCreate (hWnd : * mut :: std :: os :: raw :: c_void , gamepad_type : MaaGamepadType , screencap_method : MaaWin32ScreencapMethod) -> * mut MaaController) ;
7373
shim ! (MaaControllerDestroy (ctrl : * mut MaaController) -> ()) ;
7474
shim ! (MaaControllerAddSink (ctrl : * mut MaaController , sink : MaaEventCallback , trans_arg : * mut :: std :: os :: raw :: c_void) -> MaaSinkId) ;

maa-framework-sys/src/bindings/static_bindings.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,11 +699,12 @@ unsafe extern "C" {
699699
) -> *mut MaaController;
700700
}
701701
unsafe extern "C" {
702-
#[doc = " @brief Create a KWin (pure Wayland) controller for Linux.\n\n @param device_node The uinput device node path (e.g., \"/dev/uinput\").\n @param screen_width The screen width in pixels.\n @param screen_height The screen height in pixels.\n @return The controller handle, or nullptr on failure.\n\n @note This controller is designed for KWin (pure Wayland) on Linux.\n @note Input is simulated via /dev/uinput (kernel-level virtual touchscreen).\n @note Screencap is implemented via PipeWire / xdg-desktop-portal (KDE/KWin).\n Captures the foreground monitor in fullscreen mode.\n @note Requires user authorization via the screen sharing dialog (xdg-desktop-portal).\n @note Requires write permission to /dev/uinput (typically via the \"input\" group).\n @note Only single touch is supported (contact must be 0)."]
702+
#[doc = " @brief Create a KWin (pure Wayland) controller for Linux.\n\n @param device_node The uinput device node path (e.g., \"/dev/uinput\").\n @param screen_width The screen width in pixels.\n @param screen_height The screen height in pixels.\n @param use_win32_vk_code If true, key codes passed to click_key / key_down / key_up are\n interpreted as Win32 Virtual-Key codes (VK_*) and translated to Linux evdev codes\n internally. If false, key codes are passed through as raw evdev codes.\n @return The controller handle, or nullptr on failure.\n\n @note This controller is designed for KWin (pure Wayland) on Linux.\n @note Input is simulated via /dev/uinput (kernel-level virtual touchscreen).\n @note Screencap is implemented via PipeWire / xdg-desktop-portal (KDE/KWin).\n Captures the foreground monitor in fullscreen mode.\n @note Requires user authorization via the screen sharing dialog (xdg-desktop-portal).\n @note Requires write permission to /dev/uinput (typically via the \"input\" group).\n @note Only single touch is supported (contact must be 0)."]
703703
pub fn MaaKWinControllerCreate(
704704
device_node: *const ::std::os::raw::c_char,
705705
screen_width: ::std::os::raw::c_int,
706706
screen_height: ::std::os::raw::c_int,
707+
use_win32_vk_code: MaaBool,
707708
) -> *mut MaaController;
708709
}
709710
unsafe extern "C" {

maa-framework/src/controller.rs

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,36 @@ impl Controller {
241241
/// not exported by the Windows/macOS builds of MaaFramework.
242242
#[cfg(target_os = "linux")]
243243
pub fn new_kwin(device_node: &str, screen_width: i32, screen_height: i32) -> MaaResult<Self> {
244+
Self::new_kwin_with_vk_code(device_node, screen_width, screen_height, false)
245+
}
246+
247+
/// Create a new KWin (pure Wayland) controller for Linux.
248+
///
249+
/// Same as [`new_kwin`](Self::new_kwin), but lets you control how key codes are
250+
/// interpreted.
251+
///
252+
/// # Arguments
253+
/// * `device_node` - The uinput device node path (e.g. `/dev/uinput`)
254+
/// * `screen_width` - The screen width in pixels
255+
/// * `screen_height` - The screen height in pixels
256+
/// * `use_win32_vk_code` - Interpret key codes as Win32 Virtual-Key codes and translate
257+
/// them to Linux evdev codes internally when set to `true`
258+
#[cfg(target_os = "linux")]
259+
pub fn new_kwin_with_vk_code(
260+
device_node: &str,
261+
screen_width: i32,
262+
screen_height: i32,
263+
use_win32_vk_code: bool,
264+
) -> MaaResult<Self> {
244265
let c_node = CString::new(device_node)?;
245-
let handle =
246-
unsafe { sys::MaaKWinControllerCreate(c_node.as_ptr(), screen_width, screen_height) };
266+
let handle = unsafe {
267+
sys::MaaKWinControllerCreate(
268+
c_node.as_ptr(),
269+
screen_width,
270+
screen_height,
271+
use_win32_vk_code as sys::MaaBool,
272+
)
273+
};
247274

248275
Self::from_handle(handle)
249276
}

0 commit comments

Comments
 (0)