mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2024-11-14 13:27:41 -07:00
reimplement MP audio mode 2 (active instance only)
Some checks are pending
macOS / ${{ matrix.arch }} (arm64) (push) Waiting to run
macOS / ${{ matrix.arch }} (x86_64) (push) Waiting to run
macOS / Universal binary (push) Blocked by required conditions
Ubuntu / x86_64 (push) Waiting to run
Ubuntu / aarch64 (push) Waiting to run
Windows / build (push) Waiting to run
Some checks are pending
macOS / ${{ matrix.arch }} (arm64) (push) Waiting to run
macOS / ${{ matrix.arch }} (x86_64) (push) Waiting to run
macOS / Universal binary (push) Blocked by required conditions
Ubuntu / x86_64 (push) Waiting to run
Ubuntu / aarch64 (push) Waiting to run
Windows / build (push) Waiting to run
This commit is contained in:
parent
58ee191cc8
commit
7740634e6a
@ -133,6 +133,7 @@ void EmuInstance::micCallback(void* data, Uint8* stream, int len)
|
|||||||
void EmuInstance::audioMute()
|
void EmuInstance::audioMute()
|
||||||
{
|
{
|
||||||
audioMuted = false;
|
audioMuted = false;
|
||||||
|
if (numEmuInstances() < 2) return;
|
||||||
|
|
||||||
switch (mpAudioMode)
|
switch (mpAudioMode)
|
||||||
{
|
{
|
||||||
@ -141,10 +142,16 @@ void EmuInstance::audioMute()
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 2: // only currently focused instance
|
case 2: // only currently focused instance
|
||||||
//if (mainWindow != nullptr)
|
audioMuted = true;
|
||||||
// audioMuted = !mainWindow->isActiveWindow();
|
for (int i = 0; i < kMaxWindows; i++)
|
||||||
// TODO!!
|
{
|
||||||
printf("TODO!! audioMute mode 2\n");
|
if (!windowList[i]) continue;
|
||||||
|
if (windowList[i]->isFocused())
|
||||||
|
{
|
||||||
|
audioMuted = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -385,6 +385,10 @@ bool ScreenPanel::event(QEvent* event)
|
|||||||
touchEvent((QTouchEvent*)event);
|
touchEvent((QTouchEvent*)event);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else if (event->type() == QEvent::FocusIn)
|
||||||
|
mainWindow->onFocusIn();
|
||||||
|
else if (event->type() == QEvent::FocusOut)
|
||||||
|
mainWindow->onFocusOut();
|
||||||
|
|
||||||
return QWidget::event(event);
|
return QWidget::event(event);
|
||||||
}
|
}
|
||||||
|
@ -235,7 +235,8 @@ MainWindow::MainWindow(int id, EmuInstance* inst, QWidget* parent) :
|
|||||||
localCfg(inst->localCfg),
|
localCfg(inst->localCfg),
|
||||||
windowCfg(localCfg.GetTable("Window"+std::to_string(id), "Window0")),
|
windowCfg(localCfg.GetTable("Window"+std::to_string(id), "Window0")),
|
||||||
emuThread(inst->getEmuThread()),
|
emuThread(inst->getEmuThread()),
|
||||||
enabledSaved(false)
|
enabledSaved(false),
|
||||||
|
focused(true)
|
||||||
{
|
{
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
if (!parent)
|
if (!parent)
|
||||||
@ -1015,13 +1016,26 @@ void MainWindow::dropEvent(QDropEvent* event)
|
|||||||
|
|
||||||
void MainWindow::focusInEvent(QFocusEvent* event)
|
void MainWindow::focusInEvent(QFocusEvent* event)
|
||||||
{
|
{
|
||||||
emuInstance->audioMute();
|
onFocusIn();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::focusOutEvent(QFocusEvent* event)
|
void MainWindow::focusOutEvent(QFocusEvent* event)
|
||||||
|
{
|
||||||
|
onFocusOut();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::onFocusIn()
|
||||||
|
{
|
||||||
|
focused = true;
|
||||||
|
if (emuInstance)
|
||||||
|
emuInstance->audioMute();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::onFocusOut()
|
||||||
{
|
{
|
||||||
// focusOutEvent is called through the window close event handler
|
// focusOutEvent is called through the window close event handler
|
||||||
// prevent use after free
|
// prevent use after free
|
||||||
|
focused = false;
|
||||||
if (emuInstance)
|
if (emuInstance)
|
||||||
emuInstance->audioMute();
|
emuInstance->audioMute();
|
||||||
}
|
}
|
||||||
|
@ -131,6 +131,10 @@ public:
|
|||||||
|
|
||||||
void onAppStateChanged(Qt::ApplicationState state);
|
void onAppStateChanged(Qt::ApplicationState state);
|
||||||
|
|
||||||
|
void onFocusIn();
|
||||||
|
void onFocusOut();
|
||||||
|
bool isFocused() { return focused; }
|
||||||
|
|
||||||
void osdAddMessage(unsigned int color, const char* msg);
|
void osdAddMessage(unsigned int color, const char* msg);
|
||||||
|
|
||||||
// called when the MP interface is changed
|
// called when the MP interface is changed
|
||||||
@ -264,6 +268,8 @@ private:
|
|||||||
int windowID;
|
int windowID;
|
||||||
bool enabledSaved;
|
bool enabledSaved;
|
||||||
|
|
||||||
|
bool focused;
|
||||||
|
|
||||||
EmuInstance* emuInstance;
|
EmuInstance* emuInstance;
|
||||||
EmuThread* emuThread;
|
EmuThread* emuThread;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user