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

DualSense Adaptive Triggers Support #757

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

VHemmekam
Copy link

@VHemmekam VHemmekam commented Nov 29, 2023

DualSense Adaptive Triggers Support

The changes introduced in this pull request aim to provide resistance to adaptive triggers before the ZR/ZL buttons are pressed, offering a more immersive and responsive gaming experience. I also resolved a bug for the DualSense controller, ensuring that setting analog_trigger_activation_threshold to 100% is now reachable.

The adaptive triggers can be customized through the missioncontrol.ini file, and they are enabled by default. They perform best (by my opinion) when the analog_trigger_activation_threshold is set to 100%.

Configuration

analog_trigger_activation_threshold This existing property influences the end section of the adaptive triggers.
dualsense_enable_adaptive_triggers Enables or disables adaptive triggers for the DualSense controller.
dualsense_adaptive_triggers_resistance Allows the customization of the DualSense adaptive triggers resistance. Valid range is [0-9], where 0 represents light resistance and 9 represents heavy resistance.

Future

In the future, it would be interesting to enable users to create scripts (or files with memory addresses) for specific game titles, which MissionControl can utilize to adjust the adaptive triggers according to the game's current state.

Credits

I would also like to thank Mxater for his valuable contribution of the DualSenseSupport project. His code served as an essential reference and inspiration throughout the development of this pull request.

Binaries

MissionControl-0.10.0-dualsense-adaptive-triggers-2e08477.zip

Copy link
Owner

@ndeadly ndeadly left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution. No major objections to merging such a feature, just a few implementation details and style issues to be addressed.

@@ -150,6 +150,8 @@ These are miscellaneous controller-specific settings etc.
- `dualsense_lightbar_brightness` Set LED lightbar brightness for Sony Dualsense controllers. Valid range [0-9] where 0=off, 1=min, 2-9=12.5-100% in 12.5% increments.
- `dualsense_enable_player_leds` Enable/disable the white player indicator LEDs below the Dualsense touchpad.
- `dualsense_vibration_intensity` Set Dualsense vibration intensity, 12.5% per increment. Valid range [1-8] where 1=12.5%, 8=100%.
- `dualsense_enable_adaptive_triggers` Enable/disable adaptive triggers for Dualsense.
Copy link
Owner

Choose a reason for hiding this comment

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

There is no need for an additional enable option. You can just make the numbers run 0-10, where 0 is disabled.

@@ -150,6 +150,8 @@ These are miscellaneous controller-specific settings etc.
- `dualsense_lightbar_brightness` Set LED lightbar brightness for Sony Dualsense controllers. Valid range [0-9] where 0=off, 1=min, 2-9=12.5-100% in 12.5% increments.
- `dualsense_enable_player_leds` Enable/disable the white player indicator LEDs below the Dualsense touchpad.
- `dualsense_vibration_intensity` Set Dualsense vibration intensity, 12.5% per increment. Valid range [1-8] where 1=12.5%, 8=100%.
- `dualsense_enable_adaptive_triggers` Enable/disable adaptive triggers for Dualsense.
- `dualsense_adaptive_triggers_resistance` Set Dualsense adaptive triggers resistance. Valid range [0-9] where 0=light, 9=heavy.
Copy link
Owner

Choose a reason for hiding this comment

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

I think we can simplify this to dualsense_trigger_resistance, since we are not using them in an "adaptive" manner.

@@ -26,3 +26,7 @@
;dualsense_enable_player_leds=false
; Set Dualsense vibration intensity, 12.5% per increment. Valid range [1-8] where 1=12.5%, 8=100% [default 4(50%)]
;dualsense_vibration_intensity=4
; Enable adaptive triggers [default true]
;dualsense_enable_adaptive_triggers=true
Copy link
Owner

Choose a reason for hiding this comment

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

In addition to what I wrote above about using a single config option, this option should be disabled by default (i.e. set to 0)

@@ -156,8 +156,8 @@ namespace ams::controller {

this->MapButtons(&src->input0x01.buttons);

m_buttons.ZR = src->input0x01.right_trigger > (m_trigger_threshold * UINT8_MAX);
m_buttons.ZL = src->input0x01.left_trigger > (m_trigger_threshold * UINT8_MAX);
m_buttons.ZR = src->input0x01.right_trigger > (std::min(m_trigger_threshold * UINT8_MAX, UINT8_MAX - 1.0f));
Copy link
Owner

Choose a reason for hiding this comment

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

No need to wrap a function call in parethesis

float adaptive_trigger_threshold_end = (std::max(trigger_threshold - 80.0f, 0.0f));
float adaptive_trigger_threshold_start = (std::max(adaptive_trigger_threshold_end - 10.0f, 0.0f));

u8 force1 = static_cast<u8>(adaptive_trigger_threshold_start);
Copy link
Owner

Choose a reason for hiding this comment

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

No need to cast these, you can just assign them as u8 above

// Start of resistance section
// 0x00 = 0%
// 0xFF = 100%
report.output0x31.data[12] = force1;
Copy link
Owner

Choose a reason for hiding this comment

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

I would assign these directly, rather than creating intermediate force variables

// (Mode Extra A & Extra B = Strength of effect near release state)
// 0x00 = 0%
// 0xFF = 100%
report.output0x31.data[15] = 0x00;
Copy link
Owner

Choose a reason for hiding this comment

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

No need to assign unused fields, report is zero-initialised


u8 force3 = static_cast<u8>(config->misc.dualsense_adaptive_triggers_resistance / 9.0f * 255.0f);

// --- Control flags ---
Copy link
Owner

Choose a reason for hiding this comment

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

These comments don't match the project style. Dont use things like --- to separate sections. I usually label sections with a comment and separate them by blank lines


// --- Right trigger ---

// [Mode]
Copy link
Owner

Choose a reason for hiding this comment

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

Likewise with these. Don't use [ ]. Prefer single line and/or inline comments if you must add them. I don't like multi-line comments within code blocks decreasing the amount of actual code I can fit on the screen. In this case a self-documenting enum might be a better choice. Or even just a url to where you found this info documented, in the event it might be needed in the future.

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.

None yet

2 participants