mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-20 11:36:13 +00:00
Input: remame some functions
This commit is contained in:
parent
907adc817e
commit
d4606cfdb9
4 changed files with 10 additions and 10 deletions
|
@ -100,7 +100,7 @@ long PadHandlerBase::FindKeyCodeByString(const std::unordered_map<u64, std::stri
|
|||
}
|
||||
|
||||
// Get new scaled value between 0 and 255 based on its minimum and maximum
|
||||
float PadHandlerBase::ScaleStickInput(s32 raw_value, int minimum, int maximum)
|
||||
float PadHandlerBase::ScaledInput(s32 raw_value, int minimum, int maximum)
|
||||
{
|
||||
// value based on max range converted to [0, 1]
|
||||
float val = static_cast<float>(std::clamp(raw_value, minimum, maximum) - minimum) / (abs(maximum) + abs(minimum));
|
||||
|
@ -108,7 +108,7 @@ float PadHandlerBase::ScaleStickInput(s32 raw_value, int minimum, int maximum)
|
|||
}
|
||||
|
||||
// Get new scaled value between -255 and 255 based on its minimum and maximum
|
||||
float PadHandlerBase::ScaleStickInput2(s32 raw_value, int minimum, int maximum)
|
||||
float PadHandlerBase::ScaledInput2(s32 raw_value, int minimum, int maximum)
|
||||
{
|
||||
// value based on max range converted to [0, 1]
|
||||
float val = static_cast<float>(std::clamp(raw_value, minimum, maximum) - minimum) / (abs(maximum) + abs(minimum));
|
||||
|
@ -160,7 +160,7 @@ u16 PadHandlerBase::NormalizeStickInput(u16 raw_value, int threshold, int multip
|
|||
|
||||
if (ignore_threshold)
|
||||
{
|
||||
return static_cast<u16>(ScaleStickInput(scaled_value, 0, thumb_max));
|
||||
return static_cast<u16>(ScaledInput(scaled_value, 0, thumb_max));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -89,10 +89,10 @@ protected:
|
|||
static long FindKeyCodeByString(const std::unordered_map<u64, std::string>& map, const std::string& name, bool fallback = true);
|
||||
|
||||
// Get new scaled value between 0 and 255 based on its minimum and maximum
|
||||
static float ScaleStickInput(s32 raw_value, int minimum, int maximum);
|
||||
static float ScaledInput(s32 raw_value, int minimum, int maximum);
|
||||
|
||||
// Get new scaled value between -255 and 255 based on its minimum and maximum
|
||||
static float ScaleStickInput2(s32 raw_value, int minimum, int maximum);
|
||||
static float ScaledInput2(s32 raw_value, int minimum, int maximum);
|
||||
|
||||
// Get normalized trigger value based on the range defined by a threshold
|
||||
u16 NormalizeTriggerInput(u16 value, int threshold);
|
||||
|
|
|
@ -243,12 +243,12 @@ std::unordered_map<u64, std::pair<u16, bool>> evdev_joystick_handler::GetButtonV
|
|||
// Triggers do not need handling of negative values
|
||||
if (min >= 0 && std::find(m_positive_axis.begin(), m_positive_axis.end(), code) == m_positive_axis.end())
|
||||
{
|
||||
const float fvalue = ScaleStickInput(val, min, max);
|
||||
const float fvalue = ScaledInput(val, min, max);
|
||||
button_values.emplace(code, std::make_pair<u16, bool>(static_cast<u16>(fvalue), false));
|
||||
continue;
|
||||
}
|
||||
|
||||
const float fvalue = ScaleStickInput2(val, min, max);
|
||||
const float fvalue = ScaledInput2(val, min, max);
|
||||
if (fvalue < 0)
|
||||
button_values.emplace(code, std::make_pair<u16, bool>(static_cast<u16>(std::abs(fvalue)), true));
|
||||
else
|
||||
|
@ -544,11 +544,11 @@ int evdev_joystick_handler::GetButtonInfo(const input_event& evt, const std::sha
|
|||
{
|
||||
m_is_negative = false;
|
||||
m_is_button_or_trigger = true;
|
||||
value = static_cast<u16>(ScaleStickInput(val, min, max));
|
||||
value = static_cast<u16>(ScaledInput(val, min, max));
|
||||
return code;
|
||||
}
|
||||
|
||||
const float fvalue = ScaleStickInput2(val, min, max);
|
||||
const float fvalue = ScaledInput2(val, min, max);
|
||||
m_is_negative = fvalue < 0;
|
||||
value = static_cast<u16>(std::abs(fvalue));
|
||||
return code;
|
||||
|
|
|
@ -383,7 +383,7 @@ std::unordered_map<u64, u16> mm_joystick_handler::GetButtonValues(const JOYINFOE
|
|||
|
||||
auto add_axis_value = [&](DWORD axis, UINT min, UINT max, u64 pos, u64 neg)
|
||||
{
|
||||
float val = ScaleStickInput2(axis, min, max);
|
||||
float val = ScaledInput2(axis, min, max);
|
||||
if (val < 0)
|
||||
{
|
||||
button_values.emplace(pos, 0);
|
||||
|
|
Loading…
Add table
Reference in a new issue