2022-02-07 15:00:02 +06:00
|
|
|
/*
|
2023-01-06 15:36:05 -05:00
|
|
|
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
|
|
|
|
* running old operating systems and software designed for IBM
|
|
|
|
|
* PC systems and compatibles from 1981 through fairly recent
|
|
|
|
|
* system designs based on the PCI bus.
|
2022-02-07 15:00:02 +06:00
|
|
|
*
|
2023-01-06 15:36:05 -05:00
|
|
|
* This file is part of the 86Box distribution.
|
2022-02-07 15:00:02 +06:00
|
|
|
*
|
2023-01-06 15:36:05 -05:00
|
|
|
* Serial/Parallel ports configuration UI module.
|
2022-02-07 15:00:02 +06:00
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
*
|
2023-01-06 15:36:05 -05:00
|
|
|
* Authors: Joakim L. Gilje <jgilje@jgilje.net>
|
2022-02-07 16:09:01 +06:00
|
|
|
* Cacodemon345
|
2022-02-07 15:00:02 +06:00
|
|
|
*
|
2023-01-06 15:36:05 -05:00
|
|
|
* Copyright 2022 Cacodemon345
|
|
|
|
|
* Copyright 2022 Jasmine Iwanek
|
|
|
|
|
* Copyright 2021 Joakim L. Gilje
|
2022-02-07 15:00:02 +06:00
|
|
|
*/
|
2021-11-25 10:20:56 +01:00
|
|
|
#include "qt_settingsports.hpp"
|
|
|
|
|
#include "ui_qt_settingsports.h"
|
|
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
#include <86box/86box.h>
|
|
|
|
|
#include <86box/timer.h>
|
|
|
|
|
#include <86box/device.h>
|
|
|
|
|
#include <86box/machine.h>
|
|
|
|
|
#include <86box/lpt.h>
|
2022-07-28 16:50:49 -04:00
|
|
|
#include <86box/serial.h>
|
2023-02-14 20:37:58 -05:00
|
|
|
#include <86box/serial_passthrough.h>
|
2021-11-25 10:20:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#include "qt_deviceconfig.hpp"
|
|
|
|
|
#include "qt_models_common.hpp"
|
|
|
|
|
|
2022-11-19 08:49:04 -05:00
|
|
|
SettingsPorts::SettingsPorts(QWidget *parent)
|
|
|
|
|
: QWidget(parent)
|
|
|
|
|
, ui(new Ui::SettingsPorts)
|
2021-11-25 10:20:56 +01:00
|
|
|
{
|
|
|
|
|
ui->setupUi(this);
|
2025-03-01 15:22:36 +05:00
|
|
|
onCurrentMachineChanged(machine);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SettingsPorts::~SettingsPorts()
|
|
|
|
|
{
|
|
|
|
|
delete ui;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
SettingsPorts::save()
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < PARALLEL_MAX; i++) {
|
|
|
|
|
auto *cbox = findChild<QComboBox *>(QString("comboBoxLpt%1").arg(i + 1));
|
|
|
|
|
auto *checkBox = findChild<QCheckBox *>(QString("checkBoxParallel%1").arg(i + 1));
|
|
|
|
|
if (cbox != NULL)
|
|
|
|
|
lpt_ports[i].device = cbox->currentData().toInt();
|
|
|
|
|
if (checkBox != NULL)
|
|
|
|
|
lpt_ports[i].enabled = checkBox->isChecked() ? 1 : 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < SERIAL_MAX; i++) {
|
|
|
|
|
auto *checkBox = findChild<QCheckBox *>(QString("checkBoxSerial%1").arg(i + 1));
|
|
|
|
|
auto *checkBoxPass = findChild<QCheckBox *>(QString("checkBoxSerialPassThru%1").arg(i + 1));
|
|
|
|
|
if (checkBox != NULL)
|
|
|
|
|
com_ports[i].enabled = checkBox->isChecked() ? 1 : 0;
|
|
|
|
|
if (checkBoxPass != NULL)
|
|
|
|
|
serial_passthrough_enabled[i] = checkBoxPass->isChecked();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
SettingsPorts::onCurrentMachineChanged(int machineId)
|
|
|
|
|
{
|
|
|
|
|
this->machineId = machineId;
|
2021-11-25 10:20:56 +01:00
|
|
|
|
2025-03-30 03:40:08 +02:00
|
|
|
int c = 0;
|
|
|
|
|
|
|
|
|
|
// LPT Device
|
|
|
|
|
QComboBox * cbox[PARALLEL_MAX] = { 0 };
|
|
|
|
|
QAbstractItemModel *models[PARALLEL_MAX] = { 0 };
|
|
|
|
|
int removeRows_[PARALLEL_MAX] = { 0 };
|
|
|
|
|
int selectedRows[PARALLEL_MAX] = { 0 };
|
|
|
|
|
|
|
|
|
|
for (uint8_t i = 0; i < PARALLEL_MAX; ++i) {
|
|
|
|
|
cbox[i] = findChild<QComboBox *>(QString("comboBoxLpt%1").arg(i + 1));
|
|
|
|
|
models[i] = cbox[i]->model();
|
|
|
|
|
removeRows_[i] = models[i]->rowCount();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (true) {
|
|
|
|
|
const char *lptName = lpt_device_get_name(c);
|
|
|
|
|
|
|
|
|
|
if (lptName == nullptr)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
const QString name = tr(lptName);
|
|
|
|
|
|
|
|
|
|
for (uint8_t i = 0; i < PARALLEL_MAX; ++i) {
|
|
|
|
|
int row = Models::AddEntry(models[i], name, c);
|
|
|
|
|
|
|
|
|
|
if (c == lpt_ports[i].device)
|
|
|
|
|
selectedRows[i] = row - removeRows_[i];
|
2021-11-25 10:20:56 +01:00
|
|
|
}
|
2025-03-30 03:40:08 +02:00
|
|
|
|
|
|
|
|
c++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (uint8_t i = 0; i < PARALLEL_MAX; ++i) {
|
|
|
|
|
models[i]->removeRows(0, removeRows_[i]);
|
|
|
|
|
cbox[i]->setEnabled(models[i]->rowCount() > 1);
|
|
|
|
|
cbox[i]->setCurrentIndex(-1);
|
|
|
|
|
cbox[i]->setCurrentIndex(selectedRows[i]);
|
2021-11-25 10:20:56 +01:00
|
|
|
|
2022-11-19 08:49:04 -05:00
|
|
|
auto *checkBox = findChild<QCheckBox *>(QString("checkBoxParallel%1").arg(i + 1));
|
2024-06-29 18:57:52 -04:00
|
|
|
if (checkBox != NULL)
|
|
|
|
|
checkBox->setChecked(lpt_ports[i].enabled > 0);
|
2025-03-30 03:40:08 +02:00
|
|
|
if (cbox[i] != NULL)
|
|
|
|
|
cbox[i]->setEnabled(lpt_ports[i].enabled > 0);
|
2021-11-25 10:20:56 +01:00
|
|
|
}
|
|
|
|
|
|
2022-02-20 00:33:47 -05:00
|
|
|
for (int i = 0; i < SERIAL_MAX; i++) {
|
2024-06-29 19:11:59 -04:00
|
|
|
auto *checkBox = findChild<QCheckBox *>(QString("checkBoxSerial%1").arg(i + 1));
|
|
|
|
|
auto *checkBoxPass = findChild<QCheckBox *>(QString("checkBoxSerialPassThru%1").arg(i + 1));
|
2025-03-01 02:01:00 +05:00
|
|
|
auto *buttonPass = findChild<QPushButton *>(QString("pushButtonSerialPassThru%1").arg(i + 1));
|
2024-06-29 18:57:52 -04:00
|
|
|
if (checkBox != NULL)
|
|
|
|
|
checkBox->setChecked(com_ports[i].enabled > 0);
|
2025-03-01 02:01:00 +05:00
|
|
|
if (checkBoxPass != NULL) {
|
2025-03-01 02:05:30 +05:00
|
|
|
checkBoxPass->setEnabled(com_ports[i].enabled > 0);
|
2024-06-29 19:11:59 -04:00
|
|
|
checkBoxPass->setChecked(serial_passthrough_enabled[i]);
|
2025-03-01 02:05:30 +05:00
|
|
|
buttonPass->setEnabled((com_ports[i].enabled > 0) && serial_passthrough_enabled[i]);
|
2025-03-01 02:01:00 +05:00
|
|
|
}
|
2021-11-25 10:20:56 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-19 08:49:04 -05:00
|
|
|
void
|
|
|
|
|
SettingsPorts::on_checkBoxParallel1_stateChanged(int state)
|
|
|
|
|
{
|
2021-11-25 10:20:56 +01:00
|
|
|
ui->comboBoxLpt1->setEnabled(state == Qt::Checked);
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-19 08:49:04 -05:00
|
|
|
void
|
|
|
|
|
SettingsPorts::on_checkBoxParallel2_stateChanged(int state)
|
|
|
|
|
{
|
2021-11-25 10:20:56 +01:00
|
|
|
ui->comboBoxLpt2->setEnabled(state == Qt::Checked);
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-19 08:49:04 -05:00
|
|
|
void
|
|
|
|
|
SettingsPorts::on_checkBoxParallel3_stateChanged(int state)
|
|
|
|
|
{
|
2021-11-25 10:20:56 +01:00
|
|
|
ui->comboBoxLpt3->setEnabled(state == Qt::Checked);
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-19 08:49:04 -05:00
|
|
|
void
|
|
|
|
|
SettingsPorts::on_checkBoxParallel4_stateChanged(int state)
|
|
|
|
|
{
|
2022-02-07 16:07:07 +06:00
|
|
|
ui->comboBoxLpt4->setEnabled(state == Qt::Checked);
|
|
|
|
|
}
|
2023-02-14 20:37:58 -05:00
|
|
|
|
|
|
|
|
void
|
2025-03-01 02:05:30 +05:00
|
|
|
SettingsPorts::on_checkBoxSerial1_stateChanged(int state)
|
|
|
|
|
{
|
|
|
|
|
ui->checkBoxSerialPassThru1->setEnabled(state == Qt::Checked);
|
|
|
|
|
ui->pushButtonSerialPassThru1->setEnabled((state == Qt::Checked) && ui->checkBoxSerialPassThru1->isChecked());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
SettingsPorts::on_checkBoxSerial2_stateChanged(int state)
|
|
|
|
|
{
|
|
|
|
|
ui->checkBoxSerialPassThru2->setEnabled(state == Qt::Checked);
|
|
|
|
|
ui->pushButtonSerialPassThru2->setEnabled((state == Qt::Checked) && ui->checkBoxSerialPassThru2->isChecked());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
SettingsPorts::on_checkBoxSerial3_stateChanged(int state)
|
|
|
|
|
{
|
|
|
|
|
ui->checkBoxSerialPassThru3->setEnabled(state == Qt::Checked);
|
|
|
|
|
ui->pushButtonSerialPassThru3->setEnabled((state == Qt::Checked) && ui->checkBoxSerialPassThru3->isChecked());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
SettingsPorts::on_checkBoxSerial4_stateChanged(int state)
|
|
|
|
|
{
|
|
|
|
|
ui->checkBoxSerialPassThru4->setEnabled(state == Qt::Checked);
|
|
|
|
|
ui->pushButtonSerialPassThru4->setEnabled((state == Qt::Checked) && ui->checkBoxSerialPassThru4->isChecked());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
void
|
|
|
|
|
SettingsPorts::on_checkBoxSerial5_stateChanged(int state)
|
|
|
|
|
{
|
|
|
|
|
ui->checkBoxSerialPassThru5->setEnabled(state == Qt::Checked);
|
|
|
|
|
ui->pushButtonSerialPassThru5->setEnabled((state == Qt::Checked) && ui->checkBoxSerialPassThru5->isChecked());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
SettingsPorts::on_checkBoxSerial6_stateChanged(int state)
|
|
|
|
|
{
|
|
|
|
|
ui->checkBoxSerialPassThru6->setEnabled(state == Qt::Checked);
|
|
|
|
|
ui->pushButtonSerialPassThru6->setEnabled((state == Qt::Checked) && ui->checkBoxSerialPassThru6->isChecked());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
SettingsPorts::on_checkBoxSerial7_stateChanged(int state)
|
|
|
|
|
{
|
|
|
|
|
ui->checkBoxSerialPassThru7->setEnabled(state == Qt::Checked);
|
|
|
|
|
ui->pushButtonSerialPassThru7->setEnabled((state == Qt::Checked) && ui->checkBoxSerialPassThru7->isChecked());
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
void
|
2025-03-01 02:01:00 +05:00
|
|
|
SettingsPorts::on_checkBoxSerialPassThru1_stateChanged(int state)
|
2023-02-14 20:37:58 -05:00
|
|
|
{
|
2025-03-01 02:01:00 +05:00
|
|
|
ui->pushButtonSerialPassThru1->setEnabled(state == Qt::Checked);
|
2023-02-14 20:37:58 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2025-03-01 02:01:00 +05:00
|
|
|
SettingsPorts::on_checkBoxSerialPassThru2_stateChanged(int state)
|
2023-02-14 20:37:58 -05:00
|
|
|
{
|
2025-03-01 02:01:00 +05:00
|
|
|
ui->pushButtonSerialPassThru2->setEnabled(state == Qt::Checked);
|
2023-02-14 20:37:58 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2025-03-01 02:01:00 +05:00
|
|
|
SettingsPorts::on_checkBoxSerialPassThru3_stateChanged(int state)
|
2023-02-14 20:37:58 -05:00
|
|
|
{
|
2025-03-01 02:01:00 +05:00
|
|
|
ui->pushButtonSerialPassThru3->setEnabled(state == Qt::Checked);
|
2023-02-14 20:37:58 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2025-03-01 02:01:00 +05:00
|
|
|
SettingsPorts::on_checkBoxSerialPassThru4_stateChanged(int state)
|
2023-02-14 20:37:58 -05:00
|
|
|
{
|
2025-03-01 02:01:00 +05:00
|
|
|
ui->pushButtonSerialPassThru4->setEnabled(state == Qt::Checked);
|
2023-02-14 20:37:58 -05:00
|
|
|
}
|
2024-06-29 19:11:37 -04:00
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
void
|
2025-03-01 02:01:00 +05:00
|
|
|
SettingsPorts::on_checkBoxSerialPassThru5_stateChanged(int state)
|
2024-06-29 19:11:37 -04:00
|
|
|
{
|
2025-03-01 02:01:00 +05:00
|
|
|
ui->pushButtonSerialPassThru5->setEnabled(state == Qt::Checked);
|
2024-06-29 19:11:37 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2025-03-01 02:01:00 +05:00
|
|
|
SettingsPorts::on_checkBoxSerialPassThru6_stateChanged(int state)
|
2024-06-29 19:11:37 -04:00
|
|
|
{
|
2025-03-01 02:01:00 +05:00
|
|
|
ui->pushButtonSerialPassThru6->setEnabled(state == Qt::Checked);
|
2024-06-29 19:11:37 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2025-03-01 02:01:00 +05:00
|
|
|
SettingsPorts::on_checkBoxSerialPassThru7_stateChanged(int state)
|
2024-06-29 19:11:37 -04:00
|
|
|
{
|
2025-03-01 02:01:00 +05:00
|
|
|
ui->pushButtonSerialPassThru7->setEnabled(state == Qt::Checked);
|
2024-06-29 19:11:37 -04:00
|
|
|
}
|
2025-01-06 22:40:18 -05:00
|
|
|
#endif
|
2025-03-01 15:22:36 +05:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
SettingsPorts::on_pushButtonSerialPassThru1_clicked()
|
|
|
|
|
{
|
|
|
|
|
DeviceConfig::ConfigureDevice(&serial_passthrough_device, 1, qobject_cast<Settings *>(Settings::settings));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
SettingsPorts::on_pushButtonSerialPassThru2_clicked()
|
|
|
|
|
{
|
|
|
|
|
DeviceConfig::ConfigureDevice(&serial_passthrough_device, 2, qobject_cast<Settings *>(Settings::settings));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
SettingsPorts::on_pushButtonSerialPassThru3_clicked()
|
|
|
|
|
{
|
|
|
|
|
DeviceConfig::ConfigureDevice(&serial_passthrough_device, 3, qobject_cast<Settings *>(Settings::settings));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
SettingsPorts::on_pushButtonSerialPassThru4_clicked()
|
|
|
|
|
{
|
|
|
|
|
DeviceConfig::ConfigureDevice(&serial_passthrough_device, 4, qobject_cast<Settings *>(Settings::settings));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
void
|
|
|
|
|
SettingsPorts::on_pushButtonSerialPassThru5_clicked()
|
|
|
|
|
{
|
|
|
|
|
DeviceConfig::ConfigureDevice(&serial_passthrough_device, 5, qobject_cast<Settings *>(Settings::settings));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
SettingsPorts::on_pushButtonSerialPassThru6_clicked()
|
|
|
|
|
{
|
|
|
|
|
DeviceConfig::ConfigureDevice(&serial_passthrough_device, 6, qobject_cast<Settings *>(Settings::settings));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
SettingsPorts::on_pushButtonSerialPassThru7_clicked()
|
|
|
|
|
{
|
|
|
|
|
DeviceConfig::ConfigureDevice(&serial_passthrough_device, 7, qobject_cast<Settings *>(Settings::settings));
|
|
|
|
|
}
|
|
|
|
|
#endif
|