69 lines
1.9 KiB
C++
69 lines
1.9 KiB
C++
|
inline void Platform_ConsumeEvent(platform_event_list *EventList, platform_event *Event)
|
||
|
{
|
||
|
DLLRemove(EventList->First, EventList->Last, Event);
|
||
|
}
|
||
|
|
||
|
inline b32 Platform_KeyPress(platform_event_list *EventList, platform_key Key,
|
||
|
platform_modifiers Modifiers = PlatformModifier_DoesNotMatter)
|
||
|
{
|
||
|
b32 Result = false;
|
||
|
|
||
|
for(platform_event *Event = EventList->First;
|
||
|
Event != 0;
|
||
|
Event = Event->Next)
|
||
|
{
|
||
|
if((Event->Type == PlatformEvent_Press) &&
|
||
|
(Event->Key == Key) &&
|
||
|
((Modifiers == PlatformModifier_DoesNotMatter) ||
|
||
|
(Event->Modifiers ^ Modifiers) == 0))
|
||
|
{
|
||
|
Result = true;
|
||
|
Platform_ConsumeEvent(EventList, Event);
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return(Result);
|
||
|
}
|
||
|
|
||
|
inline b32 Platform_KeyRelease(platform_event_list *EventList, platform_key Key,
|
||
|
platform_modifiers Modifiers = PlatformModifier_DoesNotMatter)
|
||
|
{
|
||
|
b32 Result = false;
|
||
|
|
||
|
for(platform_event *Event = EventList->First;
|
||
|
Event != 0;
|
||
|
Event = Event->Next)
|
||
|
{
|
||
|
if((Event->Type == PlatformEvent_Release) &&
|
||
|
(Event->Key == Key) &&
|
||
|
((Modifiers == PlatformModifier_DoesNotMatter) ||
|
||
|
((Event->Modifiers & Modifiers) != 0) ||
|
||
|
((Event->Modifiers == 0) && (Modifiers == 0))))
|
||
|
{
|
||
|
Result = true;
|
||
|
Platform_ConsumeEvent(EventList, Event);
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return(Result);
|
||
|
}
|
||
|
|
||
|
static string Platform_ReadEntireFile(memory_arena *Arena, string Path)
|
||
|
{
|
||
|
string Result = {};
|
||
|
|
||
|
platform_file_handle File = Platform.OpenFile(Path, PlatformAccess_Read);
|
||
|
if(File.IsValid)
|
||
|
{
|
||
|
Result.Count = Platform.GetFileSize(File);
|
||
|
|
||
|
Result.Data = PushArray(Arena, u8, Result.Count);
|
||
|
Platform.ReadFile(File, Result.Data, 0, Result.Count);
|
||
|
|
||
|
Platform.CloseFile(File);
|
||
|
}
|
||
|
|
||
|
return(Result);
|
||
|
}
|