mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-20 10:56:58 +02:00
audio: play DualSense haptics from vibration audio ports (#843)
* audio: play DualSense haptics from vibration audio ports Games drive the DualSense's actuators through a vibration audio port, one channel per actuator. These ports had no device, so their samples were dropped. Over USB the DualSense is a 4-channel audio device whose back channels feed the actuators; play the port's samples there through SDL. The device is looked up while the port plays, so the controller can be connected at any time. The queue keeps about the latency of the regular audio path, with the playback rate nudged by up to 3% when the port is fed off real time. While haptic audio plays, hold a DualSense's rumble at zero: SDL disables audio haptics whenever rumble is non-zero. Add pad_haptics tests for the sample conversion, device-name matching and rate correction. * Simplify DualSense audio haptics and restore idle rumble --------- Co-authored-by: nmzik <Nmzik@mail.ru>
This commit is contained in:
committed by
GitHub
parent
81f312638f
commit
a22a9d9348
@@ -8,6 +8,7 @@
|
||||
#include "common/stringUtils.h"
|
||||
#include "common/threads.h"
|
||||
#include "kernel/pthread.h"
|
||||
#include "libs/dualSenseHaptics.h"
|
||||
#include "libs/errno.h"
|
||||
#include "libs/libs.h"
|
||||
#include "libs/padData.h"
|
||||
@@ -113,6 +114,7 @@ public:
|
||||
void ReleaseHostPads();
|
||||
void GetConnectionInfo(bool* flag, int* count);
|
||||
void SetVibration(uint8_t large_motor, uint8_t small_motor);
|
||||
int GetActiveControllerId();
|
||||
void SetLightBar(uint8_t r, uint8_t g, uint8_t b);
|
||||
bool SetTriggerEffect(const PadTriggerEffectParam& param);
|
||||
void ReadState(ControllerState* state, bool* flag, int* count);
|
||||
@@ -518,6 +520,7 @@ void GameController::ResetInputState() {
|
||||
|
||||
void GameController::ReleaseHostPads() {
|
||||
Common::LockGuard lock(m_mutex);
|
||||
DualSenseHaptics::Shutdown();
|
||||
|
||||
std::vector<SDL_Gamepad*> pads;
|
||||
for (const auto id: m_connected_ids) {
|
||||
@@ -551,6 +554,9 @@ void GameController::ReleaseHostPads() {
|
||||
|
||||
void GameController::SetVibration(uint8_t large_motor, uint8_t small_motor) {
|
||||
Common::LockGuard lock(m_mutex);
|
||||
if (DualSenseHaptics::SetVibration(m_active_id, large_motor, small_motor)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_active_id == HOST_INPUT_CONTROLLER_ID) {
|
||||
return;
|
||||
@@ -568,6 +574,11 @@ void GameController::SetVibration(uint8_t large_motor, uint8_t small_motor) {
|
||||
}
|
||||
}
|
||||
|
||||
int GameController::GetActiveControllerId() {
|
||||
Common::LockGuard lock(m_mutex);
|
||||
return m_active_id;
|
||||
}
|
||||
|
||||
void GameController::SetLightBar(uint8_t r, uint8_t g, uint8_t b) {
|
||||
Common::LockGuard lock(m_mutex);
|
||||
if (auto* pad = SDL_GetGamepadFromID(static_cast<SDL_JoystickID>(m_active_id));
|
||||
@@ -692,6 +703,10 @@ void ResetInputState() {
|
||||
g_controller->ResetInputState();
|
||||
}
|
||||
|
||||
int GetActiveControllerId() {
|
||||
return g_controller != nullptr ? g_controller->GetActiveControllerId() : -1;
|
||||
}
|
||||
|
||||
int KYTY_SYSV_ABI PadInit() {
|
||||
PRINT_NAME();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user