mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-17 17:11:23 +00:00
input: use left and right squircle values
This commit is contained in:
parent
d6623e0f22
commit
4d9533ea54
@ -172,7 +172,7 @@ u16 PadHandlerBase::NormalizeStickInput(u16 raw_value, int threshold, int multip
|
||||
// This function normalizes stick deadzone based on the DS3's deadzone, which is ~13%
|
||||
// X and Y is expected to be in (-255) to 255 range, deadzone should be in terms of thumb stick range
|
||||
// return is new x and y values in 0-255 range
|
||||
std::tuple<u16, u16> PadHandlerBase::NormalizeStickDeadzone(s32 inX, s32 inY, u32 deadzone)
|
||||
std::tuple<u16, u16> PadHandlerBase::NormalizeStickDeadzone(s32 inX, s32 inY, u32 deadzone) const
|
||||
{
|
||||
const float dz_range = deadzone / static_cast<float>(std::abs(thumb_max)); // NOTE: thumb_max should be positive anyway
|
||||
|
||||
@ -388,6 +388,18 @@ void PadHandlerBase::get_next_button_press(const std::string& pad_id, const pad_
|
||||
return;
|
||||
}
|
||||
|
||||
void PadHandlerBase::convert_stick_values(u16& x_out, u16& y_out, const s32& x_in, const s32& y_in, const s32& deadzone, const s32& padsquircling) const
|
||||
{
|
||||
// Normalize our stick axis based on the deadzone
|
||||
std::tie(x_out, y_out) = NormalizeStickDeadzone(x_in, y_in, deadzone);
|
||||
|
||||
// Apply pad squircling if necessary
|
||||
if (padsquircling != 0)
|
||||
{
|
||||
std::tie(x_out, y_out) = ConvertToSquirclePoint(x_out, y_out, padsquircling);
|
||||
}
|
||||
}
|
||||
|
||||
// Update the pad button values based on their type and thresholds. With this you can use axis or triggers as buttons or vice versa
|
||||
void PadHandlerBase::TranslateButtonPress(const std::shared_ptr<PadDevice>& device, u64 keyCode, bool& pressed, u16& val, bool ignore_stick_threshold, bool ignore_trigger_threshold)
|
||||
{
|
||||
@ -568,15 +580,9 @@ void PadHandlerBase::get_mapping(const std::shared_ptr<PadDevice>& device, const
|
||||
|
||||
u16 lx, ly, rx, ry;
|
||||
|
||||
// Normalize our two stick's axis based on the thresholds
|
||||
std::tie(lx, ly) = NormalizeStickDeadzone(stick_val[0], stick_val[1], profile->lstickdeadzone);
|
||||
std::tie(rx, ry) = NormalizeStickDeadzone(stick_val[2], stick_val[3], profile->rstickdeadzone);
|
||||
|
||||
if (profile->padsquircling != 0)
|
||||
{
|
||||
std::tie(lx, ly) = ConvertToSquirclePoint(lx, ly, profile->padsquircling);
|
||||
std::tie(rx, ry) = ConvertToSquirclePoint(rx, ry, profile->padsquircling);
|
||||
}
|
||||
// Normalize and apply pad squircling
|
||||
convert_stick_values(lx, ly, stick_val[0], stick_val[1], profile->lstickdeadzone, profile->lpadsquircling);
|
||||
convert_stick_values(rx, ry, stick_val[2], stick_val[3], profile->rstickdeadzone, profile->rpadsquircling);
|
||||
|
||||
if (m_type == pad_handler::ds4)
|
||||
{
|
||||
|
@ -101,12 +101,10 @@ protected:
|
||||
// the input values must lie in 0+
|
||||
u16 NormalizeDirectedInput(s32 raw_value, s32 threshold, s32 maximum) const;
|
||||
|
||||
u16 NormalizeStickInput(u16 raw_value, int threshold, int multiplier, bool ignore_threshold = false) const;
|
||||
|
||||
// This function normalizes stick deadzone based on the DS3's deadzone, which is ~13%
|
||||
// X and Y is expected to be in (-255) to 255 range, deadzone should be in terms of thumb stick range
|
||||
// return is new x and y values in 0-255 range
|
||||
std::tuple<u16, u16> NormalizeStickDeadzone(s32 inX, s32 inY, u32 deadzone);
|
||||
std::tuple<u16, u16> NormalizeStickDeadzone(s32 inX, s32 inY, u32 deadzone) const;
|
||||
|
||||
// get clamped value between 0 and 255
|
||||
static u16 Clamp0To255(f32 input);
|
||||
@ -144,6 +142,9 @@ public:
|
||||
static std::string get_config_dir(pad_handler type, const std::string& title_id = "");
|
||||
static std::string get_config_filename(int i, const std::string& title_id = "");
|
||||
|
||||
u16 NormalizeStickInput(u16 raw_value, int threshold, int multiplier, bool ignore_threshold = false) const;
|
||||
void convert_stick_values(u16& x_out, u16& y_out, const s32& x_in, const s32& y_in, const s32& deadzone, const s32& padsquircling) const;
|
||||
|
||||
virtual bool Init() { return true; }
|
||||
PadHandlerBase(pad_handler type = pad_handler::null);
|
||||
virtual ~PadHandlerBase() = default;
|
||||
|
@ -69,7 +69,8 @@ struct pad_config final : cfg::node
|
||||
cfg::_int<0, 1000000> rstickdeadzone{ this, "Right Stick Deadzone", 0 };
|
||||
cfg::_int<0, 1000000> ltriggerthreshold{ this, "Left Trigger Threshold", 0 };
|
||||
cfg::_int<0, 1000000> rtriggerthreshold{ this, "Right Trigger Threshold", 0 };
|
||||
cfg::_int<0, 1000000> padsquircling{ this, "Pad Squircling Factor", 0 };
|
||||
cfg::_int<0, 1000000> lpadsquircling{ this, "Left Pad Squircling Factor", 0 };
|
||||
cfg::_int<0, 1000000> rpadsquircling{ this, "Right Pad Squircling Factor", 0 };
|
||||
|
||||
cfg::_int<0, 255> colorR{ this, "Color Value R", 0 };
|
||||
cfg::_int<0, 255> colorG{ this, "Color Value G", 0 };
|
||||
|
@ -266,7 +266,8 @@ void ds3_pad_handler::init_config(pad_config* cfg, const std::string& name)
|
||||
cfg->rstickdeadzone.def = 40; // between 0 and 255
|
||||
cfg->ltriggerthreshold.def = 0; // between 0 and 255
|
||||
cfg->rtriggerthreshold.def = 0; // between 0 and 255
|
||||
cfg->padsquircling.def = 0;
|
||||
cfg->lpadsquircling.def = 0;
|
||||
cfg->rpadsquircling.def = 0;
|
||||
|
||||
// Set color value
|
||||
cfg->colorR.def = 0;
|
||||
|
@ -171,7 +171,8 @@ void ds4_pad_handler::init_config(pad_config* cfg, const std::string& name)
|
||||
cfg->rstickdeadzone.def = 40; // between 0 and 255
|
||||
cfg->ltriggerthreshold.def = 0; // between 0 and 255
|
||||
cfg->rtriggerthreshold.def = 0; // between 0 and 255
|
||||
cfg->padsquircling.def = 8000;
|
||||
cfg->lpadsquircling.def = 8000;
|
||||
cfg->rpadsquircling.def = 8000;
|
||||
|
||||
// Set default color value
|
||||
cfg->colorR.def = 0;
|
||||
|
@ -84,7 +84,8 @@ void evdev_joystick_handler::init_config(pad_config* cfg, const std::string& nam
|
||||
cfg->rstickdeadzone.def = 30; // between 0 and 255
|
||||
cfg->ltriggerthreshold.def = 0; // between 0 and 255
|
||||
cfg->rtriggerthreshold.def = 0; // between 0 and 255
|
||||
cfg->padsquircling.def = 5000;
|
||||
cfg->lpadsquircling.def = 5000;
|
||||
cfg->rpadsquircling.def = 5000;
|
||||
|
||||
// apply defaults
|
||||
cfg->from_default();
|
||||
@ -830,18 +831,11 @@ void evdev_joystick_handler::get_mapping(const std::shared_ptr<PadDevice>& devic
|
||||
|
||||
const auto profile = m_dev->config;
|
||||
|
||||
// Normalize our two stick's axis based on the thresholds
|
||||
u16 lx, ly, rx, ry;
|
||||
|
||||
// Normalize our two stick's axis based on the thresholds
|
||||
std::tie(lx, ly) = NormalizeStickDeadzone(m_dev->stick_val[0], m_dev->stick_val[1], profile->lstickdeadzone);
|
||||
std::tie(rx, ry) = NormalizeStickDeadzone(m_dev->stick_val[2], m_dev->stick_val[3], profile->rstickdeadzone);
|
||||
|
||||
if (profile->padsquircling != 0)
|
||||
{
|
||||
std::tie(lx, ly) = ConvertToSquirclePoint(lx, ly, profile->padsquircling);
|
||||
std::tie(rx, ry) = ConvertToSquirclePoint(rx, ry, profile->padsquircling);
|
||||
}
|
||||
// Normalize and apply pad squircling
|
||||
convert_stick_values(lx, ly, m_dev->stick_val[0], m_dev->stick_val[1], profile->lstickdeadzone, profile->lpadsquircling);
|
||||
convert_stick_values(rx, ry, m_dev->stick_val[2], m_dev->stick_val[3], profile->rstickdeadzone, profile->rpadsquircling);
|
||||
|
||||
pad->m_sticks[0].m_value = lx;
|
||||
pad->m_sticks[1].m_value = 255 - ly;
|
||||
|
@ -67,7 +67,8 @@ void mm_joystick_handler::init_config(pad_config* cfg, const std::string& name)
|
||||
cfg->rstickdeadzone.def = 0; // between 0 and 255
|
||||
cfg->ltriggerthreshold.def = 0; // between 0 and 255
|
||||
cfg->rtriggerthreshold.def = 0; // between 0 and 255
|
||||
cfg->padsquircling.def = 8000;
|
||||
cfg->lpadsquircling.def = 8000;
|
||||
cfg->rpadsquircling.def = 8000;
|
||||
|
||||
// apply defaults
|
||||
cfg->from_default();
|
||||
|
@ -117,7 +117,8 @@ void xinput_pad_handler::init_config(pad_config* cfg, const std::string& name)
|
||||
cfg->rstickdeadzone.def = XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE; // between 0 and 32767
|
||||
cfg->ltriggerthreshold.def = XINPUT_GAMEPAD_TRIGGER_THRESHOLD; // between 0 and 255
|
||||
cfg->rtriggerthreshold.def = XINPUT_GAMEPAD_TRIGGER_THRESHOLD; // between 0 and 255
|
||||
cfg->padsquircling.def = 8000;
|
||||
cfg->lpadsquircling.def = 8000;
|
||||
cfg->rpadsquircling.def = 8000;
|
||||
|
||||
// apply defaults
|
||||
cfg->from_default();
|
||||
|
Loading…
Reference in New Issue
Block a user