Support up to 4 sound cards

This commit is contained in:
Jasmine Iwanek
2023-02-01 02:31:07 -05:00
parent f74b72d332
commit 5f04b29e8f
56 changed files with 892 additions and 716 deletions

View File

@@ -11,8 +11,10 @@
*
*
* Authors: Joakim L. Gilje <jgilje@jgilje.net>
* Jasmine Iwanek <jriwanek@gmail.com>
*
* Copyright 2021 Joakim L. Gilje
* Copyright 2021 Joakim L. Gilje
* Copyright 2022-2023 Jasmine Iwanek
*/
#include "qt_settingssound.hpp"
#include "ui_qt_settingssound.h"
@@ -47,17 +49,17 @@ SettingsSound::~SettingsSound()
void
SettingsSound::save()
{
sound_card_current = ui->comboBoxSoundCard->currentData().toInt();
for (uint8_t i = 0; i < SOUND_CARD_MAX; ++i) {
auto *cbox = findChild<QComboBox *>(QString("comboBoxSoundCard%1").arg(i + 1));
sound_card_current[i] = cbox->currentData().toInt();
}
midi_output_device_current = ui->comboBoxMidiOut->currentData().toInt();
midi_input_device_current = ui->comboBoxMidiIn->currentData().toInt();
mpu401_standalone_enable = ui->checkBoxMPU401->isChecked() ? 1 : 0;
SSI2001 = ui->checkBoxSSI2001->isChecked() ? 1 : 0;
;
GAMEBLASTER = ui->checkBoxCMS->isChecked() ? 1 : 0;
GUS = ui->checkBoxGUS->isChecked() ? 1 : 0;
;
sound_is_float = ui->checkBoxFloat32->isChecked() ? 1 : 0;
;
if (ui->radioButtonYMFM->isChecked())
fm_driver = FM_DRV_YMFM;
else
@@ -69,41 +71,45 @@ SettingsSound::onCurrentMachineChanged(int machineId)
{
this->machineId = machineId;
auto *model = ui->comboBoxSoundCard->model();
auto removeRows = model->rowCount();
int c = 0;
int selectedRow = 0;
while (true) {
/* Skip "internal" if machine doesn't have it. */
if ((c == 1) && (machine_has_flags(machineId, MACHINE_SOUND) == 0)) {
c++;
continue;
}
int c = 0;
int selectedRow = 0;
auto *sound_dev = sound_card_getdevice(c);
QString name = DeviceConfig::DeviceName(sound_dev, sound_card_get_internal_name(c), 1);
if (name.isEmpty()) {
break;
}
for (uint8_t i = 0; i < SOUND_CARD_MAX; ++i) {
auto *cbox = findChild<QComboBox *>(QString("comboBoxSoundCard%1").arg(i + 1));
auto *model = cbox->model();
auto removeRows = model->rowCount();
c = 0;
selectedRow = 0;
if (sound_card_available(c)) {
if (device_is_valid(sound_dev, machineId)) {
while (true) {
/* Skip "internal" if machine doesn't have it for the first card, always skip for others. */
if (((c == 1) && (machine_has_flags(machineId, MACHINE_SOUND) == 0)) || (i != 0)) {
c++;
continue;
}
auto name = DeviceConfig::DeviceName(sound_card_getdevice(c), sound_card_get_internal_name(c), 1);
if (name.isEmpty()) {
break;
}
if (sound_card_available(c) && device_is_valid(sound_card_getdevice(c), machineId)) {
int row = Models::AddEntry(model, name, c);
if (c == sound_card_current) {
if (c == sound_card_current[i]) {
selectedRow = row - removeRows;
}
}
c++;
}
c++;
model->removeRows(0, removeRows);
cbox->setEnabled(model->rowCount() > 0);
cbox->setCurrentIndex(-1);
cbox->setCurrentIndex(selectedRow);
}
model->removeRows(0, removeRows);
ui->comboBoxSoundCard->setEnabled(model->rowCount() > 0);
ui->comboBoxSoundCard->setCurrentIndex(-1);
ui->comboBoxSoundCard->setCurrentIndex(selectedRow);
model = ui->comboBoxMidiOut->model();
removeRows = model->rowCount();
auto model = ui->comboBoxMidiOut->model();
auto removeRows = model->rowCount();
c = 0;
selectedRow = 0;
while (true) {
@@ -150,19 +156,8 @@ SettingsSound::onCurrentMachineChanged(int machineId)
ui->comboBoxMidiIn->setCurrentIndex(selectedRow);
ui->checkBoxMPU401->setChecked(mpu401_standalone_enable > 0);
ui->checkBoxSSI2001->setChecked(SSI2001 > 0);
ui->checkBoxCMS->setChecked(GAMEBLASTER > 0);
ui->checkBoxGUS->setChecked(GUS > 0);
ui->checkBoxFloat32->setChecked(sound_is_float > 0);
bool hasIsa = machine_has_bus(machineId, MACHINE_BUS_ISA) > 0;
bool hasIsa16 = machine_has_bus(machineId, MACHINE_BUS_ISA16) > 0;
ui->checkBoxCMS->setEnabled(hasIsa);
ui->pushButtonConfigureCMS->setEnabled((GAMEBLASTER > 0) && hasIsa);
ui->checkBoxGUS->setEnabled(hasIsa16);
ui->pushButtonConfigureGUS->setEnabled((GUS > 0) && hasIsa16);
ui->checkBoxSSI2001->setEnabled(hasIsa);
ui->pushButtonConfigureSSI2001->setEnabled((SSI2001 > 0) && hasIsa);
switch (fm_driver) {
case FM_DRV_YMFM:
ui->radioButtonYMFM->setChecked(true);
@@ -192,18 +187,63 @@ allowMpu401(Ui::SettingsSound *ui)
}
void
SettingsSound::on_comboBoxSoundCard_currentIndexChanged(int index)
SettingsSound::on_comboBoxSoundCard1_currentIndexChanged(int index)
{
if (index < 0) {
return;
}
ui->pushButtonConfigureSoundCard->setEnabled(sound_card_has_config(ui->comboBoxSoundCard->currentData().toInt()));
ui->pushButtonConfigureSoundCard1->setEnabled(sound_card_has_config(ui->comboBoxSoundCard1->currentData().toInt()));
}
void
SettingsSound::on_pushButtonConfigureSoundCard_clicked()
SettingsSound::on_pushButtonConfigureSoundCard1_clicked()
{
DeviceConfig::ConfigureDevice(sound_card_getdevice(ui->comboBoxSoundCard->currentData().toInt()), 0, qobject_cast<Settings *>(Settings::settings));
DeviceConfig::ConfigureDevice(sound_card_getdevice(ui->comboBoxSoundCard1->currentData().toInt()), 0, qobject_cast<Settings *>(Settings::settings));
}
void
SettingsSound::on_comboBoxSoundCard2_currentIndexChanged(int index)
{
if (index < 0) {
return;
}
ui->pushButtonConfigureSoundCard2->setEnabled(sound_card_has_config(ui->comboBoxSoundCard2->currentData().toInt()));
}
void
SettingsSound::on_pushButtonConfigureSoundCard2_clicked()
{
DeviceConfig::ConfigureDevice(sound_card_getdevice(ui->comboBoxSoundCard2->currentData().toInt()), 0, qobject_cast<Settings *>(Settings::settings));
}
void
SettingsSound::on_comboBoxSoundCard3_currentIndexChanged(int index)
{
if (index < 0) {
return;
}
ui->pushButtonConfigureSoundCard3->setEnabled(sound_card_has_config(ui->comboBoxSoundCard3->currentData().toInt()));
}
void
SettingsSound::on_pushButtonConfigureSoundCard3_clicked()
{
DeviceConfig::ConfigureDevice(sound_card_getdevice(ui->comboBoxSoundCard3->currentData().toInt()), 0, qobject_cast<Settings *>(Settings::settings));
}
void
SettingsSound::on_comboBoxSoundCard4_currentIndexChanged(int index)
{
if (index < 0) {
return;
}
ui->pushButtonConfigureSoundCard1->setEnabled(sound_card_has_config(ui->comboBoxSoundCard4->currentData().toInt()));
}
void
SettingsSound::on_pushButtonConfigureSoundCard4_clicked()
{
DeviceConfig::ConfigureDevice(sound_card_getdevice(ui->comboBoxSoundCard4->currentData().toInt()), 0, qobject_cast<Settings *>(Settings::settings));
}
void
@@ -246,24 +286,6 @@ SettingsSound::on_checkBoxMPU401_stateChanged(int state)
ui->pushButtonConfigureMPU401->setEnabled(state == Qt::Checked);
}
void
SettingsSound::on_checkBoxSSI2001_stateChanged(int state)
{
ui->pushButtonConfigureSSI2001->setEnabled(state == Qt::Checked);
}
void
SettingsSound::on_checkBoxCMS_stateChanged(int state)
{
ui->pushButtonConfigureCMS->setEnabled(state == Qt::Checked);
}
void
SettingsSound::on_checkBoxGUS_stateChanged(int state)
{
ui->pushButtonConfigureGUS->setEnabled(state == Qt::Checked);
}
void
SettingsSound::on_pushButtonConfigureMPU401_clicked()
{
@@ -273,21 +295,3 @@ SettingsSound::on_pushButtonConfigureMPU401_clicked()
DeviceConfig::ConfigureDevice(&mpu401_device, 0, qobject_cast<Settings *>(Settings::settings));
}
}
void
SettingsSound::on_pushButtonConfigureSSI2001_clicked()
{
DeviceConfig::ConfigureDevice(&ssi2001_device, 0, qobject_cast<Settings *>(Settings::settings));
}
void
SettingsSound::on_pushButtonConfigureCMS_clicked()
{
DeviceConfig::ConfigureDevice(&cms_device, 0, qobject_cast<Settings *>(Settings::settings));
}
void
SettingsSound::on_pushButtonConfigureGUS_clicked()
{
DeviceConfig::ConfigureDevice(&gus_device, 0, qobject_cast<Settings *>(Settings::settings));
}