mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-20 10:56:58 +02:00
controller: cycle DualSense speaker volume, vibration and trigger intensity in game (#946)
* controller: cycle DualSense speaker volume, vibration and trigger intensity in game Three new input mapping controls cycle the PS5's controller settings in game (default keys 1, 2 and 3): speaker volume (100% -> off -> 2% -> 12% -> 42%), vibration intensity and trigger effect intensity (strong -> off -> weak -> medium). Each starts at full and is not saved. Changing vibration or trigger intensity re-sends the game's last rumble and trigger effect, so the change is felt immediately. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Clean up controller settings test captures and formatting --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: nmzik <Nmzik@mail.ru>
This commit is contained in:
committed by
GitHub
parent
e1be2ead54
commit
82a2f4ad42
@@ -311,7 +311,7 @@ bool UsesBluetooth(const Stream* stream) {
|
||||
}
|
||||
|
||||
uint64_t Queue(Stream* stream, int controller, const void* data, uint32_t frames, uint32_t channels,
|
||||
bool is_float, const int* volume) {
|
||||
bool is_float, const int* volume, float gain) {
|
||||
if (stream == nullptr || data == nullptr || frames == 0 || channels == 0 || volume == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
@@ -353,7 +353,7 @@ uint64_t Queue(Stream* stream, int controller, const void* data, uint32_t frames
|
||||
const auto index = (static_cast<size_t>(first_frame) + frame) * channels + src_ch;
|
||||
float value = is_float ? static_cast<const float*>(data)[index]
|
||||
: static_cast<const int16_t*>(data)[index] / 32768.0f;
|
||||
value *= volume[src_ch] / 32768.0f;
|
||||
value *= volume[src_ch] / 32768.0f * gain;
|
||||
// USB places the speaker in front and the actuators in back; Bluetooth takes stereo.
|
||||
stream->buffer[static_cast<size_t>(frame) * output_channels + ch + channel_offset] =
|
||||
value;
|
||||
@@ -382,7 +382,7 @@ uint64_t Queue(Stream* stream, int controller, const void* data, uint32_t frames
|
||||
return queued_us;
|
||||
}
|
||||
|
||||
bool SetVibration(int controller, uint8_t large_motor, uint8_t small_motor) {
|
||||
bool SetVibration(int controller, uint8_t large_motor, uint8_t small_motor, uint32_t duration_ms) {
|
||||
if (SDL_GetGamepadTypeForID(static_cast<SDL_JoystickID>(controller)) != SDL_GAMEPAD_TYPE_PS5) {
|
||||
return false;
|
||||
}
|
||||
@@ -390,7 +390,7 @@ bool SetVibration(int controller, uint8_t large_motor, uint8_t small_motor) {
|
||||
SelectController(controller);
|
||||
g_large_motor = large_motor;
|
||||
g_small_motor = small_motor;
|
||||
g_rumble_until = SDL_GetTicks() + 0xffff;
|
||||
g_rumble_until = SDL_GetTicks() + duration_ms;
|
||||
ApplyRumble();
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user