Skip to content
Permalink
Browse files

WiimoteEmu: Fix battery level handling and remove old comments.

  • Loading branch information
jordan-woyak committed Jan 5, 2019
1 parent 6c0902a commit 3945aa624203c2e82160ef7fd045ab74fa47ca95
Showing with 13 additions and 9 deletions.
  1. +12 −8 Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp
  2. +1 −1 Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp
@@ -225,14 +225,18 @@ void Wiimote::HandleRequestStatus(const OutputReportRequestStatus&)
// Update status struct
m_status.extension = m_extension_port.IsDeviceConnected();

// TODO: Battery level will break determinism in TAS/Netplay

// Battery levels in voltage
// 0x00 - 0x32: level 1
// 0x33 - 0x43: level 2
// 0x33 - 0x54: level 3
// 0x55 - 0xff: level 4
m_status.battery = (u8)(m_battery_setting->GetValue() * 0xff);
// Based on testing, old WiiLi.org docs, and WiiUse library:
// Max battery level seems to be 0xc8 (decimal 200)
constexpr u8 MAX_BATTERY_LEVEL = 0xc8;

m_status.battery = (u8)(m_battery_setting->GetValue() * MAX_BATTERY_LEVEL);

if (Core::WantsDeterminism())
{
// One less thing to break determinism:
m_status.battery = MAX_BATTERY_LEVEL;
}

// Less than 0x20 triggers the low-battery flag:
m_status.battery_low = m_status.battery < 0x20;

@@ -235,7 +235,7 @@ Wiimote::Wiimote(const unsigned int index) : m_index(index)
m_options->numeric_settings.emplace_back(
std::make_unique<ControllerEmu::NumericSetting>(_trans("Speaker Pan"), 0, -127, 127));
m_options->numeric_settings.emplace_back(
m_battery_setting = new ControllerEmu::NumericSetting(_trans("Battery"), 95.0 / 100, 0, 255));
m_battery_setting = new ControllerEmu::NumericSetting(_trans("Battery"), 95.0 / 100, 0, 100));

// hotkeys
groups.emplace_back(m_hotkeys = new ControllerEmu::ModifySettingsButton(_trans("Hotkeys")));

0 comments on commit 3945aa6

Please sign in to comment.
You can’t perform that action at this time.