1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 02:32:36 +01:00

Qt: check microphone permissions

This commit is contained in:
Megamouse 2023-11-04 22:49:25 +01:00
parent 3420cb0365
commit e5b03d9cbd
2 changed files with 41 additions and 0 deletions

View File

@ -87,6 +87,7 @@ extern std::pair<std::shared_ptr<lv2_overlay>, CellError> ppu_load_overlay(const
extern bool ppu_load_rel_exec(const ppu_rel_object&);
extern void send_close_home_menu_cmds();
extern void check_microphone_permissions();
extern void signal_system_cache_can_stay();
@ -1722,6 +1723,15 @@ game_boot_result Emulator::Load(const std::string& title_id, bool is_disc_patch,
return game_boot_result::no_errors;
}
// Check microphone permissions
if (g_cfg.audio.microphone_type != microphone_handler::null)
{
if (const std::vector<std::string> device_list = fmt::split(g_cfg.audio.microphone_devices.to_string(), {"@@@"}); !device_list.empty())
{
check_microphone_permissions();
}
}
// Detect boot location
const std::string hdd0_game = vfs::get("/dev_hdd0/game/");
const bool from_hdd0_game = IsPathInsideDir(m_path, hdd0_game);

View File

@ -81,6 +81,11 @@
#include "ui_main_window.h"
#if QT_CONFIG(permissions)
#include <QGuiApplication>
#include <QPermissions>
#endif
LOG_CHANNEL(gui_log, "GUI");
extern atomic_t<bool> g_user_asked_for_frame_capture;
@ -102,6 +107,32 @@ extern void process_qt_events()
}
}
extern void check_microphone_permissions()
{
#if QT_CONFIG(permissions)
Emu.BlockingCallFromMainThread([]()
{
QMicrophonePermission permission;
switch (qApp->checkPermission(permission))
{
case Qt::PermissionStatus::Undetermined:
gui_log.notice("Requesting microphone permission");
qApp->requestPermission(permission, []()
{
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
}
main_window::main_window(std::shared_ptr<gui_settings> gui_settings, std::shared_ptr<emu_settings> emu_settings, std::shared_ptr<persistent_settings> persistent_settings, QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::main_window)