mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-08-02 22:29:21 +00:00
Implement Balance Board in movies
This commit is contained in:
parent
c0d748fc73
commit
1bf2a7ff9d
4 changed files with 68 additions and 30 deletions
|
@ -58,6 +58,7 @@
|
||||||
#include "Core/HW/WiimoteCommon/WiimoteReport.h"
|
#include "Core/HW/WiimoteCommon/WiimoteReport.h"
|
||||||
|
|
||||||
#include "Core/HW/WiimoteEmu/Encryption.h"
|
#include "Core/HW/WiimoteEmu/Encryption.h"
|
||||||
|
#include "Core/HW/WiimoteEmu/Extension/BalanceBoard.h"
|
||||||
#include "Core/HW/WiimoteEmu/Extension/Classic.h"
|
#include "Core/HW/WiimoteEmu/Extension/Classic.h"
|
||||||
#include "Core/HW/WiimoteEmu/Extension/Nunchuk.h"
|
#include "Core/HW/WiimoteEmu/Extension/Nunchuk.h"
|
||||||
#include "Core/HW/WiimoteEmu/ExtensionPort.h"
|
#include "Core/HW/WiimoteEmu/ExtensionPort.h"
|
||||||
|
@ -130,10 +131,8 @@ std::string MovieManager::GetInputDisplay()
|
||||||
if (!IsMovieActive())
|
if (!IsMovieActive())
|
||||||
{
|
{
|
||||||
m_controllers = {};
|
m_controllers = {};
|
||||||
m_wiimotes = {};
|
|
||||||
|
|
||||||
const auto& si = m_system.GetSerialInterface();
|
const auto& si = m_system.GetSerialInterface();
|
||||||
for (int i = 0; i < 4; ++i)
|
for (int i = 0; i < SerialInterface::MAX_SI_CHANNELS; ++i)
|
||||||
{
|
{
|
||||||
if (si.GetDeviceType(i) == SerialInterface::SIDEVICE_GC_GBA_EMULATED)
|
if (si.GetDeviceType(i) == SerialInterface::SIDEVICE_GC_GBA_EMULATED)
|
||||||
m_controllers[i] = ControllerType::GBA;
|
m_controllers[i] = ControllerType::GBA;
|
||||||
|
@ -141,6 +140,10 @@ std::string MovieManager::GetInputDisplay()
|
||||||
m_controllers[i] = ControllerType::GC;
|
m_controllers[i] = ControllerType::GC;
|
||||||
else
|
else
|
||||||
m_controllers[i] = ControllerType::None;
|
m_controllers[i] = ControllerType::None;
|
||||||
|
}
|
||||||
|
m_wiimotes = {};
|
||||||
|
for (int i = 0; i < MAX_BBMOTES; ++i)
|
||||||
|
{
|
||||||
m_wiimotes[i] = Config::Get(Config::GetInfoForWiimoteSource(i)) != WiimoteSource::None;
|
m_wiimotes[i] = Config::Get(Config::GetInfoForWiimoteSource(i)) != WiimoteSource::None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -148,15 +151,15 @@ std::string MovieManager::GetInputDisplay()
|
||||||
std::string input_display;
|
std::string input_display;
|
||||||
{
|
{
|
||||||
std::lock_guard guard(m_input_display_lock);
|
std::lock_guard guard(m_input_display_lock);
|
||||||
for (int i = 0; i < 4; ++i)
|
for (int i = 0; i < SerialInterface::MAX_SI_CHANNELS; ++i)
|
||||||
{
|
{
|
||||||
if (IsUsingPad(i))
|
if (IsUsingPad(i))
|
||||||
input_display += m_input_display[i] + '\n';
|
input_display += m_input_display[i] + '\n';
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 4; ++i)
|
for (int i = 0; i < MAX_BBMOTES; ++i)
|
||||||
{
|
{
|
||||||
if (IsUsingWiimote(i))
|
if (IsUsingWiimote(i))
|
||||||
input_display += m_input_display[i + 4] + '\n';
|
input_display += m_input_display[i + SerialInterface::MAX_SI_CHANNELS] + '\n';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return input_display;
|
return input_display;
|
||||||
|
@ -475,7 +478,7 @@ void MovieManager::ChangeWiiPads(bool instantly)
|
||||||
{
|
{
|
||||||
WiimoteEnabledArray wiimotes{};
|
WiimoteEnabledArray wiimotes{};
|
||||||
|
|
||||||
for (int i = 0; i < MAX_WIIMOTES; ++i)
|
for (int i = 0; i < MAX_BBMOTES; ++i)
|
||||||
{
|
{
|
||||||
wiimotes[i] = Config::Get(Config::GetInfoForWiimoteSource(i)) != WiimoteSource::None;
|
wiimotes[i] = Config::Get(Config::GetInfoForWiimoteSource(i)) != WiimoteSource::None;
|
||||||
}
|
}
|
||||||
|
@ -485,7 +488,7 @@ void MovieManager::ChangeWiiPads(bool instantly)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const auto bt = WiiUtils::GetBluetoothEmuDevice();
|
const auto bt = WiiUtils::GetBluetoothEmuDevice();
|
||||||
for (int i = 0; i < MAX_WIIMOTES; ++i)
|
for (int i = 0; i < MAX_BBMOTES; ++i)
|
||||||
{
|
{
|
||||||
const bool is_using_wiimote = IsUsingWiimote(i);
|
const bool is_using_wiimote = IsUsingWiimote(i);
|
||||||
|
|
||||||
|
@ -676,7 +679,8 @@ static std::string GenerateInputDisplayString(ControllerState padState, int cont
|
||||||
static std::string GenerateWiiInputDisplayString(int remoteID, const DataReportBuilder& rpt,
|
static std::string GenerateWiiInputDisplayString(int remoteID, const DataReportBuilder& rpt,
|
||||||
ExtensionNumber ext, const EncryptionKey& key)
|
ExtensionNumber ext, const EncryptionKey& key)
|
||||||
{
|
{
|
||||||
std::string display_str = fmt::format("R{}:", remoteID + 1);
|
std::string display_str =
|
||||||
|
(remoteID == WIIMOTE_BALANCE_BOARD ? "BB:" : fmt::format("R{}:", remoteID + 1));
|
||||||
|
|
||||||
if (rpt.HasCore())
|
if (rpt.HasCore())
|
||||||
{
|
{
|
||||||
|
@ -797,6 +801,21 @@ static std::string GenerateWiiInputDisplayString(int remoteID, const DataReportB
|
||||||
display_str += Analog2DToString(right_stick.x, right_stick.y, " R-ANA", 31);
|
display_str += Analog2DToString(right_stick.x, right_stick.y, " R-ANA", 31);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Balance board
|
||||||
|
if (rpt.HasExt() && ext == ExtensionNumber::BALANCE_BOARD)
|
||||||
|
{
|
||||||
|
const u8* const extData = rpt.GetExtDataPtr();
|
||||||
|
|
||||||
|
BalanceBoardExt::DataFormat bb;
|
||||||
|
memcpy(&bb, extData, sizeof(bb));
|
||||||
|
key.Decrypt((u8*)&bb, 0, sizeof(bb));
|
||||||
|
|
||||||
|
display_str += Analog1DToString(Common::swap16(bb.top_right), " TR", -1);
|
||||||
|
display_str += Analog1DToString(Common::swap16(bb.bottom_right), " BR", -1);
|
||||||
|
display_str += Analog1DToString(Common::swap16(bb.top_left), " TL", -1);
|
||||||
|
display_str += Analog1DToString(Common::swap16(bb.bottom_left), " BL", -1);
|
||||||
|
}
|
||||||
|
|
||||||
return display_str;
|
return display_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -864,7 +883,7 @@ void MovieManager::CheckWiimoteStatus(int wiimote, const DataReportBuilder& rpt,
|
||||||
std::string display_str = GenerateWiiInputDisplayString(wiimote, rpt, ext, key);
|
std::string display_str = GenerateWiiInputDisplayString(wiimote, rpt, ext, key);
|
||||||
|
|
||||||
std::lock_guard guard(m_input_display_lock);
|
std::lock_guard guard(m_input_display_lock);
|
||||||
m_input_display[wiimote + 4] = std::move(display_str);
|
m_input_display[wiimote + SerialInterface::MAX_SI_CHANNELS] = std::move(display_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsRecordingInput())
|
if (IsRecordingInput())
|
||||||
|
@ -886,7 +905,7 @@ void MovieManager::RecordWiimote(int wiimote, const u8* data, u8 size)
|
||||||
// NOTE: EmuThread / Host Thread
|
// NOTE: EmuThread / Host Thread
|
||||||
void MovieManager::ReadHeader()
|
void MovieManager::ReadHeader()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 4; ++i)
|
for (int i = 0; i < SerialInterface::MAX_SI_CHANNELS; ++i)
|
||||||
{
|
{
|
||||||
if (m_temp_header.GBAControllers & (1 << i))
|
if (m_temp_header.GBAControllers & (1 << i))
|
||||||
m_controllers[i] = ControllerType::GBA;
|
m_controllers[i] = ControllerType::GBA;
|
||||||
|
@ -894,8 +913,13 @@ void MovieManager::ReadHeader()
|
||||||
m_controllers[i] = ControllerType::GC;
|
m_controllers[i] = ControllerType::GC;
|
||||||
else
|
else
|
||||||
m_controllers[i] = ControllerType::None;
|
m_controllers[i] = ControllerType::None;
|
||||||
m_wiimotes[i] = (m_temp_header.controllers & (1 << (i + 4))) != 0;
|
|
||||||
}
|
}
|
||||||
|
for (int i = 0; i < MAX_WIIMOTES; i++)
|
||||||
|
{
|
||||||
|
m_wiimotes[i] =
|
||||||
|
(m_temp_header.controllers & (1 << (i + SerialInterface::MAX_SI_CHANNELS))) != 0;
|
||||||
|
}
|
||||||
|
m_wiimotes[WIIMOTE_BALANCE_BOARD] = m_temp_header.bBalanceBoard;
|
||||||
m_recording_start_time = m_temp_header.recordingStartTime;
|
m_recording_start_time = m_temp_header.recordingStartTime;
|
||||||
if (m_rerecords < m_temp_header.numRerecords)
|
if (m_rerecords < m_temp_header.numRerecords)
|
||||||
m_rerecords = m_temp_header.numRerecords;
|
m_rerecords = m_temp_header.numRerecords;
|
||||||
|
@ -1374,15 +1398,19 @@ void MovieManager::SaveRecording(const std::string& filename)
|
||||||
header.bWii = m_system.IsWii();
|
header.bWii = m_system.IsWii();
|
||||||
header.controllers = 0;
|
header.controllers = 0;
|
||||||
header.GBAControllers = 0;
|
header.GBAControllers = 0;
|
||||||
for (int i = 0; i < 4; ++i)
|
for (int i = 0; i < SerialInterface::MAX_SI_CHANNELS; ++i)
|
||||||
{
|
{
|
||||||
if (IsUsingGBA(i))
|
if (IsUsingGBA(i))
|
||||||
header.GBAControllers |= 1 << i;
|
header.GBAControllers |= 1 << i;
|
||||||
if (IsUsingPad(i))
|
if (IsUsingPad(i))
|
||||||
header.controllers |= 1 << i;
|
header.controllers |= 1 << i;
|
||||||
if (IsUsingWiimote(i) && m_system.IsWii())
|
|
||||||
header.controllers |= 1 << (i + 4);
|
|
||||||
}
|
}
|
||||||
|
for (int i = 0; i < MAX_WIIMOTES; i++)
|
||||||
|
{
|
||||||
|
if (IsUsingWiimote(i) && m_system.IsWii())
|
||||||
|
header.controllers |= 1 << (i + SerialInterface::MAX_SI_CHANNELS);
|
||||||
|
}
|
||||||
|
header.bBalanceBoard = IsUsingWiimote(WIIMOTE_BALANCE_BOARD);
|
||||||
|
|
||||||
header.bFromSaveState = m_recording_from_save_state;
|
header.bFromSaveState = m_recording_from_save_state;
|
||||||
header.frameCount = m_total_frames;
|
header.frameCount = m_total_frames;
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
|
#include "Core/HW/SI/SI.h"
|
||||||
|
#include "Core/HW/Wiimote.h"
|
||||||
|
|
||||||
struct BootParameters;
|
struct BootParameters;
|
||||||
|
|
||||||
|
@ -50,8 +52,8 @@ enum class ControllerType
|
||||||
GC,
|
GC,
|
||||||
GBA,
|
GBA,
|
||||||
};
|
};
|
||||||
using ControllerTypeArray = std::array<ControllerType, 4>;
|
using ControllerTypeArray = std::array<ControllerType, SerialInterface::MAX_SI_CHANNELS>;
|
||||||
using WiimoteEnabledArray = std::array<bool, 4>;
|
using WiimoteEnabledArray = std::array<bool, MAX_BBMOTES>;
|
||||||
|
|
||||||
// GameCube Controller State
|
// GameCube Controller State
|
||||||
#pragma pack(push, 1)
|
#pragma pack(push, 1)
|
||||||
|
@ -130,10 +132,11 @@ struct DTMHeader
|
||||||
u8 reserved3;
|
u8 reserved3;
|
||||||
bool bFollowBranch;
|
bool bFollowBranch;
|
||||||
bool bUseFMA;
|
bool bUseFMA;
|
||||||
u8 GBAControllers; // GBA Controllers plugged in (the bits are ports 1-4)
|
u8 GBAControllers; // GBA Controllers plugged in (the bits are ports 1-4)
|
||||||
bool bWidescreen; // true indicates SYSCONF aspect ratio is 16:9, false for 4:3
|
bool bWidescreen; // true indicates SYSCONF aspect ratio is 16:9, false for 4:3
|
||||||
u8 countryCode; // SYSCONF country code
|
u8 countryCode; // SYSCONF country code
|
||||||
std::array<u8, 5> reserved; // Padding for any new config options
|
bool bBalanceBoard;
|
||||||
|
std::array<u8, 4> reserved; // Padding for any new config options
|
||||||
std::array<char, 40> discChange; // Name of iso file to switch to, for two disc games.
|
std::array<char, 40> discChange; // Name of iso file to switch to, for two disc games.
|
||||||
std::array<u8, 20> revision; // Git hash
|
std::array<u8, 20> revision; // Git hash
|
||||||
u32 DSPiromHash;
|
u32 DSPiromHash;
|
||||||
|
@ -237,8 +240,8 @@ private:
|
||||||
u32 m_rerecords = 0;
|
u32 m_rerecords = 0;
|
||||||
PlayMode m_play_mode = PlayMode::None;
|
PlayMode m_play_mode = PlayMode::None;
|
||||||
|
|
||||||
std::array<ControllerType, 4> m_controllers{};
|
ControllerTypeArray m_controllers{};
|
||||||
std::array<bool, 4> m_wiimotes{};
|
WiimoteEnabledArray m_wiimotes{};
|
||||||
ControllerState m_pad_state{};
|
ControllerState m_pad_state{};
|
||||||
DTMHeader m_temp_header{};
|
DTMHeader m_temp_header{};
|
||||||
std::vector<u8> m_temp_input;
|
std::vector<u8> m_temp_input;
|
||||||
|
@ -273,7 +276,8 @@ private:
|
||||||
|
|
||||||
// m_input_display is used by both CPU and GPU (is mutable).
|
// m_input_display is used by both CPU and GPU (is mutable).
|
||||||
std::mutex m_input_display_lock;
|
std::mutex m_input_display_lock;
|
||||||
std::array<std::string, 8> m_input_display;
|
std::array<std::string, static_cast<size_t>(SerialInterface::MAX_SI_CHANNELS) + MAX_BBMOTES>
|
||||||
|
m_input_display;
|
||||||
|
|
||||||
Core::System& m_system;
|
Core::System& m_system;
|
||||||
};
|
};
|
||||||
|
|
|
@ -350,12 +350,13 @@ MainWindow::~MainWindow()
|
||||||
delete m_render_widget;
|
delete m_render_widget;
|
||||||
delete m_netplay_dialog;
|
delete m_netplay_dialog;
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < num_gc_controllers; i++)
|
||||||
{
|
{
|
||||||
delete m_gc_tas_input_windows[i];
|
delete m_gc_tas_input_windows[i];
|
||||||
delete m_gba_tas_input_windows[i];
|
delete m_gba_tas_input_windows[i];
|
||||||
delete m_wii_tas_input_windows[i];
|
|
||||||
}
|
}
|
||||||
|
for (int i = 0; i < num_wii_controllers; i++)
|
||||||
|
delete m_wii_tas_input_windows[i];
|
||||||
|
|
||||||
ShutdownControllers();
|
ShutdownControllers();
|
||||||
|
|
||||||
|
@ -458,12 +459,13 @@ void MainWindow::CreateComponents()
|
||||||
m_render_widget = new RenderWidget;
|
m_render_widget = new RenderWidget;
|
||||||
m_stack = new QStackedWidget(this);
|
m_stack = new QStackedWidget(this);
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < num_gc_controllers; i++)
|
||||||
{
|
{
|
||||||
m_gc_tas_input_windows[i] = new GCTASInputWindow(nullptr, i);
|
m_gc_tas_input_windows[i] = new GCTASInputWindow(nullptr, i);
|
||||||
m_gba_tas_input_windows[i] = new GBATASInputWindow(nullptr, i);
|
m_gba_tas_input_windows[i] = new GBATASInputWindow(nullptr, i);
|
||||||
m_wii_tas_input_windows[i] = new WiiTASInputWindow(nullptr, i);
|
|
||||||
}
|
}
|
||||||
|
for (int i = 0; i < num_wii_controllers; i++)
|
||||||
|
m_wii_tas_input_windows[i] = new WiiTASInputWindow(nullptr, i);
|
||||||
|
|
||||||
m_jit_widget = new JITWidget(m_system, this);
|
m_jit_widget = new JITWidget(m_system, this);
|
||||||
m_log_widget = new LogWidget(this);
|
m_log_widget = new LogWidget(this);
|
||||||
|
@ -1873,7 +1875,7 @@ void MainWindow::OnStartRecording()
|
||||||
Movie::ControllerTypeArray controllers{};
|
Movie::ControllerTypeArray controllers{};
|
||||||
Movie::WiimoteEnabledArray wiimotes{};
|
Movie::WiimoteEnabledArray wiimotes{};
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < num_gc_controllers; i++)
|
||||||
{
|
{
|
||||||
const SerialInterface::SIDevices si_device = Config::Get(Config::GetInfoForSIDevice(i));
|
const SerialInterface::SIDevices si_device = Config::Get(Config::GetInfoForSIDevice(i));
|
||||||
if (si_device == SerialInterface::SIDEVICE_GC_GBA_EMULATED)
|
if (si_device == SerialInterface::SIDEVICE_GC_GBA_EMULATED)
|
||||||
|
@ -1882,6 +1884,10 @@ void MainWindow::OnStartRecording()
|
||||||
controllers[i] = Movie::ControllerType::GC;
|
controllers[i] = Movie::ControllerType::GC;
|
||||||
else
|
else
|
||||||
controllers[i] = Movie::ControllerType::None;
|
controllers[i] = Movie::ControllerType::None;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < num_wii_controllers; i++)
|
||||||
|
{
|
||||||
wiimotes[i] = Config::Get(Config::GetInfoForWiimoteSource(i)) != WiimoteSource::None;
|
wiimotes[i] = Config::Get(Config::GetInfoForWiimoteSource(i)) != WiimoteSource::None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -255,7 +255,7 @@ private:
|
||||||
static constexpr int num_gc_controllers = 4;
|
static constexpr int num_gc_controllers = 4;
|
||||||
std::array<GCTASInputWindow*, num_gc_controllers> m_gc_tas_input_windows{};
|
std::array<GCTASInputWindow*, num_gc_controllers> m_gc_tas_input_windows{};
|
||||||
std::array<GBATASInputWindow*, num_gc_controllers> m_gba_tas_input_windows{};
|
std::array<GBATASInputWindow*, num_gc_controllers> m_gba_tas_input_windows{};
|
||||||
static constexpr int num_wii_controllers = 4;
|
static constexpr int num_wii_controllers = 5;
|
||||||
std::array<WiiTASInputWindow*, num_wii_controllers> m_wii_tas_input_windows{};
|
std::array<WiiTASInputWindow*, num_wii_controllers> m_wii_tas_input_windows{};
|
||||||
|
|
||||||
#ifdef USE_RETRO_ACHIEVEMENTS
|
#ifdef USE_RETRO_ACHIEVEMENTS
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue