mirror of
https://github.com/TomHarte/CLK.git
synced 2025-01-26 15:32:04 +00:00
commit
a1da6db0ee
@ -1,4 +1,5 @@
|
||||
QT += core gui multimedia widgets openglwidgets
|
||||
QT += core gui multimedia widgets
|
||||
greaterThan(5, QT_MAJOR_VERSION) QT += openglwidgets
|
||||
|
||||
# Be specific about C++17 but also try the vaguer C++1z for older
|
||||
# versions of Qt.
|
||||
@ -25,7 +26,7 @@ DEFINES += IGNORE_APPLE
|
||||
QMAKE_CXXFLAGS_RELEASE += -DNDEBUG
|
||||
|
||||
# Generate warnings for any use of APIs deprecated prior to Qt 7.0.0.
|
||||
# Development was performed against Qt 6.6.1.
|
||||
# Development was performed against Qt 6.6.1 and Qt 5.15.2
|
||||
DEFINES += QT_DEPRECATED_WARNINGS
|
||||
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x070000
|
||||
|
||||
|
@ -2,14 +2,17 @@
|
||||
#include "settings.h"
|
||||
#include "timer.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
#include <QObject>
|
||||
#include <QStandardPaths>
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
#include <QAudioDevice>
|
||||
#include <QMediaDevices>
|
||||
#endif
|
||||
|
||||
#include <QtWidgets>
|
||||
#include <QtGlobal>
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
@ -317,16 +320,32 @@ void MainWindow::launchMachine() {
|
||||
static constexpr size_t samplesPerBuffer = 256; // TODO: select this dynamically.
|
||||
const auto speaker = audio_producer->get_speaker();
|
||||
if(speaker) {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QAudioDevice device(QMediaDevices::defaultAudioOutput());
|
||||
if(true) { // TODO: how to check that audio output is available in Qt6?
|
||||
QAudioFormat idealFormat = device.preferredFormat();
|
||||
#else
|
||||
const QAudioDeviceInfo &defaultDeviceInfo = QAudioDeviceInfo::defaultOutputDevice();
|
||||
if(!defaultDeviceInfo.isNull()) {
|
||||
QAudioFormat idealFormat = defaultDeviceInfo.preferredFormat();
|
||||
#endif
|
||||
|
||||
// Use the ideal format's sample rate, provide stereo as long as at least two channels
|
||||
// are available, and — at least for now — assume a good buffer size.
|
||||
audioIsStereo = (idealFormat.channelCount() > 1) && speaker->get_is_stereo();
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
audioIs8bit = idealFormat.sampleFormat() == QAudioFormat::UInt8;
|
||||
#else
|
||||
audioIs8bit = idealFormat.sampleSize() < 16;
|
||||
#endif
|
||||
|
||||
idealFormat.setChannelCount(1 + int(audioIsStereo));
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
idealFormat.setSampleFormat(audioIs8bit ? QAudioFormat::UInt8 : QAudioFormat::Int16);
|
||||
#else
|
||||
idealFormat.setSampleSize(audioIs8bit ? 8 : 16);
|
||||
#endif
|
||||
|
||||
speaker->set_output_rate(idealFormat.sampleRate(), samplesPerBuffer, audioIsStereo);
|
||||
speaker->set_delegate(this);
|
||||
@ -334,7 +353,11 @@ void MainWindow::launchMachine() {
|
||||
audioThread.start();
|
||||
audioThread.performAsync([&] {
|
||||
// Create an audio output.
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
audioOutput = std::make_unique<QAudioSink>(device, idealFormat);
|
||||
#else
|
||||
audioOutput = std::make_unique<QAudioOutput>(idealFormat);
|
||||
#endif
|
||||
|
||||
// Start the output. The additional `audioBuffer` is meant to minimise latency,
|
||||
// believe it or not, given Qt's semantics.
|
||||
@ -376,13 +399,17 @@ void MainWindow::launchMachine() {
|
||||
QAction *const asKeyboardAction = new QAction(tr("Use Keyboard as Keyboard"), this);
|
||||
asKeyboardAction->setCheckable(true);
|
||||
asKeyboardAction->setChecked(true);
|
||||
// asKeyboardAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_K));
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
asKeyboardAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_K));
|
||||
#endif
|
||||
inputMenu->addAction(asKeyboardAction);
|
||||
|
||||
QAction *const asJoystickAction = new QAction(tr("Use Keyboard as Joystick"), this);
|
||||
asJoystickAction->setCheckable(true);
|
||||
asJoystickAction->setChecked(false);
|
||||
// asJoystickAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_J));
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
asJoystickAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_J));
|
||||
#endif
|
||||
inputMenu->addAction(asJoystickAction);
|
||||
|
||||
connect(asKeyboardAction, &QAction::triggered, this, [=] {
|
||||
|
@ -1,7 +1,14 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QAudioSink>
|
||||
#include <QtGlobal>
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
#include <QAudioSink>
|
||||
#else
|
||||
#include <QAudioOutput>
|
||||
#endif
|
||||
|
||||
#include <QMainWindow>
|
||||
|
||||
#include <memory>
|
||||
@ -70,7 +77,11 @@ class MainWindow : public QMainWindow, public Outputs::Speaker::Speaker::Delegat
|
||||
std::unique_ptr<Machine::DynamicMachine> machine;
|
||||
std::mutex machineMutex;
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
std::unique_ptr<QAudioSink> audioOutput;
|
||||
#else
|
||||
std::unique_ptr<QAudioOutput> audioOutput;
|
||||
#endif
|
||||
bool audioIs8bit = false, audioIsStereo = false;
|
||||
void speaker_did_complete_samples(Outputs::Speaker::Speaker *speaker, const std::vector<int16_t> &buffer) override;
|
||||
AudioBuffer audioBuffer;
|
||||
|
@ -39,7 +39,7 @@
|
||||
<item>
|
||||
<layout class="QFormLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<widget class="QLabel">
|
||||
<property name="text">
|
||||
<string>Chip RAM:</string>
|
||||
</property>
|
||||
@ -65,7 +65,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<widget class="QLabel">
|
||||
<property name="text">
|
||||
<string>Fast RAM:</string>
|
||||
</property>
|
||||
@ -129,7 +129,7 @@
|
||||
<item>
|
||||
<layout class="QFormLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<widget class="QLabel">
|
||||
<property name="text">
|
||||
<string>Model:</string>
|
||||
</property>
|
||||
@ -160,7 +160,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<widget class="QLabel">
|
||||
<property name="text">
|
||||
<string>Disk Controller:</string>
|
||||
</property>
|
||||
@ -214,7 +214,7 @@
|
||||
<item>
|
||||
<layout class="QFormLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<widget class="QLabel">
|
||||
<property name="text">
|
||||
<string>Model:</string>
|
||||
</property>
|
||||
@ -240,7 +240,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<widget class="QLabel">
|
||||
<property name="text">
|
||||
<string>Memory Size:</string>
|
||||
</property>
|
||||
@ -294,7 +294,7 @@
|
||||
<item>
|
||||
<layout class="QFormLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<widget class="QLabel">
|
||||
<property name="text">
|
||||
<string>Model:</string>
|
||||
</property>
|
||||
@ -348,7 +348,7 @@
|
||||
<item>
|
||||
<layout class="QFormLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<widget class="QLabel">
|
||||
<property name="text">
|
||||
<string>RAM:</string>
|
||||
</property>
|
||||
@ -437,7 +437,7 @@
|
||||
<item>
|
||||
<layout class="QFormLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<widget class="QLabel">
|
||||
<property name="text">
|
||||
<string>Model:</string>
|
||||
</property>
|
||||
@ -463,7 +463,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<widget class="QLabel">
|
||||
<property name="text">
|
||||
<string>Speed:</string>
|
||||
</property>
|
||||
@ -484,7 +484,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<widget class="QLabel">
|
||||
<property name="text">
|
||||
<string>EXOS:</string>
|
||||
</property>
|
||||
@ -510,7 +510,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<widget class="QLabel">
|
||||
<property name="text">
|
||||
<string>BASIC:</string>
|
||||
</property>
|
||||
@ -541,7 +541,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<widget class="QLabel">
|
||||
<property name="text">
|
||||
<string>DOS:</string>
|
||||
</property>
|
||||
@ -590,7 +590,7 @@
|
||||
<item>
|
||||
<layout class="QFormLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<widget class="QLabel">
|
||||
<property name="text">
|
||||
<string>Model:</string>
|
||||
</property>
|
||||
@ -649,7 +649,7 @@
|
||||
<item>
|
||||
<layout class="QFormLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<widget class="QLabel">
|
||||
<property name="text">
|
||||
<string>Model</string>
|
||||
</property>
|
||||
@ -691,7 +691,7 @@
|
||||
<item>
|
||||
<layout class="QFormLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<widget class="QLabel">
|
||||
<property name="text">
|
||||
<string>Region</string>
|
||||
</property>
|
||||
@ -772,7 +772,7 @@
|
||||
<item>
|
||||
<layout class="QFormLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<widget class="QLabel">
|
||||
<property name="text">
|
||||
<string>Model:</string>
|
||||
</property>
|
||||
@ -798,7 +798,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<widget class="QLabel">
|
||||
<property name="text">
|
||||
<string>Disk Interface:</string>
|
||||
</property>
|
||||
@ -862,7 +862,7 @@
|
||||
<item>
|
||||
<layout class="QFormLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<widget class="QLabel">
|
||||
<property name="text">
|
||||
<string>Video Adaptor:</string>
|
||||
</property>
|
||||
@ -883,7 +883,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<widget class="QLabel">
|
||||
<property name="text">
|
||||
<string>Speed:</string>
|
||||
</property>
|
||||
@ -932,7 +932,7 @@
|
||||
<item>
|
||||
<layout class="QFormLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<widget class="QLabel">
|
||||
<property name="text">
|
||||
<string>Region:</string>
|
||||
</property>
|
||||
@ -968,7 +968,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<widget class="QLabel">
|
||||
<property name="text">
|
||||
<string>Memory Size:</string>
|
||||
</property>
|
||||
@ -1042,7 +1042,7 @@
|
||||
<item>
|
||||
<layout class="QFormLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<widget class="QLabel">
|
||||
<property name="text">
|
||||
<string>Memory Size:</string>
|
||||
</property>
|
||||
@ -1111,7 +1111,7 @@
|
||||
<item>
|
||||
<layout class="QFormLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<widget class="QLabel">
|
||||
<property name="text">
|
||||
<string>Memory Size:</string>
|
||||
</property>
|
||||
@ -1160,7 +1160,7 @@
|
||||
<item>
|
||||
<layout class="QFormLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<widget class="QLabel">
|
||||
<property name="text">
|
||||
<string>Model:</string>
|
||||
</property>
|
||||
|
Loading…
x
Reference in New Issue
Block a user