feat(event): implement synchronous key and mouse state tracking

This commit is contained in:
phaneron 2023-04-29 23:12:53 -04:00
parent df1ab32267
commit 3ee7e489aa
3 changed files with 125 additions and 3 deletions

View file

@ -53,7 +53,28 @@ int32_t EventIsControlKeyDown() {
}
int32_t EventIsKeyDown(KEY key) {
// TODO
auto hContext = PropGet(PROP_EVENTCONTEXT);
auto contextId = *reinterpret_cast<uint32_t*>(hContext);
int32_t findMask;
auto context = TSingletonInstanceId<EvtContext, offsetof(EvtContext, m_id)>::s_idTable.Ptr(
contextId,
0,
&findMask
);
if (context) {
auto keystate = IEvtQueueCheckSyncKeyState(context, key);
if (findMask != -1) {
TSingletonInstanceId<EvtContext, offsetof(EvtContext, m_id)>::s_idTable.Unlock(
findMask & (INSTANCE_TABLE_SLOT_COUNT - 1),
findMask >= INSTANCE_TABLE_SLOT_COUNT
);
}
return keystate;
}
return 0;
}