Skip to content
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

Add touchpad left click as a target button #986

Closed
wants to merge 2 commits into from

Conversation

romracer
Copy link
Contributor

@romracer romracer commented Feb 6, 2024

This adds the touchpad left click (single touch click) from DS4 virtual controllers as a target button for DInput, Pro and Xinput controllers. This is currently available via the touchscreen, but this adds the ability to remap buttons to this function.

This is useful for situations where a game natively supports a DS4 controller on Windows and therefore most likely doesn't use the Share button from the DS4 controller. On an Xinput device, for example, the default mapping for Back/View is to the Share button, but if a game doesn't support the Share button, this can now be remapped to the touchpad click.

In Modern Warfare, for example, this makes the Back/View button which is previously unusable open the game map instead.

This doesn't change the default mapping for these controllers because there are valid uses for those cases as well.

I also added a comment to the other controller source files, but that was just for consistency for the new lines added elsewhere.

Closes #799

Summary by CodeRabbit

  • New Features
    • Enhanced controller support across various controllers (DInput, DS4, DualSense, Gordon, Neptune, Pro Controller, XInput) with the addition of new target buttons, improving game interaction and user experience.

… and XInput devices

Add comment to the other files for consistency.
Copy link
Contributor

coderabbitai bot commented Feb 6, 2024

Walkthrough

The recent updates to the HandheldCompanion project focused on enhancing controller compatibility and functionality. By adding new namespace imports and expanding the list of target buttons for various controllers, the project now supports more user-specific customization options, such as remapping trackpad actions to button clicks for different controllers, including DS4 and DualSense.

Changes

Files Change Summary
DInputController.cs, DS4Controller.cs, DualSenseController.cs, GordonController.cs, NeptuneController.cs, ProController.cs, XInputController.cs Added imports and expanded target buttons for enhanced controller support.

Assessment against linked issues

