Skip to content

Commit e5b03d9

Browse files
committed
Qt: check microphone permissions
1 parent 3420cb0 commit e5b03d9

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

rpcs3/Emu/System.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ extern std::pair<std::shared_ptr<lv2_overlay>, CellError> ppu_load_overlay(const
8787
extern bool ppu_load_rel_exec(const ppu_rel_object&);
8888

8989
extern void send_close_home_menu_cmds();
90+
extern void check_microphone_permissions();
9091

9192
extern void signal_system_cache_can_stay();
9293

@@ -1722,6 +1723,15 @@ game_boot_result Emulator::Load(const std::string& title_id, bool is_disc_patch,
17221723
return game_boot_result::no_errors;
17231724
}
17241725

1726+
// Check microphone permissions
1727+
if (g_cfg.audio.microphone_type != microphone_handler::null)
1728+
{
1729+
if (const std::vector<std::string> device_list = fmt::split(g_cfg.audio.microphone_devices.to_string(), {"@@@"}); !device_list.empty())
1730+
{
1731+
check_microphone_permissions();
1732+
}
1733+
}
1734+
17251735
// Detect boot location
17261736
const std::string hdd0_game = vfs::get("/dev_hdd0/game/");
17271737
const bool from_hdd0_game = IsPathInsideDir(m_path, hdd0_game);

rpcs3/rpcs3qt/main_window.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@
8181

8282
#include "ui_main_window.h"
8383

84+
#if QT_CONFIG(permissions)
85+
#include <QGuiApplication>
86+
#include <QPermissions>
87+
#endif
88+
8489
LOG_CHANNEL(gui_log, "GUI");
8590

8691
extern atomic_t<bool> g_user_asked_for_frame_capture;
@@ -102,6 +107,32 @@ extern void process_qt_events()
102107
}
103108
}
104109

110+
extern void check_microphone_permissions()
111+
{
112+
#if QT_CONFIG(permissions)
113+
Emu.BlockingCallFromMainThread([]()
114+
{
115+
QMicrophonePermission permission;
116+
switch (qApp->checkPermission(permission))
117+
{
118+
case Qt::PermissionStatus::Undetermined:
119+
gui_log.notice("Requesting microphone permission");
120+
qApp->requestPermission(permission, []()
121+
{
122+
check_microphone_permissions();
123+
});
124+
break;
125+
case Qt::PermissionStatus::Denied:
126+
gui_log.error("RPCS3 has no permissions to access microphones on this device.");
127+
break;
128+
case Qt::PermissionStatus::Granted:
129+
gui_log.notice("Microphone permission granted");
130+
break;
131+
}
132+
});
133+
#endif
134+
}
135+
105136
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)
106137
: QMainWindow(parent)
107138
, ui(new Ui::main_window)

0 commit comments

Comments
 (0)