mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-05 06:21:26 +12:00
Move check_microphone_permissions to emu callbacks
This commit is contained in:
parent
d33d3a9f57
commit
87db82cacd
5 changed files with 34 additions and 33 deletions
|
@ -90,7 +90,6 @@ extern std::pair<shared_ptr<lv2_overlay>, CellError> ppu_load_overlay(const ppu_
|
||||||
extern bool ppu_load_rel_exec(const ppu_rel_object&);
|
extern bool ppu_load_rel_exec(const ppu_rel_object&);
|
||||||
|
|
||||||
extern void send_close_home_menu_cmds();
|
extern void send_close_home_menu_cmds();
|
||||||
extern void check_microphone_permissions();
|
|
||||||
|
|
||||||
extern void signal_system_cache_can_stay();
|
extern void signal_system_cache_can_stay();
|
||||||
|
|
||||||
|
@ -1810,7 +1809,7 @@ game_boot_result Emulator::Load(const std::string& title_id, bool is_disc_patch,
|
||||||
{
|
{
|
||||||
if (const std::vector<std::string> device_list = fmt::split(g_cfg.audio.microphone_devices.to_string(), {"@@@"}); !device_list.empty())
|
if (const std::vector<std::string> device_list = fmt::split(g_cfg.audio.microphone_devices.to_string(), {"@@@"}); !device_list.empty())
|
||||||
{
|
{
|
||||||
check_microphone_permissions();
|
Emu.GetCallbacks().check_microphone_permissions();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -107,6 +107,7 @@ struct EmuCallbacks
|
||||||
std::function<std::vector<std::string>()> get_font_dirs;
|
std::function<std::vector<std::string>()> get_font_dirs;
|
||||||
std::function<bool(const std::vector<std::string>&)> on_install_pkgs;
|
std::function<bool(const std::vector<std::string>&)> on_install_pkgs;
|
||||||
std::function<void(u32)> add_breakpoint;
|
std::function<void(u32)> add_breakpoint;
|
||||||
|
std::function<void()> check_microphone_permissions;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace utils
|
namespace utils
|
||||||
|
|
|
@ -168,6 +168,8 @@ void headless_application::InitializeCallbacks()
|
||||||
callbacks.play_sound = [](const std::string&){};
|
callbacks.play_sound = [](const std::string&){};
|
||||||
callbacks.add_breakpoint = [](u32 /*addr*/){};
|
callbacks.add_breakpoint = [](u32 /*addr*/){};
|
||||||
|
|
||||||
|
callbacks.check_microphone_permissions = [](){};
|
||||||
|
|
||||||
Emu.SetCallbacks(std::move(callbacks));
|
Emu.SetCallbacks(std::move(callbacks));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,10 @@
|
||||||
#include "Emu/Cell/lv2/sys_usbd.h"
|
#include "Emu/Cell/lv2/sys_usbd.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if QT_CONFIG(permissions)
|
||||||
|
#include <QPermissions>
|
||||||
|
#endif
|
||||||
|
|
||||||
LOG_CHANNEL(gui_log, "GUI");
|
LOG_CHANNEL(gui_log, "GUI");
|
||||||
|
|
||||||
std::unique_ptr<raw_mouse_handler> g_raw_mouse_handler;
|
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));
|
Emu.SetCallbacks(std::move(callbacks));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,11 +86,6 @@
|
||||||
#include <QEventLoop>
|
#include <QEventLoop>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
#if QT_CONFIG(permissions)
|
|
||||||
#include <QGuiApplication>
|
|
||||||
#include <QPermissions>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include "raw_mouse_settings_dialog.h"
|
#include "raw_mouse_settings_dialog.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -168,32 +163,6 @@ extern void qt_events_aware_op(int repeat_duration_ms, std::function<bool()> wra
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern void 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, []()
|
|
||||||
{
|
|
||||||
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)
|
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)
|
: QMainWindow(parent)
|
||||||
, ui(new Ui::main_window)
|
, ui(new Ui::main_window)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue