-
-
Notifications
You must be signed in to change notification settings - Fork 145
DualSense Adaptive Triggers Support #757
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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. | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can simplify this to |
||
|
|
||
| ### Removal | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) |
||
| ; Set resistance of the DualSense adaptive triggers. Valid range [0-9] where 0=light, 9=heavy [default 0(light)] | ||
| ;dualsense_adaptive_triggers_resistance=0 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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)); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to wrap a function call in parethesis |
||
| m_buttons.ZL = src->input0x01.left_trigger > (std::min(m_trigger_threshold * UINT8_MAX, UINT8_MAX - 1.0f)); | ||
| } | ||
|
|
||
| void DualsenseController::MapInputReport0x31(const DualsenseReportData *src) { | ||
|
|
@@ -190,8 +190,8 @@ namespace ams::controller { | |
|
|
||
| this->MapButtons(&src->input0x31.buttons); | ||
|
|
||
| m_buttons.ZR = src->input0x31.right_trigger > (m_trigger_threshold * UINT8_MAX); | ||
| m_buttons.ZL = src->input0x31.left_trigger > (m_trigger_threshold * UINT8_MAX); | ||
| m_buttons.ZR = src->input0x31.right_trigger > (std::min(m_trigger_threshold * UINT8_MAX, UINT8_MAX - 1.0f)); | ||
| m_buttons.ZL = src->input0x31.left_trigger > (std::min(m_trigger_threshold * UINT8_MAX, UINT8_MAX - 1.0f)); | ||
|
|
||
| if (src->input0x31.buttons.touchpad) { | ||
| for (int i = 0; i < 2; ++i) { | ||
|
|
@@ -310,6 +310,131 @@ namespace ams::controller { | |
| report.output0x31.data[2] = 0x54; | ||
| report.output0x31.data[3] = m_rumble_state.amp_motor_right; | ||
| report.output0x31.data[4] = m_rumble_state.amp_motor_left; | ||
|
|
||
| if (config->misc.dualsense_enable_adaptive_triggers) { | ||
| // Magic numbers that work best after some trial & error | ||
| float trigger_threshold = (std::min(m_trigger_threshold * UINT8_MAX, UINT8_MAX - 1.0f)); | ||
| 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); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| u8 force2 = static_cast<u8>(adaptive_trigger_threshold_end); | ||
|
|
||
| u8 force3 = static_cast<u8>(config->misc.dualsense_adaptive_triggers_resistance / 9.0f * 255.0f); | ||
|
|
||
| // --- Control flags --- | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These comments don't match the project style. Dont use things like |
||
| report.output0x31.data[1] = 0x01 | 0x02 | 0x04 | 0x08; | ||
| report.output0x31.data[2] = 0x01 | 0x04 | 0x10 | 0x40; | ||
|
|
||
| // --- Right trigger --- | ||
|
|
||
| // [Mode] | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Likewise with these. Don't use |
||
| // 0x00 = Off | ||
| // 0x01 = Rigid | ||
| // 0x02 = Pulse | ||
| // 0x20 = Extra A | ||
| // 0x04 = Extra B | ||
| // 0xFC = Calibration | ||
| report.output0x31.data[11] = 0x02; | ||
|
|
||
| // [Force 1] | ||
| // Start of resistance section | ||
| // 0x00 = 0% | ||
| // 0xFF = 100% | ||
| report.output0x31.data[12] = force1; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would assign these directly, rather than creating intermediate |
||
|
|
||
| // [Force 2] | ||
| // (Mode Rigid = Amount of force exerted) | ||
| // (Mode Pulse = End of resistance section) | ||
| // 0x00 = 0% | ||
| // 0xFF = 100% | ||
| report.output0x31.data[13] = force2; | ||
|
|
||
| // [Force 3] | ||
| // (Mode Pulse = Force exerted in range) | ||
| // 0x00 = 0% | ||
| // 0xFF = 100% | ||
| report.output0x31.data[14] = force3; | ||
|
|
||
| // [Force 4] | ||
| // (Mode Extra A & Extra B = Strength of effect near release state) | ||
| // 0x00 = 0% | ||
| // 0xFF = 100% | ||
| report.output0x31.data[15] = 0x00; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to assign unused fields, |
||
|
|
||
| // [Force 5] | ||
| // (Mode Extra A & Extra B = Strength of effect near middle) | ||
| // 0x00 = 0% | ||
| // 0xFF = 100% | ||
| report.output0x31.data[16] = 0x00; | ||
|
|
||
| // [Force 6] | ||
| // (Mode Extra A & Extra B = Strength of effect at pressed state) | ||
| // 0x00 = 0% | ||
| // 0xFF = 100% | ||
| report.output0x31.data[17] = 0x00; | ||
|
|
||
| // [Force 7] | ||
| // (Mode Extra A & Extra B = Effect actuation frequency in Hz) | ||
| // 0x00 = 0% | ||
| // 0xFF = 100% | ||
| report.output0x31.data[20] = 0x00; | ||
|
|
||
| // --- Left trigger --- | ||
|
|
||
| // [Mode] | ||
| // 0x00 = Off | ||
| // 0x01 = Rigid | ||
| // 0x02 = Pulse | ||
| // 0x20 = Extra A | ||
| // 0x04 = Extra B | ||
| // 0xFC = Calibration | ||
| report.output0x31.data[22] = 0x02; | ||
|
|
||
| // [Force 1] | ||
| // Start of resistance section | ||
| // 0x00 = 0% | ||
| // 0xFF = 100% | ||
| report.output0x31.data[23] = force1; | ||
|
|
||
| // [Force 2] | ||
| // (Mode Rigid = Amount of force exerted) | ||
| // (Mode Pulse = End of resistance section) | ||
| // 0x00 = 0% | ||
| // 0xFF = 100% | ||
| report.output0x31.data[24] = force2; | ||
|
|
||
| // [Force 3] | ||
| // (Mode Pulse = Force exerted in range) | ||
| // 0x00 = 0% | ||
| // 0xFF = 100% | ||
| report.output0x31.data[25] = force3; | ||
|
|
||
| // [Force 4] | ||
| // (Mode Extra A & Extra B = Strength of effect near release state) | ||
| // 0x00 = 0% | ||
| // 0xFF = 100% | ||
| report.output0x31.data[26] = 0x00; | ||
|
|
||
| // [Force 5] | ||
| // (Mode Extra A & Extra B = Strength of effect near middle) | ||
| // 0x00 = 0% | ||
| // 0xFF = 100% | ||
| report.output0x31.data[27] = 0x00; | ||
|
|
||
| // [Force 6] | ||
| // (Mode Extra A & Extra B = Strength of effect at pressed state) | ||
| // 0x00 = 0% | ||
| // 0xFF = 100% | ||
| report.output0x31.data[28] = 0x00; | ||
|
|
||
| // [Force 7] | ||
| // (Mode Extra A & Extra B = Effect actuation frequency in Hz) | ||
| // 0x00 = 0% | ||
| // 0xFF = 100% | ||
| report.output0x31.data[31] = 0x00; | ||
| } | ||
|
|
||
| report.output0x31.data[37] = 0x08 - config->misc.dualsense_vibration_intensity; // User setting is inverse of how the controller sets intensity | ||
| report.output0x31.data[39] = 0x02 | 0x01; | ||
| report.output0x31.data[42] = 0x02; | ||
|
|
||
There was a problem hiding this comment.
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.