2018-05-03 22:15:00 +00:00
|
|
|
#pragma once
|
|
|
|
#include <switch.h>
|
|
|
|
|
|
|
|
#include "iwaitable.hpp"
|
|
|
|
#include "ievent.hpp"
|
|
|
|
|
|
|
|
#define SYSTEMEVENT_INDEX_WAITHANDLE 0
|
|
|
|
#define SYSTEMEVENT_INDEX_SGNLHANDLE 1
|
|
|
|
|
2018-06-03 05:46:27 +00:00
|
|
|
class SystemEvent final : public IEvent {
|
2018-05-03 22:15:00 +00:00
|
|
|
public:
|
2018-06-14 23:50:01 +00:00
|
|
|
SystemEvent(void *a, EventCallback callback) : IEvent(0, a, callback) {
|
2018-05-03 22:15:00 +00:00
|
|
|
Handle wait_h;
|
|
|
|
Handle sig_h;
|
2018-05-07 04:59:54 +00:00
|
|
|
if (R_FAILED(svcCreateEvent(&sig_h, &wait_h))) {
|
2018-05-03 22:15:00 +00:00
|
|
|
/* TODO: Panic. */
|
|
|
|
}
|
|
|
|
|
|
|
|
this->handles.push_back(wait_h);
|
|
|
|
this->handles.push_back(sig_h);
|
|
|
|
}
|
|
|
|
|
2018-06-03 05:46:27 +00:00
|
|
|
Result signal_event() override {
|
2018-05-03 22:15:00 +00:00
|
|
|
return svcSignalEvent(this->handles[SYSTEMEVENT_INDEX_SGNLHANDLE]);
|
|
|
|
}
|
2018-06-03 05:46:27 +00:00
|
|
|
};
|