yuzu-emu
/
yuzu-android
Archived
1
0
Fork 0

Revert 9617 and fix it on input_common

This commit is contained in:
Narr the Reg 2023-01-25 13:16:52 -06:00
parent 44b981fd3e
commit cc821bfae1
2 changed files with 9 additions and 12 deletions

View File

@ -11,7 +11,6 @@
namespace Core::HID { namespace Core::HID {
constexpr s32 HID_JOYSTICK_MAX = 0x7fff; constexpr s32 HID_JOYSTICK_MAX = 0x7fff;
constexpr s32 HID_JOYSTICK_MIN = 0x7ffe;
constexpr s32 HID_TRIGGER_MAX = 0x7fff; constexpr s32 HID_TRIGGER_MAX = 0x7fff;
// Use a common UUID for TAS and Virtual Gamepad // Use a common UUID for TAS and Virtual Gamepad
constexpr Common::UUID TAS_UUID = constexpr Common::UUID TAS_UUID =
@ -864,16 +863,9 @@ void EmulatedController::SetStick(const Common::Input::CallbackStatus& callback,
return; return;
} }
const auto FloatToShort = [](float a) {
if (a > 0) {
return static_cast<s32>(a * HID_JOYSTICK_MAX);
}
return static_cast<s32>(a * HID_JOYSTICK_MIN);
};
const AnalogStickState stick{ const AnalogStickState stick{
.x = FloatToShort(controller.stick_values[index].x.value), .x = static_cast<s32>(controller.stick_values[index].x.value * HID_JOYSTICK_MAX),
.y = FloatToShort(controller.stick_values[index].y.value), .y = static_cast<s32>(controller.stick_values[index].y.value * HID_JOYSTICK_MAX),
}; };
switch (index) { switch (index) {

View File

@ -11,6 +11,11 @@ namespace InputCommon {
class Stick final : public Common::Input::InputDevice { class Stick final : public Common::Input::InputDevice {
public: public:
// Some games such as EARTH DEFENSE FORCE: WORLD BROTHERS
// do not play nicely with the theoretical maximum range.
// Using a value one lower from the maximum emulates real stick behavior.
static constexpr float MAX_RANGE = 32766.0f / 32767.0f;
using Button = std::unique_ptr<Common::Input::InputDevice>; using Button = std::unique_ptr<Common::Input::InputDevice>;
Stick(Button up_, Button down_, Button left_, Button right_, Button modifier_, Button updater_, Stick(Button up_, Button down_, Button left_, Button right_, Button modifier_, Button updater_,
@ -196,7 +201,7 @@ public:
} }
void UpdateStatus() { void UpdateStatus() {
const float coef = modifier_status.value ? modifier_scale : 1.0f; const float coef = modifier_status.value ? modifier_scale : MAX_RANGE;
bool r = right_status; bool r = right_status;
bool l = left_status; bool l = left_status;
@ -290,7 +295,7 @@ public:
if (down_status) { if (down_status) {
--y; --y;
} }
const float coef = modifier_status.value ? modifier_scale : 1.0f; const float coef = modifier_status.value ? modifier_scale : MAX_RANGE;
status.x.raw_value = static_cast<float>(x) * coef * (y == 0 ? 1.0f : SQRT_HALF); status.x.raw_value = static_cast<float>(x) * coef * (y == 0 ? 1.0f : SQRT_HALF);
status.y.raw_value = static_cast<float>(y) * coef * (x == 0 ? 1.0f : SQRT_HALF); status.y.raw_value = static_cast<float>(y) * coef * (x == 0 ? 1.0f : SQRT_HALF);
return status; return status;