Objective Addressed Explanation
Layout Remapper option, DS4 trackpad to button click (#799)

Poem

🎮🐰

In a world where controllers abound,
A rabbit hopped, making hardly a sound.
With a flick and a click, maps unfold,
In battle royales, stories told.

🌟🎮🌟

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between b85593a and 60901de.
Files selected for processing (7)
  • HandheldCompanion/Controllers/DInputController.cs (3 hunks)
  • HandheldCompanion/Controllers/DS4Controller.cs (2 hunks)
  • HandheldCompanion/Controllers/DualSenseController.cs (2 hunks)
  • HandheldCompanion/Controllers/GordonController.cs (2 hunks)
  • HandheldCompanion/Controllers/NeptuneController.cs (2 hunks)
  • HandheldCompanion/Controllers/ProController.cs (2 hunks)
  • HandheldCompanion/Controllers/XInputController.cs (1 hunks)
Files skipped from review due to trivial changes (2)
  • HandheldCompanion/Controllers/DualSenseController.cs
  • HandheldCompanion/Controllers/NeptuneController.cs
Additional comments: 7
HandheldCompanion/Controllers/DInputController.cs (2)
  • 1-1: Ensure the added namespace HandheldCompanion.Inputs is utilized within the file for the newly introduced functionality.
  • 36-37: Adding ButtonFlags.LeftPadClick to TargetButtons correctly implements the feature to map the touchpad left click. Verify that ButtonFlags.LeftPadClick is properly defined and handled elsewhere in the project.
Verification successful

The verification process confirms that ButtonFlags.LeftPadClick is properly defined and extensively used throughout the project, including in controller logic, UI components, input management, and localization resources. This ensures that the feature to map the touchpad left click is implemented and integrated correctly across the application.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify ButtonFlags.LeftPadClick definition and usage
rg "ButtonFlags.LeftPadClick"

Length of output: 13302

HandheldCompanion/Controllers/ProController.cs (2)
  • 20-21: Adding ButtonFlags.LeftPadClick to TargetButtons correctly extends the functionality for the ProController. Ensure consistency with how target buttons are managed across different controller classes.
  • 20-21: The UpdateInputs method does not show modifications related to handling the newly added target buttons. Ensure that the addition of these buttons has the intended effect and is properly utilized within the method or elsewhere as needed.
HandheldCompanion/Controllers/DS4Controller.cs (1)
  • 34-34: Adding ButtonFlags.LeftPadClick, ButtonFlags.LeftPadTouch, and ButtonFlags.RightPadTouch to TargetButtons correctly extends the functionality for the DS4Controller. Ensure these buttons are properly defined and utilized within the project.
Verification successful

The addition of ButtonFlags.LeftPadClick, ButtonFlags.LeftPadTouch, and ButtonFlags.RightPadTouch to TargetButtons in the DS4Controller and their extensive usage across the project has been verified. These buttons are properly defined and utilized within the project, indicating a correct extension of functionality for the DS4Controller.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify ButtonFlags definitions and usage for newly added buttons
rg "ButtonFlags.(LeftPadClick|LeftPadTouch|RightPadTouch)"

Length of output: 26792

HandheldCompanion/Controllers/XInputController.cs (1)
  • 36-37: Adding ButtonFlags.LeftPadClick to TargetButtons correctly implements the feature to map the touchpad left click for XInput controllers. Verify that this addition is consistent with the handling of target buttons across different controller classes.
HandheldCompanion/Controllers/GordonController.cs (1)
  • 45-45: Adding ButtonFlags.LeftPadClick, ButtonFlags.RightPadClick, and ButtonFlags.LeftPadTouch to TargetButtons correctly extends the functionality for the GordonController. Ensure these buttons are properly defined and utilized within the project.
Verification successful

The addition of ButtonFlags.LeftPadClick, ButtonFlags.RightPadClick, and ButtonFlags.LeftPadTouch to TargetButtons in the GordonController and their usage throughout the project is correctly implemented and well-integrated. The script output confirms their proper definition and utilization across various parts of the project, including UI elements, controller classes, resource files for localization, and input management logic. This demonstrates a comprehensive integration of the new functionality within the existing codebase.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify ButtonFlags definitions and usage for newly added buttons
rg "ButtonFlags.(LeftPadClick|RightPadClick|LeftPadTouch)"

Length of output: 30416

@CasperH2O
Copy link
Collaborator

CasperH2O commented Feb 7, 2024

Nice PR @romracer ! It's a bit up for discussion if we want all the none Playstation controllers to also "input" a touchpad left click into a game. I don't think they even can? However, if these are removed and the user configures a button to be remapped this way, it would be confusing why it does not work when using an emulated xbox 360 controller.

How do we currently handle the other remappable features like touchpad, are they hidden if the virtual controller is not a DS4 or DS?

@MSeys
Copy link
Contributor

MSeys commented Feb 7, 2024

@CasperH2O
The mapping / stack is hidden when the emulated controller does not have the button flag / axis flag.

@Valkirie
Copy link
Owner

Valkirie commented Feb 7, 2024

@romracer I'm slightly confused here. You can already map any button to Single-touch click as soon as your emulated controller supports a touchpad (Dualshock 4).

Here I have my XBOX LB button mapped to send a Touchpad click on my virtual DS4 controller.
image

@CasperH2O
Copy link
Collaborator

@Valkirie , so #799 is already implemented?

@romracer
Copy link
Contributor Author

romracer commented Feb 7, 2024

Nice PR @romracer ! It's a bit up for discussion if we want all the none Playstation controllers to also "input" a touchpad left click into a game. I don't think they even can?

Thanks, and they can by remapping an existing button to output that touchpad click.

@CasperH2O The mapping / stack is hidden when the emulated controller does not have the button flag / axis flag.

I'm no C# wizard, but it looks like the stacks are hidden based on the source controller, not emulated (the Trackpads section is disabled on my Xbox 360 source controller even when emulating a DS4).

@romracer I'm slightly confused here. You can already map any button to Single-touch click as soon as your emulated controller supports a touchpad (Dualshock 4).

Here I have my XBOX LB button mapped to send a Touchpad click on my virtual DS4 controller. image

Hmmm.. okay, I'll have to go back and check. This didn't used to be implemented and #799 was what kept me using MotionAssistant instead of this.

@Valkirie
Copy link
Owner

Valkirie commented Feb 7, 2024

Nice PR @romracer ! It's a bit up for discussion if we want all the none Playstation controllers to also "input" a touchpad left click into a game. I don't think they even can?

Thanks, and they can by remapping an existing button to output that touchpad click.

@CasperH2O The mapping / stack is hidden when the emulated controller does not have the button flag / axis flag.

I'm no C# wizard, but it looks like the stacks are hidden based on the source controller, not emulated (the Trackpads section is disabled on my Xbox 360 source controller even when emulating a DS4).

@romracer I'm slightly confused here. You can already map any button to Single-touch click as soon as your emulated controller supports a touchpad (Dualshock 4).
Here I have my XBOX LB button mapped to send a Touchpad click on my virtual DS4 controller. image

Hmmm.. okay, I'll have to go back and check. This didn't used to be implemented and #799 was what kept me using MotionAssistant instead of this.

I know @MSeys have been fixing a few issues as a side effect of his MVVM implementation and I believe incorrectly available buttons might be fixed (I also had an issue here where the available output buttons would remain available when switch from virtual DS4 to Xbox)

@romracer
Copy link
Contributor Author

romracer commented Feb 7, 2024

@Valkirie I'm not sure how I missed it, but I guess #799 is implemented even without this PR. I do have to mark my virtual controller as a DS4 (duh) BUT I also have to mark it as connected, then Single / Multi-touch tap and Single touch click show up in the remap profile.

Subsequently marking it as disconnected doesn't remove them from the list unless I restart HC - this might be similar to the bug you were referencing when going between DS / Xbox 360 virtual controllers.

I'll leave this PR open in case there's any other comments that haven't been addressed (yet) but otherwise I think it can be closed if there's nothing else.

@CasperH2O
Copy link
Collaborator

@Valkirie I'm not sure how I missed it, but I guess #799 is implemented even without this PR. I do have to mark my virtual controller as a DS4 (duh) BUT I also have to mark it as connected, then Single / Multi-touch tap and Single touch click show up in the remap profile.

Subsequently marking it as disconnected doesn't remove them from the list unless I restart HC - this might be similar to the bug you were referencing when going between DS / Xbox 360 virtual controllers.

It's regrettably that you had to find out this way indeed, there is indeed a know bug #867 with the icons and availability of the buttons. This will receive extra testing and investigating with the MVVM rebuild.

I was also not aware the actual feature was implemented, as I don't use it myself.

I'll leave this PR open in case there's any other comments that haven't been addressed (yet) but otherwise I think it can be closed if there's nothing else.

Let's close it. Thank you for your effort, hopefully you can enjoy this feature next time you use HC. 🙂

@CasperH2O CasperH2O closed this Feb 8, 2024
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.

Layout Remapper option, DS4 trackpad to button click
4 participants