-
Notifications
You must be signed in to change notification settings - Fork 333
feat: AI 糊的 Win32 模拟手柄(要先装驱动) #972
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
MistEO
wants to merge
2
commits into
main
Choose a base branch
from
feat/gamepad
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
+521
−4
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Contributor
Reviewer's Guide新增一个 Win32 输入方法,通过 ViGEm 模拟虚拟 Xbox 360 手柄,并将其串联到 C++ 控制单元、语言绑定和文档中,同时将 ViGEm 客户端头文件以 vendoring 方式引入,以便在运行时动态使用。 通过 ViGEm 初始化 GamepadInput 的序列图sequenceDiagram
participant Win32ControlUnitMgr
participant GamepadInput
participant Kernel as ViGEmClientDLL
Win32ControlUnitMgr->>GamepadInput: constructor()
activate GamepadInput
GamepadInput->>GamepadInput: load_vigem()
activate GamepadInput
GamepadInput->>Kernel: LoadLibraryW(ViGEmClient.dll)
Kernel-->>GamepadInput: HMODULE
GamepadInput->>Kernel: GetProcAddress(vigem_alloc ... vigem_target_x360_update)
Kernel-->>GamepadInput: function_pointers
GamepadInput-->>GamepadInput: load_vigem() success?
deactivate GamepadInput
alt ViGEm_loaded
GamepadInput->>GamepadInput: init_gamepad()
activate GamepadInput
GamepadInput->>Kernel: fn_alloc_()
Kernel-->>GamepadInput: PVIGEM_CLIENT client_
GamepadInput->>Kernel: fn_connect_(client_)
Kernel-->>GamepadInput: VIGEM_ERROR
GamepadInput->>Kernel: fn_target_x360_alloc_()
Kernel-->>GamepadInput: PVIGEM_TARGET pad_
GamepadInput->>Kernel: fn_target_add_(client_, pad_)
Kernel-->>GamepadInput: VIGEM_ERROR
GamepadInput-->>GamepadInput: XUSB_REPORT_INIT(report_)
GamepadInput-->>Win32ControlUnitMgr: inited_ = true
deactivate GamepadInput
else load_failed
GamepadInput-->>Win32ControlUnitMgr: inited_ = false
end
deactivate GamepadInput
新的 GamepadInput Win32 输入方法的类图classDiagram
class InputBase {
<<abstract>>
+MaaControllerFeature get_features()
+bool click(int x, int y)
+bool swipe(int x1, int y1, int x2, int y2, int duration)
+bool touch_down(int contact, int x, int y, int pressure)
+bool touch_move(int contact, int x, int y, int pressure)
+bool touch_up(int contact)
+bool click_key(int key)
+bool input_text(const std::string& text)
+bool key_down(int key)
+bool key_up(int key)
+bool scroll(int dx, int dy)
}
class GamepadInput {
+GamepadInput()
+~GamepadInput()
+MaaControllerFeature get_features() const
+bool click(int x, int y)
+bool swipe(int x1, int y1, int x2, int y2, int duration)
+bool touch_down(int contact, int x, int y, int pressure)
+bool touch_move(int contact, int x, int y, int pressure)
+bool touch_up(int contact)
+bool click_key(int key)
+bool input_text(const std::string& text)
+bool key_down(int key)
+bool key_up(int key)
+bool scroll(int dx, int dy)
+bool set_button(WORD button, bool pressed)
+bool set_left_stick(SHORT x, SHORT y)
+bool set_right_stick(SHORT x, SHORT y)
+bool set_left_trigger(BYTE value)
+bool set_right_trigger(BYTE value)
-bool load_vigem()
-void unload_vigem()
-bool init_gamepad()
-void uninit_gamepad()
-bool send_state()
-HMODULE vigem_module_
-PVIGEM_CLIENT client_
-PVIGEM_TARGET pad_
-XUSB_REPORT report_
-bool inited_
-PFN_vigem_alloc fn_alloc_
-PFN_vigem_free fn_free_
-PFN_vigem_connect fn_connect_
-PFN_vigem_disconnect fn_disconnect_
-PFN_vigem_target_x360_alloc fn_target_x360_alloc_
-PFN_vigem_target_free fn_target_free_
-PFN_vigem_target_add fn_target_add_
-PFN_vigem_target_remove fn_target_remove_
-PFN_vigem_target_x360_update fn_target_x360_update_
}
class ViGEmClientDLL {
+PVIGEM_CLIENT vigem_alloc()
+void vigem_free(PVIGEM_CLIENT vigem)
+VIGEM_ERROR vigem_connect(PVIGEM_CLIENT vigem)
+void vigem_disconnect(PVIGEM_CLIENT vigem)
+PVIGEM_TARGET vigem_target_x360_alloc()
+void vigem_target_free(PVIGEM_TARGET target)
+VIGEM_ERROR vigem_target_add(PVIGEM_CLIENT vigem, PVIGEM_TARGET target)
+VIGEM_ERROR vigem_target_remove(PVIGEM_CLIENT vigem, PVIGEM_TARGET target)
+VIGEM_ERROR vigem_target_x360_update(PVIGEM_CLIENT vigem, PVIGEM_TARGET target, XUSB_REPORT report)
}
class XUSB_REPORT {
+USHORT wButtons
+BYTE bLeftTrigger
+BYTE bRightTrigger
+SHORT sThumbLX
+SHORT sThumbLY
+SHORT sThumbRX
+SHORT sThumbRY
}
InputBase <|-- GamepadInput
GamepadInput ..> ViGEmClientDLL : dynamic_load
GamepadInput --> XUSB_REPORT : uses
文件级变更
Tips and commandsInteracting with Sourcery
Customizing Your Experience访问你的 dashboard 以:
Getting HelpOriginal review guide in EnglishReviewer's GuideAdds a new Win32 input method that simulates a virtual Xbox 360 gamepad via ViGEm, wiring it through the C++ control unit, language bindings, and documentation, and vendoring the ViGEm client header for dynamic use at runtime. Sequence diagram for GamepadInput initialization via ViGEmsequenceDiagram
participant Win32ControlUnitMgr
participant GamepadInput
participant Kernel as ViGEmClientDLL
Win32ControlUnitMgr->>GamepadInput: constructor()
activate GamepadInput
GamepadInput->>GamepadInput: load_vigem()
activate GamepadInput
GamepadInput->>Kernel: LoadLibraryW(ViGEmClient.dll)
Kernel-->>GamepadInput: HMODULE
GamepadInput->>Kernel: GetProcAddress(vigem_alloc ... vigem_target_x360_update)
Kernel-->>GamepadInput: function_pointers
GamepadInput-->>GamepadInput: load_vigem() success?
deactivate GamepadInput
alt ViGEm_loaded
GamepadInput->>GamepadInput: init_gamepad()
activate GamepadInput
GamepadInput->>Kernel: fn_alloc_()
Kernel-->>GamepadInput: PVIGEM_CLIENT client_
GamepadInput->>Kernel: fn_connect_(client_)
Kernel-->>GamepadInput: VIGEM_ERROR
GamepadInput->>Kernel: fn_target_x360_alloc_()
Kernel-->>GamepadInput: PVIGEM_TARGET pad_
GamepadInput->>Kernel: fn_target_add_(client_, pad_)
Kernel-->>GamepadInput: VIGEM_ERROR
GamepadInput-->>GamepadInput: XUSB_REPORT_INIT(report_)
GamepadInput-->>Win32ControlUnitMgr: inited_ = true
deactivate GamepadInput
else load_failed
GamepadInput-->>Win32ControlUnitMgr: inited_ = false
end
deactivate GamepadInput
Class diagram for new GamepadInput Win32 input methodclassDiagram
class InputBase {
<<abstract>>
+MaaControllerFeature get_features()
+bool click(int x, int y)
+bool swipe(int x1, int y1, int x2, int y2, int duration)
+bool touch_down(int contact, int x, int y, int pressure)
+bool touch_move(int contact, int x, int y, int pressure)
+bool touch_up(int contact)
+bool click_key(int key)
+bool input_text(const std::string& text)
+bool key_down(int key)
+bool key_up(int key)
+bool scroll(int dx, int dy)
}
class GamepadInput {
+GamepadInput()
+~GamepadInput()
+MaaControllerFeature get_features() const
+bool click(int x, int y)
+bool swipe(int x1, int y1, int x2, int y2, int duration)
+bool touch_down(int contact, int x, int y, int pressure)
+bool touch_move(int contact, int x, int y, int pressure)
+bool touch_up(int contact)
+bool click_key(int key)
+bool input_text(const std::string& text)
+bool key_down(int key)
+bool key_up(int key)
+bool scroll(int dx, int dy)
+bool set_button(WORD button, bool pressed)
+bool set_left_stick(SHORT x, SHORT y)
+bool set_right_stick(SHORT x, SHORT y)
+bool set_left_trigger(BYTE value)
+bool set_right_trigger(BYTE value)
-bool load_vigem()
-void unload_vigem()
-bool init_gamepad()
-void uninit_gamepad()
-bool send_state()
-HMODULE vigem_module_
-PVIGEM_CLIENT client_
-PVIGEM_TARGET pad_
-XUSB_REPORT report_
-bool inited_
-PFN_vigem_alloc fn_alloc_
-PFN_vigem_free fn_free_
-PFN_vigem_connect fn_connect_
-PFN_vigem_disconnect fn_disconnect_
-PFN_vigem_target_x360_alloc fn_target_x360_alloc_
-PFN_vigem_target_free fn_target_free_
-PFN_vigem_target_add fn_target_add_
-PFN_vigem_target_remove fn_target_remove_
-PFN_vigem_target_x360_update fn_target_x360_update_
}
class ViGEmClientDLL {
+PVIGEM_CLIENT vigem_alloc()
+void vigem_free(PVIGEM_CLIENT vigem)
+VIGEM_ERROR vigem_connect(PVIGEM_CLIENT vigem)
+void vigem_disconnect(PVIGEM_CLIENT vigem)
+PVIGEM_TARGET vigem_target_x360_alloc()
+void vigem_target_free(PVIGEM_TARGET target)
+VIGEM_ERROR vigem_target_add(PVIGEM_CLIENT vigem, PVIGEM_TARGET target)
+VIGEM_ERROR vigem_target_remove(PVIGEM_CLIENT vigem, PVIGEM_TARGET target)
+VIGEM_ERROR vigem_target_x360_update(PVIGEM_CLIENT vigem, PVIGEM_TARGET target, XUSB_REPORT report)
}
class XUSB_REPORT {
+USHORT wButtons
+BYTE bLeftTrigger
+BYTE bRightTrigger
+SHORT sThumbLX
+SHORT sThumbLY
+SHORT sThumbRX
+SHORT sThumbRY
}
InputBase <|-- GamepadInput
GamepadInput ..> ViGEmClientDLL : dynamic_load
GamepadInput --> XUSB_REPORT : uses
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary by Sourcery
基于通过 ViGEm 的虚拟 Xbox 360 手柄,新增一种 Win32 手柄输入方法,并在各语言绑定和文档中公开该功能。
新增特性:
文档:
Original summary in English
Summary by Sourcery
Add a new Win32 gamepad input method based on a virtual Xbox 360 controller via ViGEm and expose it across bindings and documentation.
New Features:
Documentation: