mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-05-02 17:28:33 +00:00
InputCommon: Add types to ControllerEmu that represent raw controller inputs and calibration data to calculate normalized input values.
This commit is contained in:
parent
259a7191d2
commit
8343dadd58
2 changed files with 118 additions and 0 deletions
|
@ -300,6 +300,12 @@ void SetBit(T& value, size_t bit_number, bool bit_value)
|
|||
value &= ~(T{1} << bit_number);
|
||||
}
|
||||
|
||||
template <size_t bit_number, typename T>
|
||||
void SetBit(T& value, bool bit_value)
|
||||
{
|
||||
SetBit(value, bit_number, bit_value);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
class FlagBit
|
||||
{
|
||||
|
@ -340,4 +346,15 @@ public:
|
|||
std::underlying_type_t<T> m_hex = 0;
|
||||
};
|
||||
|
||||
// Left-shift a value and set new LSBs to that of the supplied LSB.
|
||||
// Converts a value from a N-bit range to an (N+X)-bit range. e.g. 0x101 -> 0x10111
|
||||
template <typename T>
|
||||
T ExpandValue(T value, size_t left_shift_amount)
|
||||
{
|
||||
static_assert(std::is_unsigned<T>(), "ExpandValue is only sane on unsigned types.");
|
||||
|
||||
return (value << left_shift_amount) |
|
||||
(T(-ExtractBit<0>(value)) >> (BitSize<T>() - left_shift_amount));
|
||||
}
|
||||
|
||||
} // namespace Common
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue