Large diffs are not rendered by default.

@@ -5,6 +5,7 @@
#pragma once

#include <atomic>
#include <memory>
#include <mutex>
#include <string>
#include <thread>
@@ -105,19 +106,19 @@ class Wiimote
void Prepare();
bool PrepareOnThread();

void DisableDataReporting();
void EnableDataReporting(u8 mode);
void SetChannel(u16 channel);
void ResetDataReporting();

void QueueReport(u8 rpt_id, const void* data, unsigned int size);
void QueueReport(WiimoteCommon::OutputReportID rpt_id, const void* data, unsigned int size);

int GetIndex() const;

protected:
Wiimote();
int m_index;
Report m_last_input_report;
u16 m_channel;
Wiimote() = default;

int m_index = 0;
Report m_last_input_report = {};
u16 m_channel = 0;

// If true, the Wiimote will be really disconnected when it is disconnected by Dolphin.
// In any other case, data reporting is not paused to allow reconnecting on any button press.
// This is not enabled on all platforms as connecting a Wiimote can be a pain on some platforms.
@@ -133,7 +134,12 @@ class Wiimote

void ThreadFunc();

bool m_rumble_state;
// We track the speaker state to convert unnecessary speaker data into rumble reports.
bool m_speaker_enable = false;
bool m_speaker_mute = false;

// And we track the rumble state to drop unnecessary rumble reports.
bool m_rumble_state = false;

std::thread m_wiimote_thread;
// Whether to keep running the thread.
@@ -188,7 +194,7 @@ class WiimoteScanner

extern std::mutex g_wiimotes_mutex;
extern WiimoteScanner g_wiimote_scanner;
extern Wiimote* g_wiimotes[MAX_BBMOTES];
extern std::unique_ptr<Wiimote> g_wiimotes[MAX_BBMOTES];

void InterruptChannel(int wiimote_number, u16 channel_id, const void* data, u32 size);
void ControlChannel(int wiimote_number, u16 channel_id, const void* data, u32 size);
@@ -74,7 +74,7 @@ static Common::Event g_compressAndDumpStateSyncEvent;
static std::thread g_save_thread;

// Don't forget to increase this after doing changes on the savestate system
static const u32 STATE_VERSION = 104; // Last changed in PR 7806
static const u32 STATE_VERSION = 105; // Last changed in PR 7871

// Maps savestate versions to Dolphin versions.
// Versions after 42 don't need to be added to this list,
@@ -177,10 +177,6 @@ static void DoState(PointerWrap& p)
g_video_backend->DoState(p);
p.DoMarker("video_backend");

if (SConfig::GetInstance().bWii)
Wiimote::DoState(p);
p.DoMarker("Wiimote");

PowerPC::DoState(p);
p.DoMarker("PowerPC");
// CoreTiming needs to be restored before restoring Hardware because
@@ -189,6 +185,9 @@ static void DoState(PointerWrap& p)
p.DoMarker("CoreTiming");
HW::DoState(p);
p.DoMarker("HW");
if (SConfig::GetInstance().bWii)
Wiimote::DoState(p);
p.DoMarker("Wiimote");
Movie::DoState(p);
p.DoMarker("Movie");
Gecko::DoState(p);
@@ -496,11 +496,8 @@ void ControllersWindow::SaveSettings()
for (size_t i = 0; i < m_wiimote_groups.size(); i++)
{
const int index = m_wiimote_boxes[i]->currentIndex();
g_wiimote_sources[i] = index;
m_wiimote_buttons[i]->setEnabled(index != 0 && index != 2);

if (Core::IsRunning())
WiimoteReal::ChangeWiimoteSource(static_cast<u32>(i), index);
WiimoteReal::ChangeWiimoteSource(static_cast<u32>(i), index);
}

UICommon::SaveWiimoteSources();