Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions mc_mitm/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
23 changes: 17 additions & 6 deletions mc_mitm/source/controllers/dualsense_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down Expand Up @@ -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) {
Expand Down
55 changes: 33 additions & 22 deletions mc_mitm/source/controllers/dualshock4_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
8 changes: 7 additions & 1 deletion mc_mitm/source/mcmitm_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
};

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions mc_mitm/source/mcmitm_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down