From 7a490b5aaea1d8cd26e042eb9f681d5a05df98c5 Mon Sep 17 00:00:00 2001 From: Johannes Baiter Date: Mon, 21 Nov 2022 20:21:43 +0100 Subject: [PATCH] Fix feedback state position 0x1b when DualSense is connected. The previous value of `0` caused the PS5 to expect a set of 'trigger status' values in the 0x19 and 0x1a position, which would have required reading raw values from the DualSense HID device, since these values are not reported by the SDL DualSense driver (code that does so can be checked out from the `trigger-feedback` branch on https://git.sr.ht/~jbaiter/chiaki). Fortunately this is not neccessary, simply setting the value to `1` seems to make the PS5 to rely on fallback logic (presumably based on the L2/R2 value) and games that would otherwise have relied on the trigger status (Astro's Playroom climbing levels) now work without any problems. --- lib/include/chiaki/feedback.h | 2 +- lib/src/feedback.c | 8 ++++++-- lib/src/takion.c | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/include/chiaki/feedback.h b/lib/include/chiaki/feedback.h index d0be7a1..be66384 100644 --- a/lib/include/chiaki/feedback.h +++ b/lib/include/chiaki/feedback.h @@ -38,7 +38,7 @@ CHIAKI_EXPORT void chiaki_feedback_state_format_v9(uint8_t *buf, ChiakiFeedbackS /** * @param buf buffer of at least CHIAKI_FEEDBACK_STATE_BUF_SIZE_V12 */ -CHIAKI_EXPORT void chiaki_feedback_state_format_v12(uint8_t *buf, ChiakiFeedbackState *state, bool enable_dualsense); +CHIAKI_EXPORT void chiaki_feedback_state_format_v12(uint8_t *buf, ChiakiFeedbackState *state); #define CHIAKI_HISTORY_EVENT_SIZE_MAX 0x5 diff --git a/lib/src/feedback.c b/lib/src/feedback.c index d585a88..6db8364 100644 --- a/lib/src/feedback.c +++ b/lib/src/feedback.c @@ -76,12 +76,16 @@ CHIAKI_EXPORT void chiaki_feedback_state_format_v9(uint8_t *buf, ChiakiFeedbackS *((chiaki_unaligned_uint16_t *)(buf + 0x17)) = htons((uint16_t)state->right_y); } -CHIAKI_EXPORT void chiaki_feedback_state_format_v12(uint8_t *buf, ChiakiFeedbackState *state, bool enable_dualsense) +CHIAKI_EXPORT void chiaki_feedback_state_format_v12(uint8_t *buf, ChiakiFeedbackState *state) { chiaki_feedback_state_format_v9(buf, state); buf[0x19] = 0x0; buf[0x1a] = 0x0; - buf[0x1b] = enable_dualsense ? 0x0 : 0x1; + + // 1 is classic DualShock, 0 is DualSense, but using 0 requires setting [0x19] and [0x1a] to + // values taken from raw HID, which is generally not available. But setting 1 for both seems + // to always work fine. + buf[0x1b] = 0x1; } CHIAKI_EXPORT ChiakiErrorCode chiaki_feedback_history_event_set_button(ChiakiFeedbackHistoryEvent *event, uint64_t button, uint8_t state) diff --git a/lib/src/takion.c b/lib/src/takion.c index f786d6f..baae28c 100644 --- a/lib/src/takion.c +++ b/lib/src/takion.c @@ -558,7 +558,7 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_takion_send_feedback_state(ChiakiTakion *ta else { buf_sz = 0xc + CHIAKI_FEEDBACK_STATE_BUF_SIZE_V12; - chiaki_feedback_state_format_v12(buf + 0xc, feedback_state, takion->enable_dualsense); + chiaki_feedback_state_format_v12(buf + 0xc, feedback_state); } return takion_send_feedback_packet(takion, buf, buf_sz); }