mirror of https://github.com/mgba-emu/mgba.git
Qt: Allow setting of audio channels and video layers while games are not running
This commit is contained in:
parent
ea91c48d3e
commit
df11c9d7f3
|
@ -47,6 +47,8 @@ GameController::GameController(QObject* parent)
|
||||||
, m_turboForced(false)
|
, m_turboForced(false)
|
||||||
, m_turboSpeed(-1)
|
, m_turboSpeed(-1)
|
||||||
, m_wasPaused(false)
|
, m_wasPaused(false)
|
||||||
|
, m_audioChannels{ true, true, true, true, true, true }
|
||||||
|
, m_videoLayers{ true, true, true, true, true }
|
||||||
, m_inputController(nullptr)
|
, m_inputController(nullptr)
|
||||||
, m_multiplayer(nullptr)
|
, m_multiplayer(nullptr)
|
||||||
, m_stateSlot(1)
|
, m_stateSlot(1)
|
||||||
|
@ -90,6 +92,17 @@ GameController::GameController(QObject* parent)
|
||||||
context->gba->rtcSource = &controller->m_rtc.d;
|
context->gba->rtcSource = &controller->m_rtc.d;
|
||||||
context->gba->rumble = controller->m_inputController->rumble();
|
context->gba->rumble = controller->m_inputController->rumble();
|
||||||
context->gba->rotationSource = controller->m_inputController->rotationSource();
|
context->gba->rotationSource = controller->m_inputController->rotationSource();
|
||||||
|
context->gba->audio.forceDisableCh[0] = !controller->m_audioChannels[0];
|
||||||
|
context->gba->audio.forceDisableCh[1] = !controller->m_audioChannels[1];
|
||||||
|
context->gba->audio.forceDisableCh[2] = !controller->m_audioChannels[2];
|
||||||
|
context->gba->audio.forceDisableCh[3] = !controller->m_audioChannels[3];
|
||||||
|
context->gba->audio.forceDisableChA = !controller->m_audioChannels[4];
|
||||||
|
context->gba->audio.forceDisableChB = !controller->m_audioChannels[5];
|
||||||
|
context->gba->video.renderer->disableBG[0] = !controller->m_videoLayers[0];
|
||||||
|
context->gba->video.renderer->disableBG[1] = !controller->m_videoLayers[1];
|
||||||
|
context->gba->video.renderer->disableBG[2] = !controller->m_videoLayers[2];
|
||||||
|
context->gba->video.renderer->disableBG[3] = !controller->m_videoLayers[3];
|
||||||
|
context->gba->video.renderer->disableOBJ = !controller->m_videoLayers[4];
|
||||||
controller->m_fpsTarget = context->fpsTarget;
|
controller->m_fpsTarget = context->fpsTarget;
|
||||||
|
|
||||||
if (GBALoadState(context, context->stateDir, 0)) {
|
if (GBALoadState(context, context->stateDir, 0)) {
|
||||||
|
@ -578,6 +591,49 @@ void GameController::setAudioBufferSamples(int samples) {
|
||||||
QMetaObject::invokeMethod(m_audioProcessor, "setBufferSamples", Q_ARG(int, samples));
|
QMetaObject::invokeMethod(m_audioProcessor, "setBufferSamples", Q_ARG(int, samples));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameController::setAudioChannelEnabled(int channel, bool enable) {
|
||||||
|
if (channel > 5 || channel < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_audioChannels[channel] = enable;
|
||||||
|
if (m_gameOpen) {
|
||||||
|
switch (channel) {
|
||||||
|
case 0:
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
case 3:
|
||||||
|
m_threadContext.gba->audio.forceDisableCh[channel] = !enable;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
m_threadContext.gba->audio.forceDisableChA = !enable;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
m_threadContext.gba->audio.forceDisableChB = !enable;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameController::setVideoLayerEnabled(int layer, bool enable) {
|
||||||
|
if (layer > 4 || layer < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_videoLayers[layer] = enable;
|
||||||
|
if (m_gameOpen) {
|
||||||
|
switch (layer) {
|
||||||
|
case 0:
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
case 3:
|
||||||
|
m_threadContext.gba->video.renderer->disableBG[layer] = !enable;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
m_threadContext.gba->video.renderer->disableOBJ = !enable;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GameController::setFPSTarget(float fps) {
|
void GameController::setFPSTarget(float fps) {
|
||||||
threadInterrupt();
|
threadInterrupt();
|
||||||
m_fpsTarget = fps;
|
m_fpsTarget = fps;
|
||||||
|
|
|
@ -117,6 +117,8 @@ public slots:
|
||||||
void keyReleased(int key);
|
void keyReleased(int key);
|
||||||
void clearKeys();
|
void clearKeys();
|
||||||
void setAudioBufferSamples(int samples);
|
void setAudioBufferSamples(int samples);
|
||||||
|
void setAudioChannelEnabled(int channel, bool enable = true);
|
||||||
|
void setVideoLayerEnabled(int layer, bool enable = true);
|
||||||
void setFPSTarget(float fps);
|
void setFPSTarget(float fps);
|
||||||
void loadState(int slot = 0);
|
void loadState(int slot = 0);
|
||||||
void saveState(int slot = 0);
|
void saveState(int slot = 0);
|
||||||
|
@ -193,6 +195,9 @@ private:
|
||||||
QTimer m_rewindTimer;
|
QTimer m_rewindTimer;
|
||||||
bool m_wasPaused;
|
bool m_wasPaused;
|
||||||
|
|
||||||
|
bool m_audioChannels[6];
|
||||||
|
bool m_videoLayers[5];
|
||||||
|
|
||||||
int m_stateSlot;
|
int m_stateSlot;
|
||||||
GBASerializedState* m_backupLoadState;
|
GBASerializedState* m_backupLoadState;
|
||||||
QByteArray m_backupSaveState;
|
QByteArray m_backupSaveState;
|
||||||
|
|
|
@ -1011,16 +1011,14 @@ void Window::setupMenu(QMenuBar* menubar) {
|
||||||
QAction* enableBg = new QAction(tr("Background %0").arg(i), videoLayers);
|
QAction* enableBg = new QAction(tr("Background %0").arg(i), videoLayers);
|
||||||
enableBg->setCheckable(true);
|
enableBg->setCheckable(true);
|
||||||
enableBg->setChecked(true);
|
enableBg->setChecked(true);
|
||||||
connect(enableBg, &QAction::triggered, [this, i](bool enable) { m_controller->thread()->gba->video.renderer->disableBG[i] = !enable; });
|
connect(enableBg, &QAction::triggered, [this, i](bool enable) { m_controller->setVideoLayerEnabled(i, enable); });
|
||||||
m_gameActions.append(enableBg);
|
|
||||||
addControlledAction(videoLayers, enableBg, QString("enableBG%0").arg(i));
|
addControlledAction(videoLayers, enableBg, QString("enableBG%0").arg(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
QAction* enableObj = new QAction(tr("OBJ (sprites)"), videoLayers);
|
QAction* enableObj = new QAction(tr("OBJ (sprites)"), videoLayers);
|
||||||
enableObj->setCheckable(true);
|
enableObj->setCheckable(true);
|
||||||
enableObj->setChecked(true);
|
enableObj->setChecked(true);
|
||||||
connect(enableObj, &QAction::triggered, [this](bool enable) { m_controller->thread()->gba->video.renderer->disableOBJ = !enable; });
|
connect(enableObj, &QAction::triggered, [this](bool enable) { m_controller->setVideoLayerEnabled(4, enable); });
|
||||||
m_gameActions.append(enableObj);
|
|
||||||
addControlledAction(videoLayers, enableObj, "enableOBJ");
|
addControlledAction(videoLayers, enableObj, "enableOBJ");
|
||||||
|
|
||||||
QMenu* audioChannels = avMenu->addMenu(tr("Audio channels"));
|
QMenu* audioChannels = avMenu->addMenu(tr("Audio channels"));
|
||||||
|
@ -1029,23 +1027,20 @@ void Window::setupMenu(QMenuBar* menubar) {
|
||||||
QAction* enableCh = new QAction(tr("Channel %0").arg(i + 1), audioChannels);
|
QAction* enableCh = new QAction(tr("Channel %0").arg(i + 1), audioChannels);
|
||||||
enableCh->setCheckable(true);
|
enableCh->setCheckable(true);
|
||||||
enableCh->setChecked(true);
|
enableCh->setChecked(true);
|
||||||
connect(enableCh, &QAction::triggered, [this, i](bool enable) { m_controller->thread()->gba->audio.forceDisableCh[i] = !enable; });
|
connect(enableCh, &QAction::triggered, [this, i](bool enable) { m_controller->setAudioChannelEnabled(i, enable); });
|
||||||
m_gameActions.append(enableCh);
|
|
||||||
addControlledAction(audioChannels, enableCh, QString("enableCh%0").arg(i + 1));
|
addControlledAction(audioChannels, enableCh, QString("enableCh%0").arg(i + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
QAction* enableChA = new QAction(tr("Channel A"), audioChannels);
|
QAction* enableChA = new QAction(tr("Channel A"), audioChannels);
|
||||||
enableChA->setCheckable(true);
|
enableChA->setCheckable(true);
|
||||||
enableChA->setChecked(true);
|
enableChA->setChecked(true);
|
||||||
connect(enableChA, &QAction::triggered, [this, i](bool enable) { m_controller->thread()->gba->audio.forceDisableChA = !enable; });
|
connect(enableChA, &QAction::triggered, [this, i](bool enable) { m_controller->setAudioChannelEnabled(4, enable); });
|
||||||
m_gameActions.append(enableChA);
|
|
||||||
addControlledAction(audioChannels, enableChA, QString("enableChA"));
|
addControlledAction(audioChannels, enableChA, QString("enableChA"));
|
||||||
|
|
||||||
QAction* enableChB = new QAction(tr("Channel B"), audioChannels);
|
QAction* enableChB = new QAction(tr("Channel B"), audioChannels);
|
||||||
enableChB->setCheckable(true);
|
enableChB->setCheckable(true);
|
||||||
enableChB->setChecked(true);
|
enableChB->setChecked(true);
|
||||||
connect(enableChB, &QAction::triggered, [this, i](bool enable) { m_controller->thread()->gba->audio.forceDisableChB = !enable; });
|
connect(enableChB, &QAction::triggered, [this, i](bool enable) { m_controller->setAudioChannelEnabled(5, enable); });
|
||||||
m_gameActions.append(enableChB);
|
|
||||||
addControlledAction(audioChannels, enableChB, QString("enableChB"));
|
addControlledAction(audioChannels, enableChB, QString("enableChB"));
|
||||||
|
|
||||||
QMenu* toolsMenu = menubar->addMenu(tr("&Tools"));
|
QMenu* toolsMenu = menubar->addMenu(tr("&Tools"));
|
||||||
|
|
Loading…
Reference in New Issue