diff --git a/README.md b/README.md index ff74b32..b7ed8df 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 ad0c02f..5906787 100644 --- a/mc_mitm/config.ini +++ b/mc_mitm/config.ini @@ -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 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 0cb4b5b..4fc8e18 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 22a27f5..38d162f 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 cd0402b..9b0b97e 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 6e66f5d..c44f800 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; };