Skip to content

Add missing C API bindings for MaaFramework#22

Merged
moomiji merged 7 commits intomainfrom
copilot/fix-cs-binding-issues
Jan 21, 2026
Merged

Add missing C API bindings for MaaFramework#22
moomiji merged 7 commits intomainfrom
copilot/fix-cs-binding-issues

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 13, 2026

Syncs C# bindings with MaaFramework C headers from include/. Adds missing controller APIs, gamepad support, and fixes custom controller struct layout.

Controller API Additions

  • MaaControllerPostClickV2 / MaaControllerPostSwipeV2 - Extended variants with contact and pressure params
  • MaaControllerGetResolution - Raw device resolution getter
  • MaaGamepadControllerCreate - Virtual gamepad controller (ViGEm-based)

Gamepad Enums

  • GamepadType - Xbox360, DualShock4
  • GamepadButton - XUSB button flags with DS4 aliases
  • GamepadTouch - Analog stick/trigger contact mapping

Custom Controller Fix

Fixed MaaCustomControllerCallbacks struct layout - added missing Connected callback between Connect and RequestUuid. Removed RequestResolution from interface (not in C API).

Usage

// Extended click/swipe with contact and pressure
controller.Click(100, 200, contact: 0, pressure: 100);
controller.Swipe(0, 0, 100, 100, duration: 500, contact: 0, pressure: 100);

// Get raw resolution
if (controller.GetResolution(out var width, out var height))
    Console.WriteLine($"Device: {width}x{height}");

// Gamepad controller (Windows)
var gamepad = new MaaGamepadController(hWnd, GamepadType.Xbox360, Win32ScreencapMethod.GDI);
gamepad.ClickKey((int)GamepadButton.A);
gamepad.TouchDown((int)GamepadTouch.LeftStick, x: 16000, y: 0, pressure: 0);

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • maaxyz.github.io
    • Triggering command: /usr/bin/dotnet dotnet build --no-restore (dns block)
    • Triggering command: /usr/bin/dotnet dotnet restore (dns block)
    • Triggering command: /usr/bin/dotnet dotnet restore --ignore-failed-sources (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

参考 https://github.com/MaaXYZ/MaaFramework/tree/main/include 里的 C 接口(及docs里的文档),查漏补缺 CS binding


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits January 13, 2026 12:26
Co-authored-by: MistEO <18511905+MistEO@users.noreply.github.com>
Co-authored-by: MistEO <18511905+MistEO@users.noreply.github.com>
Co-authored-by: MistEO <18511905+MistEO@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix gaps in CS binding for C interfaces Add missing C API bindings for MaaFramework Jan 13, 2026
Copilot AI requested a review from MistEO January 13, 2026 12:38
@MistEO MistEO requested review from Copilot and moomiji January 13, 2026 12:51
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR synchronizes C# bindings with the MaaFramework C API, adding missing controller APIs, gamepad support, and fixing the custom controller callback struct layout.

Changes:

  • Added extended controller methods (Click/Swipe V2) with contact and pressure parameters
  • Added gamepad controller support with three new enums (GamepadType, GamepadButton, GamepadTouch)
  • Fixed custom controller callback struct by adding missing Connected callback and removing RequestResolution

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/MaaFramework.Binding/IMaaController.cs Added overloaded Click/Swipe methods with contact and pressure parameters, and GetResolution method
src/MaaFramework.Binding/Enums/Controllers/GamepadType.cs New enum for virtual gamepad types (Xbox360, DualShock4)
src/MaaFramework.Binding/Enums/Controllers/GamepadTouch.cs New enum for gamepad analog input mapping (sticks and triggers)
src/MaaFramework.Binding/Enums/Controllers/GamepadButton.cs New flags enum for gamepad button codes with Xbox and DualShock 4 aliases
src/MaaFramework.Binding/Custom/IMaaCustomController.cs Added Connected() method, removed RequestResolution() method to match C API
src/MaaFramework.Binding.UnitTests/Test_Custom.cs Updated test implementation to include Connected() method, removed RequestResolution()
src/MaaFramework.Binding.Native/MaaController/MaaGamepadController.cs New wrapper class for MaaGamepadControllerCreate with ViGEm-based virtual gamepad support
src/MaaFramework.Binding.Native/MaaController.cs Implemented new Click/Swipe V2 and GetResolution methods
src/MaaFramework.Binding.Native/Interop/Framework/MaaDef.cs Added type aliases for gamepad types
src/MaaFramework.Binding.Native/Interop/Framework/Instance/MaaCustomController.cs Fixed struct layout by adding Connected callback between Connect and RequestUuid
src/MaaFramework.Binding.Native/Interop/Framework/Instance/MaaController.cs Added P/Invoke declarations for new controller APIs

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@moomiji moomiji marked this pull request as ready for review January 21, 2026 13:47
@moomiji moomiji merged commit 1833efd into main Jan 21, 2026
4 checks passed
@moomiji moomiji deleted the copilot/fix-cs-binding-issues branch January 21, 2026 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants