Compile for Windows

This commit is contained in:
Sketch 2024-02-06 22:08:04 -05:00
parent c308aa817c
commit 99e60d2c82
14 changed files with 35 additions and 213 deletions

View File

@ -566,12 +566,6 @@ const Info<bool> MAIN_EMULATE_SKYLANDER_PORTAL{
const Info<bool> MAIN_EMULATE_INFINITY_BASE{
{System::Main, "EmulatedUSBDevices", "EmulateInfinityBase"}, false};
const Info<bool> MAIN_EMULATE_WII_SPEAK{{System::Main, "EmulatedUSBDevices", "EmulateWiiSpeak"},
false};
const Info<std::string> MAIN_WII_SPEAK_MICROPHONE{{System::Main, "General", "WiiSpeakMicrophone"},
""};
// The reason we need this function is because some memory card code
// expects to get a non-NTSC-K region even if we're emulating an NTSC-K Wii.
DiscIO::Region ToGameCubeRegion(DiscIO::Region region)

View File

@ -351,8 +351,6 @@ void SetUSBDeviceWhitelist(const std::set<std::pair<u16, u16>>& devices);
extern const Info<bool> MAIN_EMULATE_SKYLANDER_PORTAL;
extern const Info<bool> MAIN_EMULATE_INFINITY_BASE;
extern const Info<bool> MAIN_EMULATE_WII_SPEAK;
extern const Info<std::string> MAIN_WII_SPEAK_MICROPHONE;
// GameCube path utility functions

View File

@ -1,25 +1,31 @@
//
// Created by Noah Pistilli on 2023-07-09.
//
// Copyright 2024 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <cubeb/cubeb.h>
#include "AudioCommon/CubebUtils.h"
#include <Common/Logging/Log.h>
#include "Common/Logging/Log.h"
#include "Microphone.h"
#include "Common/ScopeGuard.h"
#include "Common/Swap.h"
#include "Core/IOS/USB/Emulated/Microphone.h"
#include <algorithm>
#include <mutex>
#ifdef _WIN32
#include <Objbase.h>
#endif
namespace IOS::HLE::USB
{
Microphone::Microphone() {
Microphone::Microphone()
{
StreamInit();
}
Microphone::~Microphone() {
Microphone::~Microphone()
{
StreamTerminate();
#ifdef _WIN32
@ -110,8 +116,8 @@ void Microphone::StreamStart()
if (cubeb_stream_init(m_cubeb_ctx.get(), &m_cubeb_stream,
"Dolphin Emulated GameCube Microphone", nullptr, &params, nullptr,
nullptr, std::max<u32>(16, minimum_latency), DataCallback,
state_callback, this) != CUBEB_OK)
nullptr, std::max<u32>(16, minimum_latency), DataCallback, state_callback,
this) != CUBEB_OK)
{
ERROR_LOG_FMT(IOS_USB, "Error initializing cubeb stream");
return;
@ -151,7 +157,7 @@ void Microphone::StopStream()
}
long Microphone::DataCallback(cubeb_stream* stream, void* user_data, const void* input_buffer,
void* /*output_buffer*/, long nframes)
void* /*output_buffer*/, long nframes)
{
auto* mic = static_cast<Microphone*>(user_data);
@ -173,44 +179,6 @@ long Microphone::DataCallback(cubeb_stream* stream, void* user_data, const void*
return nframes;
}
void Microphone::PerformAudioCapture()
{
/*m_num_of_samples = BUFFER_SIZE / 2;
ALCint samples_in{};
alcGetIntegerv(m_device, ALC_CAPTURE_SAMPLES, 1, &samples_in);
m_num_of_samples = std::min(m_num_of_samples, static_cast<u32>(samples_in));
if (m_num_of_samples == 0)
return;
alcCaptureSamples(m_device, m_dsp_data.data(), m_num_of_samples);*/
}
void Microphone::ByteSwap(const void* src, void* dst) const
{
*static_cast<u16*>(dst) = Common::swap16(*static_cast<const u16*>(src));
}
void Microphone::GetSoundData()
{
/*if (m_num_of_samples == 0)
return;
u8* ptr = const_cast<u8*>(m_temp_buffer.data());
// Convert LE to BE
for (u32 i = 0; i < m_num_of_samples; i++)
{
for (u32 indchan = 0; indchan < 1; indchan++)
{
const u32 curindex = (i * 2) + indchan * (16 / 8);
ByteSwap(m_dsp_data.data() + curindex, ptr + curindex);
}
}
m_rbuf_dsp.write_bytes(ptr, m_num_of_samples * 2);*/
}
void Microphone::ReadIntoBuffer(u8* dst, u32 size)
{
std::lock_guard lk(ring_lock);
@ -231,4 +199,4 @@ bool Microphone::HasData() const
{
return samples_avail > 0;
}
} // namespace IOS::HLE::USB
} // namespace IOS::HLE::USB

View File

@ -1,13 +1,15 @@
// Copyright 2024 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <OpenAL/al.h>
#include <OpenAL/alc.h>
#include <mutex>
#include <string>
#include <vector>
#include <mutex>
#include "Common/CommonTypes.h"
#include "Common/Event.h"
#include "Common/WorkQueueThread.h"
struct cubeb;
struct cubeb_stream;
@ -22,8 +24,6 @@ public:
void StreamInit();
void StreamTerminate();
void PerformAudioCapture();
void GetSoundData();
void ReadIntoBuffer(u8* dst, u32 size);
bool HasData() const;
@ -33,7 +33,6 @@ private:
void StreamStart();
void StopStream();
void ByteSwap(const void* src, void* dst) const;
static constexpr u32 SAMPLING_RATE = 8000;
static constexpr u32 BUFFER_SIZE = SAMPLING_RATE / 2;

View File

@ -1,4 +1,4 @@
// Copyright 2023 Dolphin Emulator Project
// Copyright 2024 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "Core/IOS/USB/Emulated/WiiSpeak.h"
@ -26,11 +26,6 @@ WiiSpeak::WiiSpeak(IOS::HLE::EmulationKernel& ios, const std::string& device_nam
m_microphone = std::make_unique<Microphone>();
}
WiiSpeak::~WiiSpeak()
{
}
DeviceDescriptor WiiSpeak::GetDeviceDescriptor() const
{
return m_device_descriptor;
@ -106,9 +101,6 @@ int WiiSpeak::SubmitTransfer(std::unique_ptr<CtrlMessage> cmd)
m_vid, m_pid, m_active_interface, cmd->request_type, cmd->request, cmd->value,
cmd->index, cmd->length);
if (!b_is_mic_connected)
return IPC_ENOENT;
switch (cmd->request_type << 8 | cmd->request)
{
case USBHDR(DIR_DEVICE2HOST, TYPE_STANDARD, REC_INTERFACE, REQUEST_GET_INTERFACE):
@ -176,8 +168,7 @@ int WiiSpeak::SubmitTransfer(std::unique_ptr<IsoMessage> cmd)
if (cmd->endpoint == 0x81 && m_microphone->HasData())
m_microphone->ReadIntoBuffer(packets, cmd->length);
// Anything more causes the visual cue to not appear.
// Anything less is more choppy audio.
// TODO: Figure out proper timings.
cmd->ScheduleTransferCompletion(IPC_SUCCESS, 2500);
return IPC_SUCCESS;
};
@ -199,6 +190,7 @@ void WiiSpeak::SetRegister(std::unique_ptr<CtrlMessage>& cmd)
switch (arg1)
{
case FREQ_8KHZ:
// TODO: I have never seen it not be 8000 kHz
sampler.freq = 8000;
break;
case FREQ_11KHZ:
@ -319,4 +311,4 @@ void WiiSpeak::GetRegister(std::unique_ptr<CtrlMessage>& cmd)
break;
}
}
} // namespace IOS::HLE::USB
} // namespace IOS::HLE::USB

View File

@ -1,4 +1,4 @@
// Copyright 2023 Dolphin Emulator Project
// Copyright 2024 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
@ -19,7 +19,6 @@ class WiiSpeak final : public Device
{
public:
WiiSpeak(EmulationKernel& ios, const std::string& device_name);
~WiiSpeak();
DeviceDescriptor GetDeviceDescriptor() const override;
std::vector<ConfigDescriptor> GetConfigurations() const override;
std::vector<InterfaceDescriptor> GetInterfaces(u8 config) const override;
@ -57,13 +56,13 @@ private:
FREQ_8KHZ = 0,
FREQ_11KHZ = 1,
FREQ_RESERVED = 2,
FREQ_16KHZ = 3, // default
FREQ_16KHZ = 3,
SAMPLER_GAIN = 4,
GAIN_00dB = 0,
GAIN_15dB = 1,
GAIN_30dB = 2,
GAIN_36dB = 3, // default
GAIN_36dB = 3,
EC_STATE = 0x14,
@ -83,7 +82,6 @@ private:
u8 m_active_interface = 0;
bool m_device_attached = false;
bool init = false;
bool b_is_mic_connected = true;
std::unique_ptr<Microphone> m_microphone;
DeviceDescriptor m_device_descriptor{};
std::vector<ConfigDescriptor> m_config_descriptor;
@ -92,4 +90,4 @@ private:
std::mutex m_mutex;
Common::Event m_shutdown_event;
};
} // namespace IOS::HLE::USB
} // namespace IOS::HLE::USB

View File

@ -395,9 +395,11 @@
<ClInclude Include="Core\IOS\USB\Bluetooth\WiimoteHIDAttr.h" />
<ClInclude Include="Core\IOS\USB\Common.h" />
<ClInclude Include="Core\IOS\USB\Emulated\Infinity.h" />
<ClInclude Include="Core\IOS\USB\Emulated\Microphone.h" />
<ClInclude Include="Core\IOS\USB\Emulated\Skylanders\Skylander.h" />
<ClInclude Include="Core\IOS\USB\Emulated\Skylanders\SkylanderCrypto.h" />
<ClInclude Include="Core\IOS\USB\Emulated\Skylanders\SkylanderFigure.h" />
<ClInclude Include="Core\IOS\USB\Emulated\WiiSpeak.h" />
<ClInclude Include="Core\IOS\USB\Host.h" />
<ClInclude Include="Core\IOS\USB\LibusbDevice.h" />
<ClInclude Include="Core\IOS\USB\OH0\OH0.h" />
@ -1051,9 +1053,11 @@
<ClCompile Include="Core\IOS\USB\Bluetooth\WiimoteHIDAttr.cpp" />
<ClCompile Include="Core\IOS\USB\Common.cpp" />
<ClCompile Include="Core\IOS\USB\Emulated\Infinity.cpp" />
<ClCompile Include="Core\IOS\USB\Emulated\Microphone.cpp" />
<ClCompile Include="Core\IOS\USB\Emulated\Skylanders\Skylander.cpp" />
<ClCompile Include="Core\IOS\USB\Emulated\Skylanders\SkylanderCrypto.cpp" />
<ClCompile Include="Core\IOS\USB\Emulated\Skylanders\SkylanderFigure.cpp" />
<ClCompile Include="Core\IOS\USB\Emulated\WiiSpeak.cpp" />
<ClCompile Include="Core\IOS\USB\Host.cpp" />
<ClCompile Include="Core\IOS\USB\LibusbDevice.cpp" />
<ClCompile Include="Core\IOS\USB\OH0\OH0.cpp" />

View File

@ -240,8 +240,6 @@ add_executable(dolphin-emu
DiscordHandler.h
DiscordJoinRequestDialog.cpp
DiscordJoinRequestDialog.h
EmulatedUSB/WiiSpeakWindow.cpp
EmulatedUSB/WiiSpeakWindow.h
FIFO/FIFOAnalyzer.cpp
FIFO/FIFOAnalyzer.h
FIFO/FIFOPlayerWindow.cpp

View File

@ -1,77 +0,0 @@
// Copyright 2023 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "DolphinQt/EmulatedUSB/WiiSpeakWindow.h"
#include <string>
#include <QCheckBox>
#include <QComboBox>
#include <QCompleter>
#include <QDialogButtonBox>
#include <QGroupBox>
#include <QLabel>
#include <QLineEdit>
#include <QMessageBox>
#include <QPushButton>
#include <QScrollArea>
#include <QString>
#include <QVBoxLayout>
#include "Common/IOFile.h"
#include "Core/Config/MainSettings.h"
#include "Core/Core.h"
#include "Core/IOS/USB/Emulated/Microphone.h"
#include "Core/System.h"
#include "DolphinQt/QtUtils/DolphinFileDialog.h"
#include "DolphinQt/Settings.h"
WiiSpeakWindow::WiiSpeakWindow(QWidget* parent) : QWidget(parent)
{
setWindowTitle(tr("Wii Speak Manager"));
setObjectName(QStringLiteral("wii_speak_manager"));
setMinimumSize(QSize(700, 200));
CreateMainWindow();
connect(&Settings::Instance(), &Settings::EmulationStateChanged, this,
&WiiSpeakWindow::OnEmulationStateChanged);
installEventFilter(this);
OnEmulationStateChanged(Core::GetState());
};
WiiSpeakWindow::~WiiSpeakWindow() = default;
void WiiSpeakWindow::CreateMainWindow()
{
auto* main_layout = new QVBoxLayout();
auto* checkbox_group = new QGroupBox();
auto* checkbox_layout = new QHBoxLayout();
checkbox_layout->setAlignment(Qt::AlignLeft);
m_checkbox = new QCheckBox(tr("Emulate Wii Speak"), this);
m_checkbox->setChecked(Config::Get(Config::MAIN_EMULATE_WII_SPEAK));
connect(m_checkbox, &QCheckBox::toggled, this, &WiiSpeakWindow::EmulateWiiSpeak);
checkbox_layout->addWidget(m_checkbox);
checkbox_group->setLayout(checkbox_layout);
main_layout->addWidget(checkbox_group);
setLayout(main_layout);
}
void WiiSpeakWindow::EmulateWiiSpeak(bool emulate)
{
Config::SetBaseOrCurrent(Config::MAIN_EMULATE_WII_SPEAK, emulate);
}
void WiiSpeakWindow::OnEmulationStateChanged(Core::State state)
{
const bool running = state != Core::State::Uninitialized;
m_checkbox->setEnabled(!running);
}

View File

@ -1,33 +0,0 @@
// Copyright 2023 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <array>
#include <QDialog>
#include <QWidget>
#include "Common/CommonTypes.h"
#include "Core/Core.h"
class QCheckBox;
class QGroupBox;
class QLineEdit;
class QVBoxLayout;
class QComboBox;
class WiiSpeakWindow : public QWidget
{
Q_OBJECT
public:
explicit WiiSpeakWindow(QWidget* parent = nullptr);
~WiiSpeakWindow() override;
private:
void CreateMainWindow();
void OnEmulationStateChanged(Core::State state);
void EmulateWiiSpeak(bool emulate);
QCheckBox* m_checkbox;
};

View File

@ -92,7 +92,6 @@
#include "DolphinQt/Debugger/ThreadWidget.h"
#include "DolphinQt/Debugger/WatchWidget.h"
#include "DolphinQt/DiscordHandler.h"
#include "DolphinQt/EmulatedUSB/WiiSpeakWindow.h"
#include "DolphinQt/FIFO/FIFOPlayerWindow.h"
#include "DolphinQt/GCMemcardManager.h"
#include "DolphinQt/GameList/GameList.h"
@ -559,7 +558,6 @@ void MainWindow::ConnectMenuBar()
connect(m_menu_bar, &MenuBar::ShowFIFOPlayer, this, &MainWindow::ShowFIFOPlayer);
connect(m_menu_bar, &MenuBar::ShowSkylanderPortal, this, &MainWindow::ShowSkylanderPortal);
connect(m_menu_bar, &MenuBar::ShowInfinityBase, this, &MainWindow::ShowInfinityBase);
connect(m_menu_bar, &MenuBar::ShowWiiSpeakWindow, this, &MainWindow::ShowWiiSpeakWindow);
connect(m_menu_bar, &MenuBar::ConnectWiiRemote, this, &MainWindow::OnConnectWiiRemote);
#ifdef USE_RETRO_ACHIEVEMENTS
@ -1404,18 +1402,6 @@ void MainWindow::ShowInfinityBase()
m_infinity_window->activateWindow();
}
void MainWindow::ShowWiiSpeakWindow()
{
if (!m_wii_speak_window)
{
m_wii_speak_window = new WiiSpeakWindow();
}
m_wii_speak_window->show();
m_wii_speak_window->raise();
m_wii_speak_window->activateWindow();
}
void MainWindow::StateLoad()
{
QString path =

View File

@ -52,7 +52,6 @@ class ThreadWidget;
class ToolBar;
class WatchWidget;
class WiiTASInputWindow;
class WiiSpeakWindow;
struct WindowSystemInfo;
namespace DiscIO
@ -170,7 +169,6 @@ private:
void ShowFIFOPlayer();
void ShowSkylanderPortal();
void ShowInfinityBase();
void ShowWiiSpeakWindow();
void ShowMemcardManager();
void ShowResourcePackManager();
void ShowCheatsManager();
@ -246,7 +244,6 @@ private:
FIFOPlayerWindow* m_fifo_window = nullptr;
SkylanderPortalWindow* m_skylander_window = nullptr;
InfinityBaseWindow* m_infinity_window = nullptr;
WiiSpeakWindow* m_wii_speak_window = nullptr;
MappingWindow* m_hotkey_window = nullptr;
FreeLookWindow* m_freelook_window = nullptr;

View File

@ -237,7 +237,6 @@ void MenuBar::AddToolsMenu()
auto* usb_device_menu = new QMenu(tr("Emulated USB Devices"), tools_menu);
usb_device_menu->addAction(tr("&Skylanders Portal"), this, &MenuBar::ShowSkylanderPortal);
usb_device_menu->addAction(tr("&Infinity Base"), this, &MenuBar::ShowInfinityBase);
usb_device_menu->addAction(tr("&Wii Speak"), this, &MenuBar::ShowWiiSpeakWindow);
tools_menu->addMenu(usb_device_menu);
tools_menu->addSeparator();

View File

@ -91,7 +91,6 @@ signals:
void ShowResourcePackManager();
void ShowSkylanderPortal();
void ShowInfinityBase();
void ShowWiiSpeakWindow();
void ConnectWiiRemote(int id);
#ifdef USE_RETRO_ACHIEVEMENTS