Merge branch 'shadps4-emu:main' into main

This commit is contained in:
Daniel Nylander 2025-02-06 09:07:00 +01:00 committed by GitHub
commit 1a1e0690b1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 17 deletions

View File

@ -60,7 +60,7 @@ inline int GetAxis(int min, int max, int value) {
return std::clamp((255 * (value - min)) / (max - min), 0, 255);
}
constexpr u32 MAX_STATES = 64;
constexpr u32 MAX_STATES = 32;
class GameController {
public:

View File

@ -448,7 +448,6 @@ void ControllerOutput::ResetUpdate() {
*new_param = 0; // bruh
}
void ControllerOutput::AddUpdate(InputEvent event) {
state_changed = true;
if (button == KEY_TOGGLE) {
if (event.active) {
ToggleKeyInList(event.input);
@ -465,24 +464,14 @@ void ControllerOutput::AddUpdate(InputEvent event) {
}
} else if (axis != SDL_GAMEPAD_AXIS_INVALID) {
switch (axis) {
case SDL_GAMEPAD_AXIS_LEFT_TRIGGER:
case SDL_GAMEPAD_AXIS_RIGHT_TRIGGER:
// if it's a button input, then we know the value to set, so the param is 0.
// if it's an analog input, then the param isn't 0
*new_param = (event.active ? event.axis_value : 0) + *new_param;
break;
default:
*new_param = (event.active ? event.axis_value : 0) + *new_param;
break;
}
*new_param = (event.active ? event.axis_value : 0) + *new_param;
}
}
void ControllerOutput::FinalizeUpdate() {
state_changed = old_button_state != new_button_state || old_param != *new_param;
if (!state_changed) {
// return;
return;
}
old_button_state = new_button_state;
old_param = *new_param;
float touchpad_x = 0;
@ -511,8 +500,6 @@ void ControllerOutput::FinalizeUpdate() {
}
} else if (axis != SDL_GAMEPAD_AXIS_INVALID && positive_axis) {
// avoid double-updating axes, but don't skip directional button bindings
float multiplier = 1.0;
int deadzone = 0;
auto ApplyDeadzone = [](s16* value, std::pair<int, int> deadzone) {
if (std::abs(*value) <= deadzone.first || deadzone.first == deadzone.second) {
*value = 0;
@ -523,6 +510,7 @@ void ControllerOutput::FinalizeUpdate() {
0, 128);
}
};
float multiplier = 1.0;
Axis c_axis = GetAxisFromSDLAxis(axis);
switch (c_axis) {
case Axis::LeftX:
@ -572,6 +560,10 @@ bool UpdatePressedKeys(InputEvent event) {
pressed_keys.insert(it, {event, false});
LOG_DEBUG(Input, "Added axis {} to the input list", event.input.sdl_id);
} else {
// noise filter
if (std::abs(it->first.axis_value - event.axis_value) <= 1) {
return false;
}
it->first.axis_value = event.axis_value;
}
return true;