mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-25 11:34:55 +00:00
Merge branch 'main' into user_management
This commit is contained in:
commit
ee54507457
@ -138,7 +138,7 @@ The following firmware modules are supported and must be placed in shadPS4's `sy
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
> [!Caution]
|
> [!Caution]
|
||||||
> The above modules are required to run the games properly and must be extracted from your PlayStation 4.\
|
> The above modules are required to run the games properly and must be extracted from your PlayStation 4.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -125,7 +125,6 @@ int EqueueInternal::WaitForEvents(SceKernelEvent* ev, int num, u32 micros) {
|
|||||||
.count();
|
.count();
|
||||||
count = WaitForSmallTimer(ev, num, std::max(0l, long(micros - time_waited)));
|
count = WaitForSmallTimer(ev, num, std::max(0l, long(micros - time_waited)));
|
||||||
}
|
}
|
||||||
small_timer_event.event.data = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ev->flags & SceKernelEvent::Flags::OneShot) {
|
if (ev->flags & SceKernelEvent::Flags::OneShot) {
|
||||||
@ -179,39 +178,46 @@ int EqueueInternal::GetTriggeredEvents(SceKernelEvent* ev, int num) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool EqueueInternal::AddSmallTimer(EqueueEvent& ev) {
|
bool EqueueInternal::AddSmallTimer(EqueueEvent& ev) {
|
||||||
// We assume that only one timer event (with the same ident across calls)
|
SmallTimer st;
|
||||||
// can be posted to the queue, based on observations so far. In the opposite case,
|
st.event = ev.event;
|
||||||
// the small timer storage and wait logic should be reworked.
|
st.added = std::chrono::steady_clock::now();
|
||||||
ASSERT(!HasSmallTimer() || small_timer_event.event.ident == ev.event.ident);
|
st.interval = std::chrono::microseconds{ev.event.data};
|
||||||
ev.time_added = std::chrono::steady_clock::now();
|
{
|
||||||
small_timer_event = std::move(ev);
|
std::scoped_lock lock{m_mutex};
|
||||||
|
m_small_timers[st.event.ident] = std::move(st);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int EqueueInternal::WaitForSmallTimer(SceKernelEvent* ev, int num, u32 micros) {
|
int EqueueInternal::WaitForSmallTimer(SceKernelEvent* ev, int num, u32 micros) {
|
||||||
int count{};
|
ASSERT(num >= 1);
|
||||||
|
|
||||||
ASSERT(num == 1);
|
|
||||||
|
|
||||||
auto curr_clock = std::chrono::steady_clock::now();
|
auto curr_clock = std::chrono::steady_clock::now();
|
||||||
const auto wait_end_us = (micros == 0) ? std::chrono::steady_clock::time_point::max()
|
const auto wait_end_us = (micros == 0) ? std::chrono::steady_clock::time_point::max()
|
||||||
: curr_clock + std::chrono::microseconds{micros};
|
: curr_clock + std::chrono::microseconds{micros};
|
||||||
|
int count = 0;
|
||||||
do {
|
do {
|
||||||
curr_clock = std::chrono::steady_clock::now();
|
curr_clock = std::chrono::steady_clock::now();
|
||||||
{
|
{
|
||||||
std::scoped_lock lock{m_mutex};
|
std::scoped_lock lock{m_mutex};
|
||||||
if ((curr_clock - small_timer_event.time_added) >
|
for (auto it = m_small_timers.begin(); it != m_small_timers.end() && count < num;) {
|
||||||
std::chrono::microseconds{small_timer_event.event.data}) {
|
const SmallTimer& st = it->second;
|
||||||
ev[count++] = small_timer_event.event;
|
|
||||||
small_timer_event.event.data = 0;
|
if (curr_clock - st.added >= st.interval) {
|
||||||
break;
|
ev[count++] = st.event;
|
||||||
|
it = m_small_timers.erase(it);
|
||||||
|
} else {
|
||||||
|
++it;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (count > 0)
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
std::this_thread::yield();
|
std::this_thread::yield();
|
||||||
} while (curr_clock < wait_end_us);
|
} while (curr_clock < wait_end_us);
|
||||||
|
|
||||||
return count;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EqueueInternal::EventExists(u64 id, s16 filter) {
|
bool EqueueInternal::EventExists(u64 id, s16 filter) {
|
||||||
@ -326,6 +332,11 @@ s32 PS4_SYSV_ABI sceKernelAddHRTimerEvent(SceKernelEqueue eq, int id, timespec*
|
|||||||
// `HrTimerSpinlockThresholdUs`) and fall back to boost asio timers if the time to tick is
|
// `HrTimerSpinlockThresholdUs`) and fall back to boost asio timers if the time to tick is
|
||||||
// large. Even for large delays, we truncate a small portion to complete the wait
|
// large. Even for large delays, we truncate a small portion to complete the wait
|
||||||
// using the spinlock, prioritizing precision.
|
// using the spinlock, prioritizing precision.
|
||||||
|
|
||||||
|
if (eq->EventExists(event.event.ident, event.event.filter)) {
|
||||||
|
eq->RemoveEvent(id, SceKernelEvent::Filter::HrTimer);
|
||||||
|
}
|
||||||
|
|
||||||
if (total_us < HrTimerSpinlockThresholdUs) {
|
if (total_us < HrTimerSpinlockThresholdUs) {
|
||||||
return eq->AddSmallTimer(event) ? ORBIS_OK : ORBIS_KERNEL_ERROR_ENOMEM;
|
return eq->AddSmallTimer(event) ? ORBIS_OK : ORBIS_KERNEL_ERROR_ENOMEM;
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <boost/asio/steady_timer.hpp>
|
#include <boost/asio/steady_timer.hpp>
|
||||||
|
|
||||||
|
#include <unordered_map>
|
||||||
#include "common/rdtsc.h"
|
#include "common/rdtsc.h"
|
||||||
#include "common/types.h"
|
#include "common/types.h"
|
||||||
|
|
||||||
@ -135,6 +136,12 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
class EqueueInternal {
|
class EqueueInternal {
|
||||||
|
struct SmallTimer {
|
||||||
|
SceKernelEvent event;
|
||||||
|
std::chrono::steady_clock::time_point added;
|
||||||
|
std::chrono::microseconds interval;
|
||||||
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit EqueueInternal(std::string_view name) : m_name(name) {}
|
explicit EqueueInternal(std::string_view name) : m_name(name) {}
|
||||||
|
|
||||||
@ -151,13 +158,14 @@ public:
|
|||||||
int GetTriggeredEvents(SceKernelEvent* ev, int num);
|
int GetTriggeredEvents(SceKernelEvent* ev, int num);
|
||||||
|
|
||||||
bool AddSmallTimer(EqueueEvent& event);
|
bool AddSmallTimer(EqueueEvent& event);
|
||||||
bool HasSmallTimer() const {
|
bool HasSmallTimer() {
|
||||||
return small_timer_event.event.data != 0;
|
std::scoped_lock lock{m_mutex};
|
||||||
|
return !m_small_timers.empty();
|
||||||
}
|
}
|
||||||
bool RemoveSmallTimer(u64 id) {
|
bool RemoveSmallTimer(u64 id) {
|
||||||
if (HasSmallTimer() && small_timer_event.event.ident == id) {
|
if (HasSmallTimer()) {
|
||||||
small_timer_event = {};
|
std::scoped_lock lock{m_mutex};
|
||||||
return true;
|
return m_small_timers.erase(id) > 0;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -170,8 +178,8 @@ private:
|
|||||||
std::string m_name;
|
std::string m_name;
|
||||||
std::mutex m_mutex;
|
std::mutex m_mutex;
|
||||||
std::vector<EqueueEvent> m_events;
|
std::vector<EqueueEvent> m_events;
|
||||||
EqueueEvent small_timer_event{};
|
|
||||||
std::condition_variable m_cond;
|
std::condition_variable m_cond;
|
||||||
|
std::unordered_map<u64, SmallTimer> m_small_timers;
|
||||||
};
|
};
|
||||||
|
|
||||||
u64 PS4_SYSV_ABI sceKernelGetEventData(const SceKernelEvent* ev);
|
u64 PS4_SYSV_ABI sceKernelGetEventData(const SceKernelEvent* ev);
|
||||||
|
@ -33,13 +33,13 @@ KBMSettings::KBMSettings(std::shared_ptr<GameInfoClass> game_info_get, QWidget*
|
|||||||
}
|
}
|
||||||
|
|
||||||
ButtonsList = {
|
ButtonsList = {
|
||||||
ui->CrossButton, ui->CircleButton, ui->TriangleButton, ui->SquareButton,
|
ui->CrossButton, ui->CircleButton, ui->TriangleButton, ui->SquareButton,
|
||||||
ui->L1Button, ui->R1Button, ui->L2Button, ui->R2Button,
|
ui->L1Button, ui->R1Button, ui->L2Button, ui->R2Button,
|
||||||
ui->L3Button, ui->R3Button, ui->TouchpadButton, ui->OptionsButton,
|
ui->L3Button, ui->R3Button, ui->OptionsButton, ui->TouchpadButton,
|
||||||
ui->TouchpadButton, ui->DpadUpButton, ui->DpadDownButton, ui->DpadLeftButton,
|
ui->DpadUpButton, ui->DpadDownButton, ui->DpadLeftButton, ui->DpadRightButton,
|
||||||
ui->DpadRightButton, ui->LStickUpButton, ui->LStickDownButton, ui->LStickLeftButton,
|
ui->LStickUpButton, ui->LStickDownButton, ui->LStickLeftButton, ui->LStickRightButton,
|
||||||
ui->LStickRightButton, ui->RStickUpButton, ui->RStickDownButton, ui->RStickLeftButton,
|
ui->RStickUpButton, ui->RStickDownButton, ui->RStickLeftButton, ui->RStickRightButton,
|
||||||
ui->RStickRightButton, ui->LHalfButton, ui->RHalfButton};
|
ui->LHalfButton, ui->RHalfButton};
|
||||||
|
|
||||||
ButtonConnects();
|
ButtonConnects();
|
||||||
SetUIValuestoMappings("default");
|
SetUIValuestoMappings("default");
|
||||||
@ -372,14 +372,31 @@ void KBMSettings::SaveKBMConfig(bool CloseOnSave) {
|
|||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
// Prevent duplicate inputs for KBM as this breaks the engine
|
// Prevent duplicate inputs for KBM as this breaks the engine
|
||||||
|
bool duplicateFound = false;
|
||||||
|
QSet<QString> duplicateMappings;
|
||||||
for (auto it = inputs.begin(); it != inputs.end(); ++it) {
|
for (auto it = inputs.begin(); it != inputs.end(); ++it) {
|
||||||
if (std::find(it + 1, inputs.end(), *it) != inputs.end()) {
|
if (std::find(it + 1, inputs.end(), *it) != inputs.end()) {
|
||||||
QMessageBox::information(this, tr("Unable to Save"),
|
duplicateFound = true;
|
||||||
tr("Cannot bind any unique input more than once"));
|
duplicateMappings.insert(QString::fromStdString(*it));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (duplicateFound) {
|
||||||
|
QStringList duplicatesList;
|
||||||
|
for (const QString mapping : duplicateMappings) {
|
||||||
|
for (const auto& button : ButtonsList) {
|
||||||
|
if (button->text() == mapping)
|
||||||
|
duplicatesList.append(button->objectName() + " - " + mapping);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QMessageBox::information(
|
||||||
|
this, tr("Unable to Save"),
|
||||||
|
// clang-format off
|
||||||
|
QString(tr("Cannot bind any unique input more than once. Duplicate inputs mapped to the following buttons:\n\n%1").arg(duplicatesList.join("\n"))));
|
||||||
|
// clang-format on
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<std::string> save;
|
std::vector<std::string> save;
|
||||||
bool CurrentLineEmpty = false, LastLineEmpty = false;
|
bool CurrentLineEmpty = false, LastLineEmpty = false;
|
||||||
for (auto const& line : lines) {
|
for (auto const& line : lines) {
|
||||||
|
@ -456,7 +456,7 @@ void SettingsDialog::LoadValuesFromConfig() {
|
|||||||
ui->dumpShadersCheckBox->setChecked(toml::find_or<bool>(data, "GPU", "dumpShaders", false));
|
ui->dumpShadersCheckBox->setChecked(toml::find_or<bool>(data, "GPU", "dumpShaders", false));
|
||||||
ui->nullGpuCheckBox->setChecked(toml::find_or<bool>(data, "GPU", "nullGpu", false));
|
ui->nullGpuCheckBox->setChecked(toml::find_or<bool>(data, "GPU", "nullGpu", false));
|
||||||
ui->enableHDRCheckBox->setChecked(toml::find_or<bool>(data, "GPU", "allowHDR", false));
|
ui->enableHDRCheckBox->setChecked(toml::find_or<bool>(data, "GPU", "allowHDR", false));
|
||||||
ui->playBGMCheckBox->setChecked(toml::find_or<bool>(data, "General", "playBGM", false));
|
ui->playBGMCheckBox->setChecked(m_gui_settings->GetValue(gui::gl_playBackgroundMusic).toBool());
|
||||||
ui->disableTrophycheckBox->setChecked(
|
ui->disableTrophycheckBox->setChecked(
|
||||||
toml::find_or<bool>(data, "General", "isTrophyPopupDisabled", false));
|
toml::find_or<bool>(data, "General", "isTrophyPopupDisabled", false));
|
||||||
ui->popUpDurationSpinBox->setValue(Config::getTrophyNotificationDuration());
|
ui->popUpDurationSpinBox->setValue(Config::getTrophyNotificationDuration());
|
||||||
@ -468,7 +468,7 @@ void SettingsDialog::LoadValuesFromConfig() {
|
|||||||
ui->radioButton_Top->setChecked(side == "top");
|
ui->radioButton_Top->setChecked(side == "top");
|
||||||
ui->radioButton_Bottom->setChecked(side == "bottom");
|
ui->radioButton_Bottom->setChecked(side == "bottom");
|
||||||
|
|
||||||
ui->BGMVolumeSlider->setValue(toml::find_or<int>(data, "General", "BGMvolume", 50));
|
ui->BGMVolumeSlider->setValue(m_gui_settings->GetValue(gui::gl_backgroundMusicVolume).toInt());
|
||||||
ui->discordRPCCheckbox->setChecked(
|
ui->discordRPCCheckbox->setChecked(
|
||||||
toml::find_or<bool>(data, "General", "enableDiscordRPC", true));
|
toml::find_or<bool>(data, "General", "enableDiscordRPC", true));
|
||||||
QString translatedText_FullscreenMode =
|
QString translatedText_FullscreenMode =
|
||||||
|
Loading…
Reference in New Issue
Block a user