Move check_microphone_permissions to emu callbacks

This commit is contained in:
Megamouse 2025-02-24 21:38:54 +01:00
parent d33d3a9f57
commit 87db82cacd
5 changed files with 34 additions and 33 deletions

View file

@ -60,6 +60,10 @@
#include "Emu/Cell/lv2/sys_usbd.h"
#endif
#if QT_CONFIG(permissions)
#include <QPermissions>
#endif
LOG_CHANNEL(gui_log, "GUI");
std::unique_ptr<raw_mouse_handler> g_raw_mouse_handler;
@ -878,6 +882,32 @@ void gui_application::InitializeCallbacks()
});
};
callbacks.check_microphone_permissions = []()
{
#if QT_CONFIG(permissions)
Emu.BlockingCallFromMainThread([]()
{
const QMicrophonePermission permission;
switch (qApp->checkPermission(permission))
{
case Qt::PermissionStatus::Undetermined:
gui_log.notice("Requesting microphone permission");
qApp->requestPermission(permission, []()
{
Emu.GetCallbacks().check_microphone_permissions();
});
break;
case Qt::PermissionStatus::Denied:
gui_log.error("RPCS3 has no permissions to access microphones on this device.");
break;
case Qt::PermissionStatus::Granted:
gui_log.notice("Microphone permission granted");
break;
}
});
#endif
};
Emu.SetCallbacks(std::move(callbacks));
}