re-slice linux/win32 backends, top-level folder is backend (demon/win32 -> win32/demon, etc.); os_gfx -> window_manager; fix linux / opengl builds for new apis/types

This commit is contained in:
Ryan Fleury committed 2026-05-08 15:21:22 -07:00
1 parent aea4a4ff9d
commit 9a7782de47
50 files changed
+12981 -19517

No files matched your search

@@ -0,0 +1,302 @@
// Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
//- GENERATED CODE
C_LINKAGE_BEGIN
String8 os_g_key_display_string_table[143] =
{
str8_lit_comp("Invalid Key"),
str8_lit_comp("Escape"),
str8_lit_comp("F1"),
str8_lit_comp("F2"),
str8_lit_comp("F3"),
str8_lit_comp("F4"),
str8_lit_comp("F5"),
str8_lit_comp("F6"),
str8_lit_comp("F7"),
str8_lit_comp("F8"),
str8_lit_comp("F9"),
str8_lit_comp("F10"),
str8_lit_comp("F11"),
str8_lit_comp("F12"),
str8_lit_comp("F13"),
str8_lit_comp("F14"),
str8_lit_comp("F15"),
str8_lit_comp("F16"),
str8_lit_comp("F17"),
str8_lit_comp("F18"),
str8_lit_comp("F19"),
str8_lit_comp("F20"),
str8_lit_comp("F21"),
str8_lit_comp("F22"),
str8_lit_comp("F23"),
str8_lit_comp("F24"),
str8_lit_comp("Tick"),
str8_lit_comp("0"),
str8_lit_comp("1"),
str8_lit_comp("2"),
str8_lit_comp("3"),
str8_lit_comp("4"),
str8_lit_comp("5"),
str8_lit_comp("6"),
str8_lit_comp("7"),
str8_lit_comp("8"),
str8_lit_comp("9"),
str8_lit_comp("Minus"),
str8_lit_comp("Equal"),
str8_lit_comp("Backspace"),
str8_lit_comp("Tab"),
str8_lit_comp("Q"),
str8_lit_comp("W"),
str8_lit_comp("E"),
str8_lit_comp("R"),
str8_lit_comp("T"),
str8_lit_comp("Y"),
str8_lit_comp("U"),
str8_lit_comp("I"),
str8_lit_comp("O"),
str8_lit_comp("P"),
str8_lit_comp("Left Bracket"),
str8_lit_comp("Right Bracket"),
str8_lit_comp("Back Slash"),
str8_lit_comp("Caps Lock"),
str8_lit_comp("A"),
str8_lit_comp("S"),
str8_lit_comp("D"),
str8_lit_comp("F"),
str8_lit_comp("G"),
str8_lit_comp("H"),
str8_lit_comp("J"),
str8_lit_comp("K"),
str8_lit_comp("L"),
str8_lit_comp("Semicolon"),
str8_lit_comp("Quote"),
str8_lit_comp("Return"),
str8_lit_comp("Shift"),
str8_lit_comp("Z"),
str8_lit_comp("X"),
str8_lit_comp("C"),
str8_lit_comp("V"),
str8_lit_comp("B"),
str8_lit_comp("N"),
str8_lit_comp("M"),
str8_lit_comp("Comma"),
str8_lit_comp("Period"),
str8_lit_comp("Slash"),
str8_lit_comp("Ctrl"),
str8_lit_comp("Alt"),
str8_lit_comp("Space"),
str8_lit_comp("Menu"),
str8_lit_comp("Scroll Lock"),
str8_lit_comp("Pause"),
str8_lit_comp("Insert"),
str8_lit_comp("Home"),
str8_lit_comp("Page Up"),
str8_lit_comp("Delete"),
str8_lit_comp("End"),
str8_lit_comp("Page Down"),
str8_lit_comp("Up"),
str8_lit_comp("Left"),
str8_lit_comp("Down"),
str8_lit_comp("Right"),
str8_lit_comp("Ex0"),
str8_lit_comp("Ex1"),
str8_lit_comp("Ex2"),
str8_lit_comp("Ex3"),
str8_lit_comp("Ex4"),
str8_lit_comp("Ex5"),
str8_lit_comp("Ex6"),
str8_lit_comp("Ex7"),
str8_lit_comp("Ex8"),
str8_lit_comp("Ex9"),
str8_lit_comp("Ex10"),
str8_lit_comp("Ex11"),
str8_lit_comp("Ex12"),
str8_lit_comp("Ex13"),
str8_lit_comp("Ex14"),
str8_lit_comp("Ex15"),
str8_lit_comp("Ex16"),
str8_lit_comp("Ex17"),
str8_lit_comp("Ex18"),
str8_lit_comp("Ex19"),
str8_lit_comp("Ex20"),
str8_lit_comp("Ex21"),
str8_lit_comp("Ex22"),
str8_lit_comp("Ex23"),
str8_lit_comp("Ex24"),
str8_lit_comp("Ex25"),
str8_lit_comp("Ex26"),
str8_lit_comp("Ex27"),
str8_lit_comp("Ex28"),
str8_lit_comp("Ex29"),
str8_lit_comp("Num Lock"),
str8_lit_comp("Numpad Slash"),
str8_lit_comp("Numpad Star"),
str8_lit_comp("Numpad Minus"),
str8_lit_comp("Numpad Plus"),
str8_lit_comp("Numpad Period"),
str8_lit_comp("Numpad 0"),
str8_lit_comp("Numpad 1"),
str8_lit_comp("Numpad 2"),
str8_lit_comp("Numpad 3"),
str8_lit_comp("Numpad 4"),
str8_lit_comp("Numpad 5"),
str8_lit_comp("Numpad 6"),
str8_lit_comp("Numpad 7"),
str8_lit_comp("Numpad 8"),
str8_lit_comp("Numpad 9"),
str8_lit_comp("Left Mouse Button"),
str8_lit_comp("Middle Mouse Button"),
str8_lit_comp("Right Mouse Button"),
};
String8 os_g_key_cfg_string_table[143] =
{
str8_lit_comp("null"),
str8_lit_comp("esc"),
str8_lit_comp("f1"),
str8_lit_comp("f2"),
str8_lit_comp("f3"),
str8_lit_comp("f4"),
str8_lit_comp("f5"),
str8_lit_comp("f6"),
str8_lit_comp("f7"),
str8_lit_comp("f8"),
str8_lit_comp("f9"),
str8_lit_comp("f10"),
str8_lit_comp("f11"),
str8_lit_comp("f12"),
str8_lit_comp("f13"),
str8_lit_comp("f14"),
str8_lit_comp("f15"),
str8_lit_comp("f16"),
str8_lit_comp("f17"),
str8_lit_comp("f18"),
str8_lit_comp("f19"),
str8_lit_comp("f20"),
str8_lit_comp("f21"),
str8_lit_comp("f22"),
str8_lit_comp("f23"),
str8_lit_comp("f24"),
str8_lit_comp("tick"),
str8_lit_comp("0"),
str8_lit_comp("1"),
str8_lit_comp("2"),
str8_lit_comp("3"),
str8_lit_comp("4"),
str8_lit_comp("5"),
str8_lit_comp("6"),
str8_lit_comp("7"),
str8_lit_comp("8"),
str8_lit_comp("9"),
str8_lit_comp("minus"),
str8_lit_comp("equal"),
str8_lit_comp("backspace"),
str8_lit_comp("tab"),
str8_lit_comp("q"),
str8_lit_comp("w"),
str8_lit_comp("e"),
str8_lit_comp("r"),
str8_lit_comp("t"),
str8_lit_comp("y"),
str8_lit_comp("u"),
str8_lit_comp("i"),
str8_lit_comp("o"),
str8_lit_comp("p"),
str8_lit_comp("left_bracket"),
str8_lit_comp("right_bracket"),
str8_lit_comp("backslash"),
str8_lit_comp("caps_lock"),
str8_lit_comp("a"),
str8_lit_comp("s"),
str8_lit_comp("d"),
str8_lit_comp("f"),
str8_lit_comp("g"),
str8_lit_comp("h"),
str8_lit_comp("j"),
str8_lit_comp("k"),
str8_lit_comp("l"),
str8_lit_comp("semicolon"),
str8_lit_comp("quote"),
str8_lit_comp("return"),
str8_lit_comp("shift"),
str8_lit_comp("z"),
str8_lit_comp("x"),
str8_lit_comp("c"),
str8_lit_comp("v"),
str8_lit_comp("b"),
str8_lit_comp("n"),
str8_lit_comp("m"),
str8_lit_comp("comma"),
str8_lit_comp("period"),
str8_lit_comp("slash"),
str8_lit_comp("ctrl"),
str8_lit_comp("alt"),
str8_lit_comp("space"),
str8_lit_comp("menu"),
str8_lit_comp("scroll_lock"),
str8_lit_comp("pause"),
str8_lit_comp("insert"),
str8_lit_comp("home"),
str8_lit_comp("page_up"),
str8_lit_comp("delete"),
str8_lit_comp("end"),
str8_lit_comp("page_down"),
str8_lit_comp("up"),
str8_lit_comp("left"),
str8_lit_comp("down"),
str8_lit_comp("right"),
str8_lit_comp("ex0"),
str8_lit_comp("ex1"),
str8_lit_comp("ex2"),
str8_lit_comp("ex3"),
str8_lit_comp("ex4"),
str8_lit_comp("ex5"),
str8_lit_comp("ex6"),
str8_lit_comp("ex7"),
str8_lit_comp("ex8"),
str8_lit_comp("ex9"),
str8_lit_comp("ex10"),
str8_lit_comp("ex11"),
str8_lit_comp("ex12"),
str8_lit_comp("ex13"),
str8_lit_comp("ex14"),
str8_lit_comp("ex15"),
str8_lit_comp("ex16"),
str8_lit_comp("ex17"),
str8_lit_comp("ex18"),
str8_lit_comp("ex19"),
str8_lit_comp("ex20"),
str8_lit_comp("ex21"),
str8_lit_comp("ex22"),
str8_lit_comp("ex23"),
str8_lit_comp("ex24"),
str8_lit_comp("ex25"),
str8_lit_comp("ex26"),
str8_lit_comp("ex27"),
str8_lit_comp("ex28"),
str8_lit_comp("ex29"),
str8_lit_comp("num_lock"),
str8_lit_comp("numpad_slash"),
str8_lit_comp("numpad_star"),
str8_lit_comp("numpad_minus"),
str8_lit_comp("numpad_plus"),
str8_lit_comp("numpad_period"),
str8_lit_comp("numpad_0"),
str8_lit_comp("numpad_1"),
str8_lit_comp("numpad_2"),
str8_lit_comp("numpad_3"),
str8_lit_comp("numpad_4"),
str8_lit_comp("numpad_5"),
str8_lit_comp("numpad_6"),
str8_lit_comp("numpad_7"),
str8_lit_comp("numpad_8"),
str8_lit_comp("numpad_9"),
str8_lit_comp("left_mouse"),
str8_lit_comp("middle_mouse"),
str8_lit_comp("right_mouse"),
};
C_LINKAGE_END
@@ -0,0 +1,163 @@
// Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
//- GENERATED CODE
#ifndef WINDOW_MANAGER_META_H
#define WINDOW_MANAGER_META_H
typedef enum OS_Key
{
OS_Key_Null,
OS_Key_Esc,
OS_Key_F1,
OS_Key_F2,
OS_Key_F3,
OS_Key_F4,
OS_Key_F5,
OS_Key_F6,
OS_Key_F7,
OS_Key_F8,
OS_Key_F9,
OS_Key_F10,
OS_Key_F11,
OS_Key_F12,
OS_Key_F13,
OS_Key_F14,
OS_Key_F15,
OS_Key_F16,
OS_Key_F17,
OS_Key_F18,
OS_Key_F19,
OS_Key_F20,
OS_Key_F21,
OS_Key_F22,
OS_Key_F23,
OS_Key_F24,
OS_Key_Tick,
OS_Key_0,
OS_Key_1,
OS_Key_2,
OS_Key_3,
OS_Key_4,
OS_Key_5,
OS_Key_6,
OS_Key_7,
OS_Key_8,
OS_Key_9,
OS_Key_Minus,
OS_Key_Equal,
OS_Key_Backspace,
OS_Key_Tab,
OS_Key_Q,
OS_Key_W,
OS_Key_E,
OS_Key_R,
OS_Key_T,
OS_Key_Y,
OS_Key_U,
OS_Key_I,
OS_Key_O,
OS_Key_P,
OS_Key_LeftBracket,
OS_Key_RightBracket,
OS_Key_BackSlash,
OS_Key_CapsLock,
OS_Key_A,
OS_Key_S,
OS_Key_D,
OS_Key_F,
OS_Key_G,
OS_Key_H,
OS_Key_J,
OS_Key_K,
OS_Key_L,
OS_Key_Semicolon,
OS_Key_Quote,
OS_Key_Return,
OS_Key_Shift,
OS_Key_Z,
OS_Key_X,
OS_Key_C,
OS_Key_V,
OS_Key_B,
OS_Key_N,
OS_Key_M,
OS_Key_Comma,
OS_Key_Period,
OS_Key_Slash,
OS_Key_Ctrl,
OS_Key_Alt,
OS_Key_Space,
OS_Key_Menu,
OS_Key_ScrollLock,
OS_Key_Pause,
OS_Key_Insert,
OS_Key_Home,
OS_Key_PageUp,
OS_Key_Delete,
OS_Key_End,
OS_Key_PageDown,
OS_Key_Up,
OS_Key_Left,
OS_Key_Down,
OS_Key_Right,
OS_Key_Ex0,
OS_Key_Ex1,
OS_Key_Ex2,
OS_Key_Ex3,
OS_Key_Ex4,
OS_Key_Ex5,
OS_Key_Ex6,
OS_Key_Ex7,
OS_Key_Ex8,
OS_Key_Ex9,
OS_Key_Ex10,
OS_Key_Ex11,
OS_Key_Ex12,
OS_Key_Ex13,
OS_Key_Ex14,
OS_Key_Ex15,
OS_Key_Ex16,
OS_Key_Ex17,
OS_Key_Ex18,
OS_Key_Ex19,
OS_Key_Ex20,
OS_Key_Ex21,
OS_Key_Ex22,
OS_Key_Ex23,
OS_Key_Ex24,
OS_Key_Ex25,
OS_Key_Ex26,
OS_Key_Ex27,
OS_Key_Ex28,
OS_Key_Ex29,
OS_Key_NumLock,
OS_Key_NumSlash,
OS_Key_NumStar,
OS_Key_NumMinus,
OS_Key_NumPlus,
OS_Key_NumPeriod,
OS_Key_Num0,
OS_Key_Num1,
OS_Key_Num2,
OS_Key_Num3,
OS_Key_Num4,
OS_Key_Num5,
OS_Key_Num6,
OS_Key_Num7,
OS_Key_Num8,
OS_Key_Num9,
OS_Key_LeftMouseButton,
OS_Key_MiddleMouseButton,
OS_Key_RightMouseButton,
OS_Key_COUNT,
} OS_Key;
C_LINKAGE_BEGIN
extern String8 os_g_key_display_string_table[143];
extern String8 os_g_key_cfg_string_table[143];
C_LINKAGE_END
#endif // WINDOW_MANAGER_META_H
+300
View File
@@ -0,0 +1,300 @@
// Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
////////////////////////////////
//~ rjf: Generated Code
#include "window_manager/generated/window_manager.meta.c"
////////////////////////////////
//~ rjf: Handle Type Helpers
internal OS_Window
os_window_zero(void)
{
OS_Window result = {0};
return result;
}
internal B32
os_window_match(OS_Window a, OS_Window b)
{
B32 result = MemoryMatchStruct(&a, &b);
return result;
}
internal B32
os_monitor_match(OS_Monitor a, OS_Monitor b)
{
B32 result = MemoryMatchStruct(&a, &b);
return result;
}
////////////////////////////////
//~ rjf: Event Functions (Helpers, Implemented Once)
internal String8
os_string_from_event_kind(OS_EventKind kind)
{
String8 result = {0};
switch(kind)
{
case OS_EventKind_Null:
case OS_EventKind_COUNT:
{}break;
case OS_EventKind_Press: {result = str8_lit("Press");}break;
case OS_EventKind_Release: {result = str8_lit("Release");}break;
case OS_EventKind_MouseMove: {result = str8_lit("MouseMove");}break;
case OS_EventKind_Text: {result = str8_lit("Text");}break;
case OS_EventKind_Scroll: {result = str8_lit("Scroll");}break;
case OS_EventKind_WindowLoseFocus: {result = str8_lit("WindowLoseFocus");}break;
case OS_EventKind_WindowClose: {result = str8_lit("WindowClose");}break;
case OS_EventKind_FileDrop: {result = str8_lit("FileDrop");}break;
case OS_EventKind_Wakeup: {result = str8_lit("Wakeup");}break;
}
return result;
}
internal String8List
os_string_list_from_modifiers(Arena *arena, OS_Modifiers modifiers)
{
String8List result = {0};
if(modifiers & OS_Modifier_Ctrl) { str8_list_push(arena, &result, str8_lit("Ctrl")); }
if(modifiers & OS_Modifier_Shift) { str8_list_push(arena, &result, str8_lit("Shift")); }
if(modifiers & OS_Modifier_Alt) { str8_list_push(arena, &result, str8_lit("Alt")); }
return result;
}
internal String8
os_string_from_modifiers_key(Arena *arena, OS_Modifiers modifiers, OS_Key key)
{
String8 result = {0};
if(key != OS_Key_Null)
{
Temp scratch = scratch_begin(&arena, 1);
String8List mods = os_string_list_from_modifiers(scratch.arena, modifiers);
String8 key_string = os_g_key_display_string_table[key];
str8_list_push(scratch.arena, &mods, key_string);
StringJoin join = {0};
join.sep = str8_lit(" + ");
result = str8_list_join(arena, &mods, &join);
scratch_end(scratch);
}
return result;
}
internal U32
os_codepoint_from_modifiers_and_key(OS_Modifiers modifiers, OS_Key key)
{
U32 result = 0;
// rjf: special-case map
local_persist read_only struct {U32 character; OS_Key key; OS_Modifiers modifiers;} map[] =
{
{'!', OS_Key_1, OS_Modifier_Shift},
{'@', OS_Key_2, OS_Modifier_Shift},
{'#', OS_Key_3, OS_Modifier_Shift},
{'$', OS_Key_4, OS_Modifier_Shift},
{'%', OS_Key_5, OS_Modifier_Shift},
{'^', OS_Key_6, OS_Modifier_Shift},
{'&', OS_Key_7, OS_Modifier_Shift},
{'*', OS_Key_8, OS_Modifier_Shift},
{'(', OS_Key_9, OS_Modifier_Shift},
{')', OS_Key_0, OS_Modifier_Shift},
{'_', OS_Key_Minus, OS_Modifier_Shift},
{'_', OS_Key_Minus, OS_Modifier_Shift},
{'-', OS_Key_Minus, 0},
{'=', OS_Key_Equal, 0},
{'+', OS_Key_Equal, OS_Modifier_Shift},
{'`', OS_Key_Tick, 0},
{'~', OS_Key_Tick, OS_Modifier_Shift},
{'[', OS_Key_LeftBracket, 0},
{']', OS_Key_RightBracket, 0},
{'{', OS_Key_LeftBracket, OS_Modifier_Shift},
{'}', OS_Key_RightBracket, OS_Modifier_Shift},
{'\\', OS_Key_BackSlash, 0},
{'|', OS_Key_BackSlash, OS_Modifier_Shift},
{';', OS_Key_Semicolon, 0},
{':', OS_Key_Semicolon, OS_Modifier_Shift},
{'\'', OS_Key_Quote, 0},
{'"', OS_Key_Quote, OS_Modifier_Shift},
{'.', OS_Key_Period, 0},
{',', OS_Key_Comma, 0},
{'<', OS_Key_Period, OS_Modifier_Shift},
{'>', OS_Key_Comma, OS_Modifier_Shift},
{'/', OS_Key_Slash, 0},
{'?', OS_Key_Slash, OS_Modifier_Shift},
{'a', OS_Key_A, 0},
{'b', OS_Key_B, 0},
{'c', OS_Key_C, 0},
{'d', OS_Key_D, 0},
{'e', OS_Key_E, 0},
{'f', OS_Key_F, 0},
{'g', OS_Key_G, 0},
{'h', OS_Key_H, 0},
{'i', OS_Key_I, 0},
{'j', OS_Key_J, 0},
{'k', OS_Key_K, 0},
{'l', OS_Key_L, 0},
{'m', OS_Key_M, 0},
{'n', OS_Key_N, 0},
{'o', OS_Key_O, 0},
{'p', OS_Key_P, 0},
{'q', OS_Key_Q, 0},
{'r', OS_Key_R, 0},
{'s', OS_Key_S, 0},
{'t', OS_Key_T, 0},
{'u', OS_Key_U, 0},
{'v', OS_Key_V, 0},
{'w', OS_Key_W, 0},
{'x', OS_Key_X, 0},
{'y', OS_Key_Y, 0},
{'z', OS_Key_Z, 0},
{'A', OS_Key_A, OS_Modifier_Shift},
{'B', OS_Key_B, OS_Modifier_Shift},
{'C', OS_Key_C, OS_Modifier_Shift},
{'D', OS_Key_D, OS_Modifier_Shift},
{'E', OS_Key_E, OS_Modifier_Shift},
{'F', OS_Key_F, OS_Modifier_Shift},
{'G', OS_Key_G, OS_Modifier_Shift},
{'H', OS_Key_H, OS_Modifier_Shift},
{'I', OS_Key_I, OS_Modifier_Shift},
{'J', OS_Key_J, OS_Modifier_Shift},
{'K', OS_Key_K, OS_Modifier_Shift},
{'L', OS_Key_L, OS_Modifier_Shift},
{'M', OS_Key_M, OS_Modifier_Shift},
{'N', OS_Key_N, OS_Modifier_Shift},
{'O', OS_Key_O, OS_Modifier_Shift},
{'P', OS_Key_P, OS_Modifier_Shift},
{'Q', OS_Key_Q, OS_Modifier_Shift},
{'R', OS_Key_R, OS_Modifier_Shift},
{'S', OS_Key_S, OS_Modifier_Shift},
{'T', OS_Key_T, OS_Modifier_Shift},
{'U', OS_Key_U, OS_Modifier_Shift},
{'V', OS_Key_V, OS_Modifier_Shift},
{'W', OS_Key_W, OS_Modifier_Shift},
{'X', OS_Key_X, OS_Modifier_Shift},
{'Y', OS_Key_Y, OS_Modifier_Shift},
{'Z', OS_Key_Z, OS_Modifier_Shift},
{' ', OS_Key_Space, 0},
};
// rjf: check numeric
if(OS_Key_0 <= key && key <= OS_Key_9)
{
result = '0' + (key - OS_Key_0);
}
// rjf: check special-case map
for(U64 idx = 0; idx < ArrayCount(map); idx += 1)
{
if(map[idx].key == key && map[idx].modifiers == modifiers)
{
result = map[idx].character;
break;
}
}
return result;
}
internal void
os_eat_event(OS_EventList *events, OS_Event *event)
{
DLLRemove(events->first, events->last, event);
events->count -= 1;
}
internal B32
os_key_press(OS_EventList *events, OS_Window window, OS_Modifiers modifiers, OS_Key key)
{
B32 result = 0;
for(OS_Event *event = events->first; event != 0; event = event->next)
{
if((os_window_match(event->window, window) || os_window_match(window, os_window_zero())) &&
event->kind == OS_EventKind_Press && event->key == key && event->modifiers == modifiers)
{
result = 1;
os_eat_event(events, event);
break;
}
}
return result;
}
internal B32
os_key_release(OS_EventList *events, OS_Window window, OS_Modifiers modifiers, OS_Key key)
{
B32 result = 0;
for(OS_Event *event = events->first; event != 0; event = event->next)
{
if((os_window_match(event->window, window) || os_window_match(window, os_window_zero())) &&
event->kind == OS_EventKind_Release && event->key == key && event->modifiers == modifiers)
{
result = 1;
os_eat_event(events, event);
break;
}
}
return result;
}
internal B32
os_text(OS_EventList *events, OS_Window window, U32 character)
{
B32 result = 0;
for(OS_Event *event = events->first; event != 0; event = event->next)
{
if((os_window_match(event->window, window) || os_window_match(window, os_window_zero())) &&
event->kind == OS_EventKind_Text && event->character == character)
{
result = 1;
os_eat_event(events, event);
break;
}
}
return result;
}
internal OS_EventList
os_event_list_copy(Arena *arena, OS_EventList *src)
{
OS_EventList dst = {0};
for(OS_Event *s = src->first; s != 0; s = s->next)
{
OS_Event *d = push_array(arena, OS_Event, 1);
MemoryCopyStruct(d, s);
d->strings = str8_list_copy(arena, &s->strings);
DLLPushBack(dst.first, dst.last, d);
dst.count += 1;
}
return dst;
}
internal void
os_event_list_concat_in_place(OS_EventList *dst, OS_EventList *to_push)
{
if(dst->last && to_push->first)
{
dst->last->next = to_push->first;
to_push->first->prev = dst->last;
dst->last = to_push->last;
dst->count += to_push->count;
}
else if(!dst->last && to_push->first)
{
MemoryCopyStruct(dst, to_push);
}
MemoryZeroStruct(to_push);
}
internal OS_Event *
os_event_list_push_new(Arena *arena, OS_EventList *evts, OS_EventKind kind)
{
OS_Event *evt = push_array(arena, OS_Event, 1);
DLLPushBack(evts->first, evts->last, evt);
evts->count += 1;
evt->timestamp_us = now_time_us();
evt->kind = kind;
return evt;
}
+246
View File
@@ -0,0 +1,246 @@
// Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef OS_GFX_H
#define OS_GFX_H
////////////////////////////////
//~ rjf: Graphics System Info
typedef struct OS_GfxInfo OS_GfxInfo;
struct OS_GfxInfo
{
F32 double_click_time;
F32 caret_blink_time;
F32 default_refresh_rate;
};
////////////////////////////////
//~ rjf: Window Types
typedef U32 OS_WindowFlags;
enum
{
OS_WindowFlag_CustomBorder = (1<<0),
OS_WindowFlag_UseDefaultPosition = (1<<1),
};
typedef struct OS_Window OS_Window;
struct OS_Window
{
U64 u64[1];
};
////////////////////////////////
//~ rjf: External Window Types
typedef struct OS_ExternalWindow OS_ExternalWindow;
struct OS_ExternalWindow
{
U64 u64[1];
};
////////////////////////////////
//~ rjf: Monitor Types
typedef struct OS_Monitor OS_Monitor;
struct OS_Monitor
{
U64 u64[1];
};
typedef struct OS_MonitorArray OS_MonitorArray;
struct OS_MonitorArray
{
OS_Monitor *v;
U64 count;
};
////////////////////////////////
//~ rjf: Cursor Types
typedef enum OS_Cursor
{
OS_Cursor_Pointer,
OS_Cursor_IBar,
OS_Cursor_LeftRight,
OS_Cursor_UpDown,
OS_Cursor_DownRight,
OS_Cursor_UpRight,
OS_Cursor_UpDownLeftRight,
OS_Cursor_HandPoint,
OS_Cursor_Disabled,
OS_Cursor_COUNT,
}
OS_Cursor;
////////////////////////////////
//~ rjf: Generated Code
#include "window_manager/generated/window_manager.meta.h"
////////////////////////////////
//~ rjf: Event Types
typedef enum OS_EventKind
{
OS_EventKind_Null,
OS_EventKind_Press,
OS_EventKind_Release,
OS_EventKind_MouseMove,
OS_EventKind_Text,
OS_EventKind_Scroll,
OS_EventKind_WindowLoseFocus,
OS_EventKind_WindowClose,
OS_EventKind_FileDrop,
OS_EventKind_Wakeup,
OS_EventKind_COUNT
}
OS_EventKind;
typedef U32 OS_Modifiers;
enum
{
OS_Modifier_Ctrl = (1<<0),
OS_Modifier_Shift = (1<<1),
OS_Modifier_Alt = (1<<2),
};
typedef struct OS_Event OS_Event;
struct OS_Event
{
OS_Event *next;
OS_Event *prev;
U64 timestamp_us;
OS_Window window;
OS_EventKind kind;
OS_Modifiers modifiers;
OS_Key key;
B32 is_repeat;
B32 right_sided;
U32 character;
U32 repeat_count;
Vec2F32 pos;
Vec2F32 delta;
String8List strings;
};
typedef struct OS_EventList OS_EventList;
struct OS_EventList
{
U64 count;
OS_Event *first;
OS_Event *last;
};
////////////////////////////////
//~ rjf: Application-Defined Frame Hook Forward Declaration
internal B32 frame(void);
////////////////////////////////
//~ rjf: Handle Type Helpers
internal OS_Window os_window_zero(void);
internal B32 os_window_match(OS_Window a, OS_Window b);
internal B32 os_monitor_match(OS_Monitor a, OS_Monitor b);
////////////////////////////////
//~ rjf: Event Functions (Helpers, Implemented Once)
internal String8 os_string_from_event_kind(OS_EventKind kind);
internal String8List os_string_list_from_modifiers(Arena *arena, OS_Modifiers flags);
internal String8 os_string_from_modifiers_key(Arena *arena, OS_Modifiers modifiers, OS_Key key);
internal U32 os_codepoint_from_modifiers_and_key(OS_Modifiers flags, OS_Key key);
internal void os_eat_event(OS_EventList *events, OS_Event *event);
internal B32 os_key_press(OS_EventList *events, OS_Window window, OS_Modifiers modifiers, OS_Key key);
internal B32 os_key_release(OS_EventList *events, OS_Window window, OS_Modifiers modifiers, OS_Key key);
internal B32 os_text(OS_EventList *events, OS_Window window, U32 character);
internal OS_EventList os_event_list_copy(Arena *arena, OS_EventList *src);
internal void os_event_list_concat_in_place(OS_EventList *dst, OS_EventList *to_push);
internal OS_Event *os_event_list_push_new(Arena *arena, OS_EventList *evts, OS_EventKind kind);
////////////////////////////////
//~ rjf: @os_hooks Main Initialization API (Implemented Per-OS)
internal void os_gfx_init(void);
////////////////////////////////
//~ rjf: @os_hooks Graphics System Info (Implemented Per-OS)
internal OS_GfxInfo *os_get_gfx_info(void);
////////////////////////////////
//~ rjf: @os_hooks Clipboards (Implemented Per-OS)
internal void os_set_clipboard_text(String8 string);
internal String8 os_get_clipboard_text(Arena *arena);
////////////////////////////////
//~ rjf: @os_hooks Windows (Implemented Per-OS)
internal OS_Window os_window_open(Rng2F32 rect, OS_WindowFlags flags, String8 title);
internal void os_window_close(OS_Window window);
internal void os_window_set_title(OS_Window window, String8 title);
internal void os_window_first_paint(OS_Window window);
internal void os_window_focus(OS_Window window);
internal B32 os_window_is_focused(OS_Window window);
internal B32 os_window_is_fullscreen(OS_Window window);
internal void os_window_set_fullscreen(OS_Window window, B32 fullscreen);
internal B32 os_window_is_maximized(OS_Window window);
internal void os_window_set_maximized(OS_Window window, B32 maximized);
internal B32 os_window_is_minimized(OS_Window window);
internal void os_window_set_minimized(OS_Window window, B32 minimized);
internal void os_window_bring_to_front(OS_Window window);
internal void os_window_set_monitor(OS_Window window, OS_Monitor monitor);
internal void os_window_clear_custom_border_data(OS_Window handle);
internal void os_window_push_custom_title_bar(OS_Window handle, F32 thickness);
internal void os_window_push_custom_edges(OS_Window handle, F32 thickness);
internal void os_window_push_custom_title_bar_client_area(OS_Window handle, Rng2F32 rect);
internal Rng2F32 os_rect_from_window(OS_Window window);
internal Rng2F32 os_client_rect_from_window(OS_Window window);
internal F32 os_dpi_from_window(OS_Window window);
////////////////////////////////
//~ rjf: @os_hooks External Windows (Implemented Per-OS)
internal OS_ExternalWindow os_focused_external_window(void);
internal void os_focus_external_window(OS_ExternalWindow ext_window);
////////////////////////////////
//~ rjf: @os_hooks Monitors (Implemented Per-OS)
internal OS_MonitorArray os_push_monitors_array(Arena *arena);
internal OS_Monitor os_primary_monitor(void);
internal OS_Monitor os_monitor_from_window(OS_Window window);
internal String8 os_name_from_monitor(Arena *arena, OS_Monitor monitor);
internal Vec2F32 os_dim_from_monitor(OS_Monitor monitor);
internal F32 os_dpi_from_monitor(OS_Monitor monitor);
////////////////////////////////
//~ rjf: @os_hooks Events (Implemented Per-OS)
internal void os_send_wakeup_event(void);
internal OS_EventList os_get_events(Arena *arena, B32 wait);
internal OS_Modifiers os_get_modifiers(void);
internal B32 os_key_is_down(OS_Key key);
internal Vec2F32 os_mouse_from_window(OS_Window window);
////////////////////////////////
//~ rjf: @os_hooks Cursors (Implemented Per-OS)
internal void os_set_cursor(OS_Cursor cursor);
////////////////////////////////
//~ rjf: @os_hooks Native User-Facing Graphical Messages (Implemented Per-OS)
internal void os_graphical_message(B32 error, String8 title, String8 message);
internal String8 os_graphical_pick_file(Arena *arena, String8 initial_path);
////////////////////////////////
//~ rjf: @os_hooks Shell Operations
internal void os_show_in_filesystem_ui(String8 path);
internal void os_open_in_browser(String8 url);
#endif // OS_GFX_H
+172
View File
@@ -0,0 +1,172 @@
// Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
////////////////////////////////
//~ rjf: Tables
@table(name, display_string, cfg_string)
OS_KeyTable:
{
{Null "Invalid Key" "null" }
{Esc "Escape" "esc" }
{F1 "F1" "f1" }
{F2 "F2" "f2" }
{F3 "F3" "f3" }
{F4 "F4" "f4" }
{F5 "F5" "f5" }
{F6 "F6" "f6" }
{F7 "F7" "f7" }
{F8 "F8" "f8" }
{F9 "F9" "f9" }
{F10 "F10" "f10" }
{F11 "F11" "f11" }
{F12 "F12" "f12" }
{F13 "F13" "f13" }
{F14 "F14" "f14" }
{F15 "F15" "f15" }
{F16 "F16" "f16" }
{F17 "F17" "f17" }
{F18 "F18" "f18" }
{F19 "F19" "f19" }
{F20 "F20" "f20" }
{F21 "F21" "f21" }
{F22 "F22" "f22" }
{F23 "F23" "f23" }
{F24 "F24" "f24" }
{Tick "Tick" "tick" }
{0 "0" "0" }
{1 "1" "1" }
{2 "2" "2" }
{3 "3" "3" }
{4 "4" "4" }
{5 "5" "5" }
{6 "6" "6" }
{7 "7" "7" }
{8 "8" "8" }
{9 "9" "9" }
{Minus "Minus" "minus" }
{Equal "Equal" "equal" }
{Backspace "Backspace" "backspace" }
{Tab "Tab" "tab" }
{Q "Q" "q" }
{W "W" "w" }
{E "E" "e" }
{R "R" "r" }
{T "T" "t" }
{Y "Y" "y" }
{U "U" "u" }
{I "I" "i" }
{O "O" "o" }
{P "P" "p" }
{LeftBracket "Left Bracket" "left_bracket" }
{RightBracket "Right Bracket" "right_bracket" }
{BackSlash "Back Slash" "backslash" }
{CapsLock "Caps Lock" "caps_lock" }
{A "A" "a" }
{S "S" "s" }
{D "D" "d" }
{F "F" "f" }
{G "G" "g" }
{H "H" "h" }
{J "J" "j" }
{K "K" "k" }
{L "L" "l" }
{Semicolon "Semicolon" "semicolon" }
{Quote "Quote" "quote" }
{Return "Return" "return" }
{Shift "Shift" "shift" }
{Z "Z" "z" }
{X "X" "x" }
{C "C" "c" }
{V "V" "v" }
{B "B" "b" }
{N "N" "n" }
{M "M" "m" }
{Comma "Comma" "comma" }
{Period "Period" "period" }
{Slash "Slash" "slash" }
{Ctrl "Ctrl" "ctrl" }
{Alt "Alt" "alt" }
{Space "Space" "space" }
{Menu "Menu" "menu" }
{ScrollLock "Scroll Lock" "scroll_lock" }
{Pause "Pause" "pause" }
{Insert "Insert" "insert" }
{Home "Home" "home" }
{PageUp "Page Up" "page_up" }
{Delete "Delete" "delete" }
{End "End" "end" }
{PageDown "Page Down" "page_down" }
{Up "Up" "up" }
{Left "Left" "left" }
{Down "Down" "down" }
{Right "Right" "right" }
{Ex0 "Ex0" "ex0" }
{Ex1 "Ex1" "ex1" }
{Ex2 "Ex2" "ex2" }
{Ex3 "Ex3" "ex3" }
{Ex4 "Ex4" "ex4" }
{Ex5 "Ex5" "ex5" }
{Ex6 "Ex6" "ex6" }
{Ex7 "Ex7" "ex7" }
{Ex8 "Ex8" "ex8" }
{Ex9 "Ex9" "ex9" }
{Ex10 "Ex10" "ex10" }
{Ex11 "Ex11" "ex11" }
{Ex12 "Ex12" "ex12" }
{Ex13 "Ex13" "ex13" }
{Ex14 "Ex14" "ex14" }
{Ex15 "Ex15" "ex15" }
{Ex16 "Ex16" "ex16" }
{Ex17 "Ex17" "ex17" }
{Ex18 "Ex18" "ex18" }
{Ex19 "Ex19" "ex19" }
{Ex20 "Ex20" "ex20" }
{Ex21 "Ex21" "ex21" }
{Ex22 "Ex22" "ex22" }
{Ex23 "Ex23" "ex23" }
{Ex24 "Ex24" "ex24" }
{Ex25 "Ex25" "ex25" }
{Ex26 "Ex26" "ex26" }
{Ex27 "Ex27" "ex27" }
{Ex28 "Ex28" "ex28" }
{Ex29 "Ex29" "ex29" }
{NumLock "Num Lock" "num_lock" }
{NumSlash "Numpad Slash" "numpad_slash" }
{NumStar "Numpad Star" "numpad_star" }
{NumMinus "Numpad Minus" "numpad_minus" }
{NumPlus "Numpad Plus" "numpad_plus" }
{NumPeriod "Numpad Period" "numpad_period" }
{Num0 "Numpad 0" "numpad_0" }
{Num1 "Numpad 1" "numpad_1" }
{Num2 "Numpad 2" "numpad_2" }
{Num3 "Numpad 3" "numpad_3" }
{Num4 "Numpad 4" "numpad_4" }
{Num5 "Numpad 5" "numpad_5" }
{Num6 "Numpad 6" "numpad_6" }
{Num7 "Numpad 7" "numpad_7" }
{Num8 "Numpad 8" "numpad_8" }
{Num9 "Numpad 9" "numpad_9" }
{LeftMouseButton "Left Mouse Button" "left_mouse" }
{MiddleMouseButton "Middle Mouse Button" "middle_mouse" }
{RightMouseButton "Right Mouse Button" "right_mouse" }
}
////////////////////////////////
//~ rjf: Generators
@enum OS_Key:
{
@expand(OS_KeyTable a) `$(a.name)`,
COUNT,
}
@data(String8) os_g_key_display_string_table:
{
@expand(OS_KeyTable a) `str8_lit_comp("$(a.display_string)")`;
}
@data(String8) os_g_key_cfg_string_table:
{
@expand(OS_KeyTable a) `str8_lit_comp("$(a.cfg_string)")`;
}
+13
View File
@@ -0,0 +1,13 @@
// Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
#include "window_manager.c"
#if WM_STUB
# include "window_manager_stub.c"
#elif OS_WINDOWS
# include "win32/window_manager/win32_window_manager.c"
#elif OS_LINUX
# include "linux/window_manager/linux_window_manager.c"
#else
# error Window manager layer not implemented for this operating system.
#endif
+18
View File
@@ -0,0 +1,18 @@
// Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef WINDOW_MANAGER_INC_H
#define WINDOW_MANAGER_INC_H
#include "window_manager.h"
#if WM_STUB
# include "window_manager_stub.h"
#elif OS_WINDOWS
# include "win32/window_manager/win32_window_manager.h"
#elif OS_LINUX
# include "linux/window_manager/linux_window_manager.h"
#else
# error Window manager layer not implemented for this operating system.
#endif
#endif // WINDOW_MANAGER_INC_H
+279
View File
@@ -0,0 +1,279 @@
////////////////////////////////
//~ rjf: @os_hooks Main Initialization API (Implemented Per-OS)
internal void
os_gfx_init(void)
{
}
////////////////////////////////
//~ rjf: @os_hooks Graphics System Info (Implemented Per-OS)
internal OS_GfxInfo *
os_get_gfx_info(void)
{
local_persist OS_GfxInfo g = {0};
return &g;
}
////////////////////////////////
//~ rjf: @os_hooks Clipboards (Implemented Per-OS)
internal void
os_set_clipboard_text(String8 string)
{
}
internal String8
os_get_clipboard_text(Arena *arena)
{
return str8_zero();
}
////////////////////////////////
//~ rjf: @os_hooks Windows (Implemented Per-OS)
internal OS_Handle
os_window_open(Rng2F32 rect, OS_WindowFlags flags, String8 title)
{
OS_Handle handle = {1};
return handle;
}
internal void
os_window_close(OS_Handle window)
{
}
internal void
os_window_set_title(OS_Handle window, String8 title)
{
}
internal void
os_window_first_paint(OS_Handle window)
{
}
internal void
os_window_focus(OS_Handle window)
{
}
internal B32
os_window_is_focused(OS_Handle window)
{
return 0;
}
internal B32
os_window_is_fullscreen(OS_Handle window)
{
return 0;
}
internal void
os_window_set_fullscreen(OS_Handle window, B32 fullscreen)
{
}
internal B32
os_window_is_maximized(OS_Handle window)
{
return 0;
}
internal void
os_window_set_maximized(OS_Handle window, B32 maximized)
{
}
internal B32
os_window_is_minimized(OS_Handle window)
{
return 0;
}
internal void
os_window_set_minimized(OS_Handle window, B32 minimized)
{
}
internal void
os_window_bring_to_front(OS_Handle window)
{
}
internal void
os_window_set_monitor(OS_Handle window, OS_Handle monitor)
{
}
internal void
os_window_clear_custom_border_data(OS_Handle handle)
{
}
internal void
os_window_push_custom_title_bar(OS_Handle handle, F32 thickness)
{
}
internal void
os_window_push_custom_edges(OS_Handle handle, F32 thickness)
{
}
internal void
os_window_push_custom_title_bar_client_area(OS_Handle handle, Rng2F32 rect)
{
}
internal Rng2F32
os_rect_from_window(OS_Handle window)
{
Rng2F32 rect = r2f32(v2f32(0, 0), v2f32(500, 500));
return rect;
}
internal Rng2F32
os_client_rect_from_window(OS_Handle window)
{
Rng2F32 rect = r2f32(v2f32(0, 0), v2f32(500, 500));
return rect;
}
internal F32
os_dpi_from_window(OS_Handle window)
{
return 96.f;
}
////////////////////////////////
//~ rjf: @os_hooks External Windows (Implemented Per-OS)
internal OS_Handle
os_focused_external_window(void)
{
OS_Handle result = {0};
// TODO(rjf)
return result;
}
internal void
os_focus_external_window(OS_Handle handle)
{
// TODO(rjf)
}
////////////////////////////////
//~ rjf: @os_hooks Monitors (Implemented Per-OS)
internal OS_HandleArray
os_push_monitors_array(Arena *arena)
{
OS_HandleArray arr = {0};
return arr;
}
internal OS_Handle
os_primary_monitor(void)
{
OS_Handle handle = {1};
return handle;
}
internal OS_Handle
os_monitor_from_window(OS_Handle window)
{
OS_Handle handle = {1};
return handle;
}
internal String8
os_name_from_monitor(Arena *arena, OS_Handle monitor)
{
return str8_zero();
}
internal Vec2F32
os_dim_from_monitor(OS_Handle monitor)
{
Vec2F32 v = v2f32(1000, 1000);
return v;
}
internal F32
os_dpi_from_monitor(OS_Handle monitor)
{
return 96.f;
}
////////////////////////////////
//~ rjf: @os_hooks Events (Implemented Per-OS)
internal void
os_send_wakeup_event(void)
{
}
internal OS_EventList
os_get_events(Arena *arena, B32 wait)
{
OS_EventList evts = {0};
return evts;
}
internal OS_Modifiers
os_get_modifiers(void)
{
OS_Modifiers f = 0;
return f;
}
internal B32
os_key_is_down(OS_Key key)
{
return 0;
}
internal Vec2F32
os_mouse_from_window(OS_Handle window)
{
return v2f32(0, 0);
}
////////////////////////////////
//~ rjf: @os_hooks Cursors (Implemented Per-OS)
internal void
os_set_cursor(OS_Cursor cursor)
{
}
////////////////////////////////
//~ rjf: @os_hooks Native User-Facing Graphical Messages (Implemented Per-OS)
internal void
os_graphical_message(B32 error, String8 title, String8 message)
{
}
internal String8
os_graphical_pick_file(Arena *arena, String8 initial_path)
{
return str8_zero();
}
////////////////////////////////
//~ rjf: @os_hooks Shell Operations
internal void
os_show_in_filesystem_ui(String8 path)
{
}
internal void
os_open_in_browser(String8 url)
{
}
+7
View File
@@ -0,0 +1,7 @@
// Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef OS_GFX_STUB_H
#define OS_GFX_STUB_H
#endif // OS_GFX_STUB_H