mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-04 08:22:32 +00:00
Possible fix for Gravity Rush
This commit is contained in:
parent
5b6da2b0ab
commit
3466de0dc0
@ -302,90 +302,70 @@ void ToggleKeyInList(u32 key) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControllerOutput::Update(bool pressed, u32 param) {
|
void ControllerOutput::ResetUpdate() {
|
||||||
float touchpad_x = 0;
|
state_changed = false;
|
||||||
if (button != 0) {
|
if (button != 0) {
|
||||||
switch (button) {
|
switch (button) {
|
||||||
case OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_TOUCH_PAD:
|
|
||||||
touchpad_x = Config::getBackButtonBehavior() == "left" ? 0.25f
|
|
||||||
: Config::getBackButtonBehavior() == "right" ? 0.75f
|
|
||||||
: 0.5f;
|
|
||||||
controller->SetTouchpadState(0, true, touchpad_x, 0.5f);
|
|
||||||
controller->CheckButton(0, button, pressed);
|
|
||||||
break;
|
|
||||||
case LEFTJOYSTICK_HALFMODE:
|
|
||||||
leftjoystick_halfmode = pressed;
|
|
||||||
break;
|
|
||||||
case RIGHTJOYSTICK_HALFMODE:
|
|
||||||
rightjoystick_halfmode = pressed;
|
|
||||||
break;
|
|
||||||
case KEY_TOGGLE:
|
case KEY_TOGGLE:
|
||||||
if (pressed) {
|
|
||||||
ToggleKeyInList(param);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default: // is a normal key (hopefully)
|
default: // everything else
|
||||||
controller->CheckButton(0, button, pressed);
|
new_button_state = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (axis != Axis::AxisMax) {
|
} else if (axis != Axis::AxisMax) {
|
||||||
float multiplier = 1.0;
|
new_param = 0;
|
||||||
switch (axis) {
|
|
||||||
case Axis::LeftX:
|
|
||||||
case Axis::LeftY:
|
|
||||||
multiplier = leftjoystick_halfmode ? 0.5 : 1.0;
|
|
||||||
// LOG_DEBUG(Input, "Joystick multiplier set to {}", multiplier);
|
|
||||||
break;
|
|
||||||
case Axis::RightX:
|
|
||||||
case Axis::RightY:
|
|
||||||
multiplier = rightjoystick_halfmode ? 0.5 : 1.0;
|
|
||||||
// LOG_DEBUG(Input, "Joystick multiplier set to {}", multiplier);
|
|
||||||
break;
|
|
||||||
case Axis::TriggerLeft:
|
|
||||||
case Axis::TriggerRight:
|
|
||||||
// todo: verify this works (This probably works from testing,
|
|
||||||
// but needs extra info (multiple input to the same trigger?))
|
|
||||||
axis_value = SDL_clamp((pressed ? (s32)param : 0), 0, 127);
|
|
||||||
controller->Axis(0, axis, GetAxis(0, 0x80, axis_value));
|
|
||||||
return;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
axis_value = SDL_clamp((pressed ? (s32)param : 0), -127, 127);
|
|
||||||
int ax = GetAxis(-0x80, 0x80, axis_value * multiplier);
|
|
||||||
controller->Axis(0, axis, ax);
|
|
||||||
} else {
|
} else {
|
||||||
LOG_DEBUG(Input, "Controller output with no values detected!");
|
LOG_DEBUG(Input, "Controller output with no values detected!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void ControllerOutput::AddUpdate(bool pressed, u32 param) {
|
void ControllerOutput::AddUpdate(bool pressed, u32 param) {
|
||||||
|
state_changed = true;
|
||||||
|
if (button != 0) {
|
||||||
|
new_button_state |= pressed;
|
||||||
|
} else if (axis != Axis::AxisMax) {
|
||||||
|
float multiplier = 1.0;
|
||||||
|
switch (axis) {
|
||||||
|
case Axis::TriggerLeft:
|
||||||
|
case Axis::TriggerRight:
|
||||||
|
new_param = SDL_clamp((pressed ? (s32)param : 0) + new_param, 0, 127);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
new_param = SDL_clamp((pressed ? (s32)param : 0) + new_param, -127, 127);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
LOG_DEBUG(Input, "Controller output with no values detected!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void ControllerOutput::FinalizeUpdate() {
|
||||||
|
if(!state_changed || (old_button_state == new_button_state && old_param == new_param)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
old_button_state = new_button_state;
|
||||||
|
old_param = new_param;
|
||||||
float touchpad_x = 0;
|
float touchpad_x = 0;
|
||||||
if (button != 0) {
|
if (button != 0) {
|
||||||
if (!pressed) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
switch (button) {
|
switch (button) {
|
||||||
case OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_TOUCH_PAD:
|
case OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_TOUCH_PAD:
|
||||||
touchpad_x = Config::getBackButtonBehavior() == "left" ? 0.25f
|
touchpad_x = Config::getBackButtonBehavior() == "left" ? 0.25f
|
||||||
: Config::getBackButtonBehavior() == "right" ? 0.75f
|
: Config::getBackButtonBehavior() == "right" ? 0.75f
|
||||||
: 0.5f;
|
: 0.5f;
|
||||||
controller->SetTouchpadState(0, true, touchpad_x, 0.5f);
|
controller->SetTouchpadState(0, true, touchpad_x, 0.5f);
|
||||||
controller->CheckButton(0, button, pressed);
|
controller->CheckButton(0, button, new_button_state);
|
||||||
break;
|
break;
|
||||||
case LEFTJOYSTICK_HALFMODE:
|
case LEFTJOYSTICK_HALFMODE:
|
||||||
leftjoystick_halfmode |= pressed;
|
leftjoystick_halfmode = new_button_state;
|
||||||
break;
|
break;
|
||||||
case RIGHTJOYSTICK_HALFMODE:
|
case RIGHTJOYSTICK_HALFMODE:
|
||||||
rightjoystick_halfmode |= pressed;
|
rightjoystick_halfmode = new_button_state;
|
||||||
break;
|
break;
|
||||||
case KEY_TOGGLE:
|
case KEY_TOGGLE:
|
||||||
if (pressed) {
|
if (new_button_state) {
|
||||||
ToggleKeyInList(param);
|
ToggleKeyInList(new_param);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default: // is a normal key (hopefully)
|
default: // is a normal key (hopefully)
|
||||||
controller->CheckButton(0, button, pressed);
|
controller->CheckButton(0, button, new_button_state);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (axis != Axis::AxisMax) {
|
} else if (axis != Axis::AxisMax) {
|
||||||
@ -394,26 +374,19 @@ void ControllerOutput::AddUpdate(bool pressed, u32 param) {
|
|||||||
case Axis::LeftX:
|
case Axis::LeftX:
|
||||||
case Axis::LeftY:
|
case Axis::LeftY:
|
||||||
multiplier = leftjoystick_halfmode ? 0.5 : 1.0;
|
multiplier = leftjoystick_halfmode ? 0.5 : 1.0;
|
||||||
LOG_DEBUG(Input, "Left joystick multiplier set to {}", multiplier);
|
|
||||||
break;
|
break;
|
||||||
case Axis::RightX:
|
case Axis::RightX:
|
||||||
case Axis::RightY:
|
case Axis::RightY:
|
||||||
multiplier = rightjoystick_halfmode ? 0.5 : 1.0;
|
multiplier = rightjoystick_halfmode ? 0.5 : 1.0;
|
||||||
LOG_DEBUG(Input, " Right joystick multiplier set to {}", multiplier);
|
|
||||||
break;
|
break;
|
||||||
case Axis::TriggerLeft:
|
case Axis::TriggerLeft:
|
||||||
case Axis::TriggerRight:
|
case Axis::TriggerRight:
|
||||||
// todo: verify this works
|
controller->Axis(0, axis, GetAxis(0, 0x80, new_param));
|
||||||
axis_value = SDL_clamp((pressed ? (s32)param : 0) + axis_value, 0, 127);
|
|
||||||
controller->Axis(0, axis, GetAxis(0, 0x80, axis_value));
|
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
axis_value = SDL_clamp(((pressed ? (s32)param : 0) + axis_value), -127, 127);
|
controller->Axis(0, axis, GetAxis(-0x80, 0x80, new_param * multiplier));
|
||||||
controller->Axis(0, axis, GetAxis(-0x80, 0x80, axis_value * multiplier));
|
|
||||||
// LOG_INFO(Input, "Axis value delta: {} final value: {}", (pressed ? a_value : 0),
|
|
||||||
// axis_value);
|
|
||||||
} else {
|
} else {
|
||||||
LOG_DEBUG(Input, "Controller output with no values detected!");
|
LOG_DEBUG(Input, "Controller output with no values detected!");
|
||||||
}
|
}
|
||||||
@ -494,25 +467,20 @@ bool IsInputActive(const InputBinding& i) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ActivateOutputsFromInputs() {
|
void ActivateOutputsFromInputs() {
|
||||||
// reset everything
|
|
||||||
for (auto& it : pressed_keys) {
|
for (auto& it : pressed_keys) {
|
||||||
it.second = false;
|
it.second = false;
|
||||||
}
|
}
|
||||||
for (auto it = connections.begin(); it != connections.end(); it++) {
|
|
||||||
if (it->output) {
|
// this is the cleanest looking code I've ever written, too bad it is not working
|
||||||
it->output->Update(false, 0);
|
for (auto& it : output_array) {
|
||||||
} else {
|
it.ResetUpdate();
|
||||||
LOG_DEBUG(Input, "Null output in BindingConnection at position {}",
|
|
||||||
std::distance(connections.begin(), it));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// iterates over the connections, and updates them depending on whether the corresponding input
|
|
||||||
// trio is found
|
|
||||||
for (auto& it : connections) {
|
for (auto& it : connections) {
|
||||||
if (it.output) {
|
it.output->AddUpdate(IsInputActive(it.binding), it.parameter);
|
||||||
bool active = IsInputActive(it.binding);
|
}
|
||||||
it.output->AddUpdate(active, it.parameter);
|
for (auto& it : output_array) {
|
||||||
}
|
it.FinalizeUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,12 +263,13 @@ public:
|
|||||||
|
|
||||||
u32 button;
|
u32 button;
|
||||||
Axis axis;
|
Axis axis;
|
||||||
int axis_value;
|
int old_param, new_param;
|
||||||
|
bool old_button_state, new_button_state, state_changed;
|
||||||
|
|
||||||
ControllerOutput(const u32 b, Axis a = Axis::AxisMax) {
|
ControllerOutput(const u32 b, Axis a = Axis::AxisMax) {
|
||||||
button = b;
|
button = b;
|
||||||
axis = a;
|
axis = a;
|
||||||
axis_value = 0;
|
old_param = 0;
|
||||||
}
|
}
|
||||||
ControllerOutput(const ControllerOutput& o) : button(o.button), axis(o.axis) {}
|
ControllerOutput(const ControllerOutput& o) : button(o.button), axis(o.axis) {}
|
||||||
inline bool operator==(const ControllerOutput& o) const { // fucking consts everywhere
|
inline bool operator==(const ControllerOutput& o) const { // fucking consts everywhere
|
||||||
@ -278,7 +279,7 @@ public:
|
|||||||
return button != o.button || axis != o.axis;
|
return button != o.button || axis != o.axis;
|
||||||
}
|
}
|
||||||
std::string ToString() const {
|
std::string ToString() const {
|
||||||
return fmt::format("({}, {}, {})", button, (int)axis, axis_value);
|
return fmt::format("({}, {}, {})", button, (int)axis, old_param);
|
||||||
}
|
}
|
||||||
inline bool IsButton() const {
|
inline bool IsButton() const {
|
||||||
return axis == Axis::AxisMax && button != 0;
|
return axis == Axis::AxisMax && button != 0;
|
||||||
@ -286,9 +287,10 @@ public:
|
|||||||
inline bool IsAxis() const {
|
inline bool IsAxis() const {
|
||||||
return axis != Axis::AxisMax && button == 0;
|
return axis != Axis::AxisMax && button == 0;
|
||||||
}
|
}
|
||||||
void Update(bool pressed, u32 param = 0);
|
|
||||||
// Off events are not counted
|
void ResetUpdate();
|
||||||
void AddUpdate(bool pressed, u32 param = 0);
|
void AddUpdate(bool pressed, u32 param = 0);
|
||||||
|
void FinalizeUpdate();
|
||||||
};
|
};
|
||||||
class BindingConnection {
|
class BindingConnection {
|
||||||
public:
|
public:
|
||||||
|
Loading…
Reference in New Issue
Block a user