mirror of
https://github.com/Atmosphere-NX/Atmosphere-libs.git
synced 2025-06-29 14:32:58 +02:00
libstrat: Add InterruptEvents
This commit is contained in:
parent
495cd03c2c
commit
78d16968fd
@ -54,7 +54,9 @@ class IEvent : public IWaitable {
|
||||
void Clear() {
|
||||
std::scoped_lock<HosMutex> 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 <class F>
|
||||
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<F>(r_h, w_h, std::move(f), autoclear);
|
||||
}
|
||||
|
||||
template <class F>
|
||||
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<F>(r_h, INVALID_HANDLE, std::move(f), autoclear);
|
||||
}
|
||||
|
||||
template <bool a = false>
|
||||
static IEvent *CreateWriteOnlySystemEvent() {
|
||||
return CreateSystemEvent([](u64 timeout) -> Result { std::abort(); }, a);
|
||||
|
Loading…
Reference in New Issue
Block a user