mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-12-16 12:42:30 +00:00
feat(event): implement synchronous key and mouse state tracking
This commit is contained in:
parent
df1ab32267
commit
3ee7e489aa
3 changed files with 125 additions and 3 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue