From c16697e89ba18fc57c6d5bc40dc3559b1e1bc199 Mon Sep 17 00:00:00 2001 From: Josh birnholz Date: Mon, 1 Apr 2024 16:15:56 -0400 Subject: [PATCH 1/2] Add alternate touchpad mapping --- README.md | 2 + mc_mitm/config.ini | 60 ++++++++++--------- .../controllers/dualsense_controller.cpp | 23 +++++-- .../controllers/dualshock4_controller.cpp | 55 ++++++++++------- mc_mitm/source/mcmitm_config.cpp | 8 ++- mc_mitm/source/mcmitm_config.hpp | 2 + 6 files changed, 93 insertions(+), 57 deletions(-) diff --git a/README.md b/README.md index c41f98a8..7c44be1c 100644 --- a/README.md +++ b/README.md @@ -151,6 +151,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%. + - `enable_dualsense_mute_button` Enable the DualSense microphone mute button to be mapped to the Capture button (enabled by default). + - `swap_touchpad_button` Enables an alternate mapping for DualSense and DualShock 4 controllers so that the touchpad=minus and share=capture. ### Removal diff --git a/mc_mitm/config.ini b/mc_mitm/config.ini index ad0c02f9..ffa8705e 100644 --- a/mc_mitm/config.ini +++ b/mc_mitm/config.ini @@ -1,28 +1,32 @@ -[general] -; Enable vibration support for unofficial controllers [default true] -;enable_rumble=true -; Enable motion controls support for unoffical controllers [default true] -;enable_motion=true - -[bluetooth] -; Override host name of Bluetooth adapter -;host_name=Nintendo Switch! -; Override host mac address of Bluetooth adapter -;host_address=04:20:69:04:20:69 - -[misc] -; Set the threshold for which ZL/ZR are considered pressed for controllers with analog triggers. Valid range [0-100] percent [default 50] -;analog_trigger_activation_threshold=50 -; Set Dualshock 3 player LED behaviour. Valid modes [0-2] where 0=Switch pattern, 1=PS3 pattern, 2=Hybrid (Switch pattern reversed to line up with numeric labels on the controller) [default 0] -;dualshock3_led_mode=0 -; Set polling rate for Sony Dualshock 4 controllers. Valid range [0-16] where 0=max, 16=min [default 8 (125Hz)] -; Refer to https://github.com/ndeadly/MissionControl/blob/4a0326308d1ff39353b045f5efb1a99c4a504c28/mc_mitm/source/controllers/dualshock4_controller.hpp#L21 -;dualshock4_polling_rate=8 -; Set LED lightbar brightness for Sony Dualshock 4 controllers. Valid range [0-9] where 0=off, 1=min, 2-9=12.5-100% [default 5(50%)] -;dualshock4_lightbar_brightness=4 -; Set LED lightbar brightness for Sony Dualsense controllers. Valid range [0-9] where 0=off, 1=min, 2-9=12.5-100% [default 5(50%)] -;dualsense_lightbar_brightness=4 -; Enable the white player indicator LEDs below the Dualsense touchpad [default true] -;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 +[general] +; Enable vibration support for unofficial controllers [default true] +;enable_rumble=true +; Enable motion controls support for unoffical controllers [default true] +;enable_motion=true + +[bluetooth] +; Override host name of Bluetooth adapter +;host_name=Nintendo Switch! +; Override host mac address of Bluetooth adapter +;host_address=04:20:69:04:20:69 + +[misc] +; Set the threshold for which ZL/ZR are considered pressed for controllers with analog triggers. Valid range [0-100] percent [default 50] +;analog_trigger_activation_threshold=50 +; Set Dualshock 3 player LED behaviour. Valid modes [0-2] where 0=Switch pattern, 1=PS3 pattern, 2=Hybrid (Switch pattern reversed to line up with numeric labels on the controller) [default 0] +;dualshock3_led_mode=0 +; Set polling rate for Sony Dualshock 4 controllers. Valid range [0-16] where 0=max, 16=min [default 8 (125Hz)] +; Refer to https://github.com/ndeadly/MissionControl/blob/4a0326308d1ff39353b045f5efb1a99c4a504c28/mc_mitm/source/controllers/dualshock4_controller.hpp#L21 +;dualshock4_polling_rate=8 +; Set LED lightbar brightness for Sony Dualshock 4 controllers. Valid range [0-9] where 0=off, 1=min, 2-9=12.5-100% [default 5(50%)] +;dualshock4_lightbar_brightness=4 +; Set LED lightbar brightness for Sony Dualsense controllers. Valid range [0-9] where 0=off, 1=min, 2-9=12.5-100% [default 5(50%)] +;dualsense_lightbar_brightness=4 +; Enable the white player indicator LEDs below the Dualsense touchpad [default true] +;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 the DualSense microphone mute button to be mapped to the Capture button [default true] +;enable_dualsense_mute_button=true +; Enables an alternate mapping for the touchpad and share buttons on DualSense and DualShock 4 controllers so that the touchpad=minus and share=capture +;swap_touchpad_button=false diff --git a/mc_mitm/source/controllers/dualsense_controller.cpp b/mc_mitm/source/controllers/dualsense_controller.cpp index 906d917e..ca5f5c71 100644 --- a/mc_mitm/source/controllers/dualsense_controller.cpp +++ b/mc_mitm/source/controllers/dualsense_controller.cpp @@ -180,7 +180,8 @@ namespace ams::controller { m_buttons.ZR = src->input0x31.right_trigger > (m_trigger_threshold * TriggerMax); m_buttons.ZL = src->input0x31.left_trigger > (m_trigger_threshold * TriggerMax); - if (src->input0x31.buttons.touchpad) { + auto config = mitm::GetGlobalConfig(); + if (!config->misc.swap_touchpad_button && src->input0x31.buttons.touchpad) { for (int i = 0; i < 2; ++i) { const DualsenseTouchpadPoint *point = &src->input0x31.touch_points[i]; @@ -255,14 +256,24 @@ namespace ams::controller { m_buttons.R = buttons->R1; m_buttons.L = buttons->L1; - m_buttons.minus = buttons->share; - m_buttons.plus = buttons->options; - m_buttons.lstick_press = buttons->L3; m_buttons.rstick_press = buttons->R3; - m_buttons.capture = buttons->mute; - m_buttons.home = buttons->ps; + m_buttons.home = buttons->ps; + + auto config = mitm::GetGlobalConfig(); + if (config->misc.swap_touchpad_button) { + m_buttons.capture = buttons->share; + m_buttons.plus = buttons->options; + m_buttons.minus = buttons->touchpad; + } else { + m_buttons.minus = buttons->share; + m_buttons.plus = buttons->options; + } + + if (config->misc.enable_dualsense_mute_button) { + m_buttons.capture = buttons->mute; + } } Result DualsenseController::GetVersionInfo(DualsenseVersionInfo *version_info) { diff --git a/mc_mitm/source/controllers/dualshock4_controller.cpp b/mc_mitm/source/controllers/dualshock4_controller.cpp index 06709a07..8f8c662a 100644 --- a/mc_mitm/source/controllers/dualshock4_controller.cpp +++ b/mc_mitm/source/controllers/dualshock4_controller.cpp @@ -143,28 +143,32 @@ namespace ams::controller { m_buttons.ZR = src->input0x11.right_trigger > (m_trigger_threshold * TriggerMax); m_buttons.ZL = src->input0x11.left_trigger > (m_trigger_threshold * TriggerMax); - if (src->input0x11.buttons.touchpad) { - for (int i = 0; i < src->input0x11.num_reports; ++i) { - const Dualshock4TouchReport *touch_report = &src->input0x11.touch_reports[i]; - for (int j = 0; j < 2; ++j) { - const Dualshock4TouchpadPoint *point = &touch_report->points[j]; - - bool active = point->contact & BIT(7) ? false : true; - if (active) { - u16 x = (point->x_hi << 8) | point->x_lo; - - if (x < (0.15 * TouchpadWidth)) { - m_buttons.minus = 1; - } else if (x > (0.85 * TouchpadWidth)) { - m_buttons.plus = 1; - } else { - m_buttons.capture = 1; + + auto config = mitm::GetGlobalConfig(); + if (!config->misc.swap_touchpad_button) { + if (src->input0x11.buttons.touchpad) { + for (int i = 0; i < src->input0x11.num_reports; ++i) { + const Dualshock4TouchReport *touch_report = &src->input0x11.touch_reports[i]; + for (int j = 0; j < 2; ++j) { + const Dualshock4TouchpadPoint *point = &touch_report->points[j]; + + bool active = point->contact & BIT(7) ? false : true; + if (active) { + u16 x = (point->x_hi << 8) | point->x_lo; + + if (x < (0.15 * TouchpadWidth)) { + m_buttons.minus = 1; + } else if (x > (0.85 * TouchpadWidth)) { + m_buttons.plus = 1; + } else { + m_buttons.capture = 1; + } } } } + } else { + m_buttons.capture = 0; } - } else { - m_buttons.capture = 0; } if (m_enable_motion) { @@ -225,13 +229,20 @@ namespace ams::controller { m_buttons.L = buttons->L1; m_buttons.ZL = buttons->L2; - m_buttons.minus = buttons->share; - m_buttons.plus = buttons->options; - m_buttons.lstick_press = buttons->L3; m_buttons.rstick_press = buttons->R3; - m_buttons.home = buttons->ps; + m_buttons.home = buttons->ps; + + auto config = mitm::GetGlobalConfig(); + if (config->misc.swap_touchpad_button) { + m_buttons.capture = buttons->share; + m_buttons.plus = buttons->options; + m_buttons.minus = buttons->touchpad; + } else { + m_buttons.minus = buttons->share; + m_buttons.plus = buttons->options; + } } Result Dualshock4Controller::GetVersionInfo(Dualshock4VersionInfo *version_info) { diff --git a/mc_mitm/source/mcmitm_config.cpp b/mc_mitm/source/mcmitm_config.cpp index cd0402b3..9b0b97e7 100644 --- a/mc_mitm/source/mcmitm_config.cpp +++ b/mc_mitm/source/mcmitm_config.cpp @@ -36,7 +36,9 @@ namespace ams::mitm { .dualshock4_lightbar_brightness = 5, .dualsense_lightbar_brightness = 5, .dualsense_enable_player_leds = true, - .dualsense_vibration_intensity = 4 + .dualsense_vibration_intensity = 4, + .enable_dualsense_mute_button = true, + .swap_touchpad_button = false } }; @@ -107,6 +109,10 @@ namespace ams::mitm { ParseBoolean(value, &config->misc.dualsense_enable_player_leds); } else if (strcasecmp(name, "dualsense_vibration_intensity") == 0) { ParseInt(value, &config->misc.dualsense_vibration_intensity, 1, 8); + } else if (strcasecmp(name, "enable_dualsense_mute_button") == 0) { + ParseBoolean(value, &config->misc.enable_dualsense_mute_button); + } else if (strcasecmp(name, "swap_touchpad_button") == 0) { + ParseBoolean(value, &config->misc.swap_touchpad_button); } } else { return 0; diff --git a/mc_mitm/source/mcmitm_config.hpp b/mc_mitm/source/mcmitm_config.hpp index 6e66f5d5..c44f800a 100644 --- a/mc_mitm/source/mcmitm_config.hpp +++ b/mc_mitm/source/mcmitm_config.hpp @@ -36,6 +36,8 @@ namespace ams::mitm { int dualsense_lightbar_brightness; bool dualsense_enable_player_leds; int dualsense_vibration_intensity; + bool enable_dualsense_mute_button; + bool swap_touchpad_button; } misc; }; From f311268d575b71c803f5cac9225986b68ac2ae01 Mon Sep 17 00:00:00 2001 From: Josh birnholz Date: Mon, 1 Apr 2024 16:20:42 -0400 Subject: [PATCH 2/2] Fix config.ini --- mc_mitm/config.ini | 64 +++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/mc_mitm/config.ini b/mc_mitm/config.ini index ffa8705e..59067875 100644 --- a/mc_mitm/config.ini +++ b/mc_mitm/config.ini @@ -1,32 +1,32 @@ -[general] -; Enable vibration support for unofficial controllers [default true] -;enable_rumble=true -; Enable motion controls support for unoffical controllers [default true] -;enable_motion=true - -[bluetooth] -; Override host name of Bluetooth adapter -;host_name=Nintendo Switch! -; Override host mac address of Bluetooth adapter -;host_address=04:20:69:04:20:69 - -[misc] -; Set the threshold for which ZL/ZR are considered pressed for controllers with analog triggers. Valid range [0-100] percent [default 50] -;analog_trigger_activation_threshold=50 -; Set Dualshock 3 player LED behaviour. Valid modes [0-2] where 0=Switch pattern, 1=PS3 pattern, 2=Hybrid (Switch pattern reversed to line up with numeric labels on the controller) [default 0] -;dualshock3_led_mode=0 -; Set polling rate for Sony Dualshock 4 controllers. Valid range [0-16] where 0=max, 16=min [default 8 (125Hz)] -; Refer to https://github.com/ndeadly/MissionControl/blob/4a0326308d1ff39353b045f5efb1a99c4a504c28/mc_mitm/source/controllers/dualshock4_controller.hpp#L21 -;dualshock4_polling_rate=8 -; Set LED lightbar brightness for Sony Dualshock 4 controllers. Valid range [0-9] where 0=off, 1=min, 2-9=12.5-100% [default 5(50%)] -;dualshock4_lightbar_brightness=4 -; Set LED lightbar brightness for Sony Dualsense controllers. Valid range [0-9] where 0=off, 1=min, 2-9=12.5-100% [default 5(50%)] -;dualsense_lightbar_brightness=4 -; Enable the white player indicator LEDs below the Dualsense touchpad [default true] -;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 the DualSense microphone mute button to be mapped to the Capture button [default true] -;enable_dualsense_mute_button=true -; Enables an alternate mapping for the touchpad and share buttons on DualSense and DualShock 4 controllers so that the touchpad=minus and share=capture -;swap_touchpad_button=false +[general] +; Enable vibration support for unofficial controllers [default true] +;enable_rumble=true +; Enable motion controls support for unoffical controllers [default true] +;enable_motion=true + +[bluetooth] +; Override host name of Bluetooth adapter +;host_name=Nintendo Switch! +; Override host mac address of Bluetooth adapter +;host_address=04:20:69:04:20:69 + +[misc] +; Set the threshold for which ZL/ZR are considered pressed for controllers with analog triggers. Valid range [0-100] percent [default 50] +;analog_trigger_activation_threshold=50 +; Set Dualshock 3 player LED behaviour. Valid modes [0-2] where 0=Switch pattern, 1=PS3 pattern, 2=Hybrid (Switch pattern reversed to line up with numeric labels on the controller) [default 0] +;dualshock3_led_mode=0 +; Set polling rate for Sony Dualshock 4 controllers. Valid range [0-16] where 0=max, 16=min [default 8 (125Hz)] +; Refer to https://github.com/ndeadly/MissionControl/blob/4a0326308d1ff39353b045f5efb1a99c4a504c28/mc_mitm/source/controllers/dualshock4_controller.hpp#L21 +;dualshock4_polling_rate=8 +; Set LED lightbar brightness for Sony Dualshock 4 controllers. Valid range [0-9] where 0=off, 1=min, 2-9=12.5-100% [default 5(50%)] +;dualshock4_lightbar_brightness=4 +; Set LED lightbar brightness for Sony Dualsense controllers. Valid range [0-9] where 0=off, 1=min, 2-9=12.5-100% [default 5(50%)] +;dualsense_lightbar_brightness=4 +; Enable the white player indicator LEDs below the Dualsense touchpad [default true] +;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 the DualSense microphone mute button to be mapped to the Capture button [default true] +;enable_dualsense_mute_button=true +; Enables an alternate mapping for the touchpad and share buttons on DualSense and DualShock 4 controllers so that the touchpad=minus and share=capture +;swap_touchpad_button=false