diff --git a/include/stratosphere/event.hpp b/include/stratosphere/event.hpp index 5be7badd..3db815c2 100644 --- a/include/stratosphere/event.hpp +++ b/include/stratosphere/event.hpp @@ -54,7 +54,9 @@ class IEvent : public IWaitable { void Clear() { std::scoped_lock lock(this->sig_lock); this->is_signaled = false; - if (this->r_h != INVALID_HANDLE) { + if (this->w_h != INVALID_HANDLE) { + svcClearEvent(this->w_h); + } else if (this->r_h != INVALID_HANDLE) { svcResetSignal(this->r_h); } } @@ -112,15 +114,23 @@ static IEvent *CreateHosEvent(F f, bool autoclear = false) { template static IEvent *CreateSystemEvent(F f, bool autoclear = false) { - Handle w_h, r_h; if (R_FAILED(svcCreateEvent(&w_h, &r_h))) { std::abort(); } - return new HosEvent(r_h, w_h, std::move(f), autoclear); } +template +static IEvent *CreateInterruptEvent(F f, u64 irq, bool autoclear = false) { + Handle r_h; + /* flag is "rising edge vs level", official N code maps autoclear to edge and not to level... */ + if (R_FAILED(svcCreateInterruptEvent(&r_h, irq, autoclear ? 1 : 0))) { + std::abort(); + } + return new HosEvent(r_h, INVALID_HANDLE, std::move(f), autoclear); +} + template static IEvent *CreateWriteOnlySystemEvent() { return CreateSystemEvent([](u64 timeout) -> Result { std::abort(); }, a);