mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-04-20 11:35:54 +00:00
Publicly expose ConvertToSensorWeight; add ConvertToKilograms
This commit is contained in:
parent
68155565e3
commit
5331a48b0c
2 changed files with 18 additions and 4 deletions
|
@ -141,9 +141,6 @@ void BalanceBoardExt::LoadDefaults(const ControllerInterface& ciface)
|
|||
|
||||
u16 BalanceBoardExt::ConvertToSensorWeight(double weight_in_kilos)
|
||||
{
|
||||
constexpr u16 LOW_WEIGHT_DELTA = WEIGHT_17_KG - WEIGHT_0_KG;
|
||||
constexpr u16 HIGH_WEIGHT_DELTA = WEIGHT_34_KG - WEIGHT_17_KG;
|
||||
|
||||
// Note: this is the weight on a single sensor, so these ranges make more sense
|
||||
// (if all sensors read 34 kilos, then the overall weight would be 136 kilos or 300 pounds...)
|
||||
if (weight_in_kilos < 17)
|
||||
|
@ -156,6 +153,18 @@ u16 BalanceBoardExt::ConvertToSensorWeight(double weight_in_kilos)
|
|||
}
|
||||
}
|
||||
|
||||
double BalanceBoardExt::ConvertToKilograms(u16 sensor_weight)
|
||||
{
|
||||
if (sensor_weight < WEIGHT_17_KG)
|
||||
{
|
||||
return (sensor_weight - WEIGHT_0_KG) * 17. / LOW_WEIGHT_DELTA;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (sensor_weight - WEIGHT_17_KG) * 17. / HIGH_WEIGHT_DELTA + 17.;
|
||||
}
|
||||
}
|
||||
|
||||
void BalanceBoardExt::ComputeCalibrationChecksum()
|
||||
{
|
||||
std::array<u8, 0x1c> data;
|
||||
|
|
|
@ -52,6 +52,9 @@ public:
|
|||
|
||||
void LoadDefaults(const ControllerInterface& ciface) override;
|
||||
|
||||
static u16 ConvertToSensorWeight(double weight_in_kilos);
|
||||
static double ConvertToKilograms(u16 sensor_weight);
|
||||
|
||||
// Use the same calibration data for all sensors.
|
||||
// Wii Fit internally converts to grams, but using grams for the actual values leads to
|
||||
// overflowing values, and also underflowing values when a sensor gets negative if balance is
|
||||
|
@ -65,9 +68,11 @@ public:
|
|||
static constexpr u8 TEMPERATURE = 0x19;
|
||||
|
||||
private:
|
||||
u16 ConvertToSensorWeight(double weight_in_kilos);
|
||||
void ComputeCalibrationChecksum();
|
||||
|
||||
static constexpr u16 LOW_WEIGHT_DELTA = WEIGHT_17_KG - WEIGHT_0_KG;
|
||||
static constexpr u16 HIGH_WEIGHT_DELTA = WEIGHT_34_KG - WEIGHT_17_KG;
|
||||
|
||||
ControllerEmu::AnalogStick* m_balance;
|
||||
ControllerEmu::Triggers* m_weight;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue