kernel: event_queue: slight event class refactoring
This commit is contained in:
parent
76c92a9dfb
commit
fe30369349
|
@ -11,9 +11,11 @@ EqueueInternal::~EqueueInternal() = default;
|
|||
int EqueueInternal::addEvent(const EqueueEvent& event) {
|
||||
std::scoped_lock lock{m_mutex};
|
||||
|
||||
ASSERT(!event.isTriggered);
|
||||
ASSERT(!event.IsTriggered());
|
||||
|
||||
const auto& it = std::ranges::find(m_events, event);
|
||||
ASSERT(it == m_events.cend()); // TODO: update event if found
|
||||
|
||||
// TODO check if event is already exists and return it. Currently we just add in m_events array
|
||||
m_events.push_back(event);
|
||||
return 0;
|
||||
}
|
||||
|
@ -51,7 +53,7 @@ bool EqueueInternal::triggerEvent(u64 ident, s16 filter, void* trigger_data) {
|
|||
|
||||
for (auto& event : m_events) {
|
||||
if (event.event.ident == ident) { // event filter?
|
||||
event.trigger(trigger_data);
|
||||
event.Trigger(trigger_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -64,9 +66,9 @@ int EqueueInternal::getTriggeredEvents(SceKernelEvent* ev, int num) {
|
|||
int ret = 0;
|
||||
|
||||
for (auto& event : m_events) {
|
||||
if (event.isTriggered) {
|
||||
if (event.IsTriggered()) {
|
||||
ev[ret++] = event.event;
|
||||
event.reset();
|
||||
event.Reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -73,21 +73,31 @@ struct Filter {
|
|||
};
|
||||
|
||||
struct EqueueEvent {
|
||||
bool isTriggered = false;
|
||||
SceKernelEvent event;
|
||||
Filter filter;
|
||||
|
||||
void reset() {
|
||||
isTriggered = false;
|
||||
void Reset() {
|
||||
is_triggered = false;
|
||||
event.fflags = 0;
|
||||
event.data = 0;
|
||||
}
|
||||
|
||||
void trigger(void* data) {
|
||||
isTriggered = true;
|
||||
void Trigger(void* data) {
|
||||
is_triggered = true;
|
||||
event.fflags++;
|
||||
event.data = reinterpret_cast<uintptr_t>(data);
|
||||
}
|
||||
|
||||
bool IsTriggered() const {
|
||||
return is_triggered;
|
||||
}
|
||||
|
||||
bool operator==(const EqueueEvent& ev) const {
|
||||
return ev.event.ident == event.ident;
|
||||
}
|
||||
|
||||
private:
|
||||
bool is_triggered = false;
|
||||
};
|
||||
|
||||
class EqueueInternal {
|
||||
|
|
|
@ -84,7 +84,6 @@ int PS4_SYSV_ABI sceKernelAddUserEvent(SceKernelEqueue eq, int id) {
|
|||
}
|
||||
|
||||
Kernel::EqueueEvent event{};
|
||||
event.isTriggered = false;
|
||||
event.event.ident = id;
|
||||
event.event.filter = Kernel::EVFILT_USER;
|
||||
event.event.udata = 0;
|
||||
|
@ -101,7 +100,6 @@ int PS4_SYSV_ABI sceKernelAddUserEventEdge(SceKernelEqueue eq, int id) {
|
|||
}
|
||||
|
||||
Kernel::EqueueEvent event{};
|
||||
event.isTriggered = false;
|
||||
event.event.ident = id;
|
||||
event.event.filter = Kernel::EVFILT_USER;
|
||||
event.event.udata = 0;
|
||||
|
|
|
@ -48,7 +48,6 @@ s32 PS4_SYSV_ABI sceVideoOutAddFlipEvent(Kernel::SceKernelEqueue eq, s32 handle,
|
|||
}
|
||||
|
||||
Kernel::EqueueEvent event{};
|
||||
event.isTriggered = false;
|
||||
event.event.ident = SCE_VIDEO_OUT_EVENT_FLIP;
|
||||
event.event.filter = Kernel::EVFILT_VIDEO_OUT;
|
||||
event.event.udata = udata;
|
||||
|
@ -73,7 +72,6 @@ s32 PS4_SYSV_ABI sceVideoOutAddVblankEvent(Kernel::SceKernelEqueue eq, s32 handl
|
|||
}
|
||||
|
||||
Kernel::EqueueEvent event{};
|
||||
event.isTriggered = false;
|
||||
event.event.ident = SCE_VIDEO_OUT_EVENT_VBLANK;
|
||||
event.event.filter = Kernel::EVFILT_VIDEO_OUT;
|
||||
event.event.udata = udata;
|
||||
|
|
Loading…
Reference in New Issue