rename 'Input' -> 'ControllerEvent'
This commit is contained in:
parent
00c95e5bee
commit
687cc88a64
@ -1,5 +1,5 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Button types
|
//~ Controller button types
|
||||||
|
|
||||||
Enum(Btn)
|
Enum(Btn)
|
||||||
{
|
{
|
||||||
@ -110,40 +110,49 @@ Enum(Btn)
|
|||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Input types
|
//~ Controller event types
|
||||||
|
|
||||||
Enum(InputKind)
|
Enum(ControllerEventKind)
|
||||||
{
|
{
|
||||||
InputKind_None,
|
ControllerEventKind_None,
|
||||||
|
|
||||||
InputKind_ButtonDown,
|
ControllerEventKind_ButtonDown,
|
||||||
InputKind_ButtonUp,
|
ControllerEventKind_ButtonUp,
|
||||||
|
|
||||||
InputKind_CursorMove,
|
ControllerEventKind_CursorMove,
|
||||||
InputKind_MouseMove,
|
ControllerEventKind_MouseMove,
|
||||||
|
|
||||||
InputKind_Text,
|
ControllerEventKind_Text,
|
||||||
|
|
||||||
InputKind_Quit,
|
ControllerEventKind_Quit,
|
||||||
|
|
||||||
InputKind_Count
|
ControllerEventKind_Count
|
||||||
};
|
};
|
||||||
|
|
||||||
Struct(Input)
|
Struct(ControllerEvent)
|
||||||
{
|
{
|
||||||
InputKind kind;
|
ControllerEventKind kind;
|
||||||
|
|
||||||
/* InputKind_ButtonDown */
|
/* ControllerEventKind_ButtonDown */
|
||||||
/* InputKind_ButtonUp */
|
/* ControllerEventKind_ButtonUp */
|
||||||
Btn button;
|
Btn button;
|
||||||
b32 is_repeat;
|
b32 is_repeat;
|
||||||
|
|
||||||
/* InputKind_Text */
|
/* ControllerEventKind_Text */
|
||||||
u32 text_codepoint;
|
u32 text_codepoint;
|
||||||
|
|
||||||
/* InputKind_CursorMove */
|
/* ControllerEventKind_CursorMove */
|
||||||
Vec2I32 cursor_pos;
|
Vec2I32 cursor_pos;
|
||||||
|
|
||||||
/* InputKind_MouseMove */
|
/* ControllerEventKind_MouseMove */
|
||||||
Vec2I32 mouse_delta;
|
Vec2I32 mouse_delta;
|
||||||
|
|
||||||
|
/* Should be incremented by systems that want to consume the input */
|
||||||
|
u32 consumed;
|
||||||
|
};
|
||||||
|
|
||||||
|
Struct(ControllerEventsArray)
|
||||||
|
{
|
||||||
|
u64 count;
|
||||||
|
ControllerEvent *events;
|
||||||
};
|
};
|
||||||
@ -24,7 +24,7 @@
|
|||||||
# include "base_entry.h"
|
# include "base_entry.h"
|
||||||
# include "base_bitbuff.h"
|
# include "base_bitbuff.h"
|
||||||
# include "base_resource.h"
|
# include "base_resource.h"
|
||||||
# include "base_input.h"
|
# include "base_controller.h"
|
||||||
#elif LanguageIsGpu
|
#elif LanguageIsGpu
|
||||||
# include "base_math_gpu.h"
|
# include "base_math_gpu.h"
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
45
src/pp/pp.c
45
src/pp/pp.c
@ -388,15 +388,14 @@ void PP_UpdateUser(void)
|
|||||||
g->window_restore.len = src.len;
|
g->window_restore.len = src.len;
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 inputs_count = window_frame.inputs_count;
|
ControllerEventsArray controller_events = window_frame.controller_events;
|
||||||
Input *inputs = window_frame.inputs;
|
|
||||||
|
|
||||||
g->screen_size = window_frame.draw_size;
|
g->screen_size = window_frame.draw_size;
|
||||||
g->screen_size.x = MaxI32(g->screen_size.x, 1);
|
g->screen_size.x = MaxI32(g->screen_size.x, 1);
|
||||||
g->screen_size.y = MaxI32(g->screen_size.y, 1);
|
g->screen_size.y = MaxI32(g->screen_size.y, 1);
|
||||||
|
|
||||||
//- Begin UI
|
//- Begin UI
|
||||||
UI_BeginBuild();
|
UI_BeginBuild(&controller_events);
|
||||||
UI_Push(LayoutAxis, Axis_Y);
|
UI_Push(LayoutAxis, Axis_Y);
|
||||||
if (window_frame.forced_top)
|
if (window_frame.forced_top)
|
||||||
{
|
{
|
||||||
@ -538,9 +537,9 @@ void PP_UpdateUser(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Process inputs into user bind state
|
//- Process controller events into user bind state
|
||||||
{
|
{
|
||||||
__profn("Process inputs");
|
__profn("Process controller events");
|
||||||
|
|
||||||
/* Reset bind pressed / released states */
|
/* Reset bind pressed / released states */
|
||||||
for (u32 i = 0; i < countof(g->bind_states); ++i)
|
for (u32 i = 0; i < countof(g->bind_states); ++i)
|
||||||
@ -550,38 +549,38 @@ void PP_UpdateUser(void)
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
for (u64 idx = 0; idx < inputs_count; ++idx)
|
for (u64 idx = 0; idx < controller_events.count; ++idx)
|
||||||
{
|
{
|
||||||
Input *input = &inputs[idx];
|
ControllerEvent *event = &controller_events.events[idx];
|
||||||
if (input->kind == InputKind_Quit)
|
if (event->kind == ControllerEventKind_Quit)
|
||||||
{
|
{
|
||||||
SignalExit(0);
|
SignalExit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input->kind == InputKind_ButtonUp)
|
if (event->kind == ControllerEventKind_ButtonUp)
|
||||||
{
|
{
|
||||||
/* Escape quit */
|
/* Escape quit */
|
||||||
if (input->button == Btn_Esc)
|
if (event->button == Btn_Esc)
|
||||||
{
|
{
|
||||||
SignalExit(0);
|
SignalExit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update mouse pos */
|
/* Update mouse pos */
|
||||||
if (input->kind == InputKind_CursorMove)
|
if (event->kind == ControllerEventKind_CursorMove)
|
||||||
{
|
{
|
||||||
g->screen_cursor = Vec2FromFields(input->cursor_pos);
|
g->screen_cursor = Vec2FromFields(event->cursor_pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update bind states */
|
/* Update bind states */
|
||||||
if ((input->kind == InputKind_ButtonDown || input->kind == InputKind_ButtonUp))
|
if ((event->kind == ControllerEventKind_ButtonDown || event->kind == ControllerEventKind_ButtonUp))
|
||||||
{
|
{
|
||||||
Btn button = input->button;
|
Btn button = event->button;
|
||||||
button = button >= Btn_Count ? Btn_None : button;
|
button = button >= Btn_Count ? Btn_None : button;
|
||||||
PP_BindKind bind = g_binds[button];
|
PP_BindKind bind = g_binds[button];
|
||||||
if (bind)
|
if (bind)
|
||||||
{
|
{
|
||||||
b32 pressed = input->kind == InputKind_ButtonDown;
|
b32 pressed = event->kind == ControllerEventKind_ButtonDown;
|
||||||
#if 0
|
#if 0
|
||||||
b32 out_of_bounds = button >= Btn_M1 && button <= Btn_M5 &&
|
b32 out_of_bounds = button >= Btn_M1 && button <= Btn_M5 &&
|
||||||
(g->ui_cursor.x < 0 ||
|
(g->ui_cursor.x < 0 ||
|
||||||
@ -597,7 +596,7 @@ void PP_UpdateUser(void)
|
|||||||
if (!out_of_bounds)
|
if (!out_of_bounds)
|
||||||
{
|
{
|
||||||
++g->bind_states[bind].num_presses_and_repeats;
|
++g->bind_states[bind].num_presses_and_repeats;
|
||||||
if (input->is_repeat)
|
if (event->is_repeat)
|
||||||
{
|
{
|
||||||
++g->bind_states[bind].num_repeats;
|
++g->bind_states[bind].num_repeats;
|
||||||
}
|
}
|
||||||
@ -1941,22 +1940,16 @@ void PP_UpdateUser(void)
|
|||||||
/* Draw lister */
|
/* Draw lister */
|
||||||
if (g->debug_lister)
|
if (g->debug_lister)
|
||||||
{
|
{
|
||||||
g->debug_lister_pos = g->ui_cursor;
|
|
||||||
|
|
||||||
Vec2 size = VEC2(400, 500);
|
Vec2 size = VEC2(400, 500);
|
||||||
|
|
||||||
Vec2 pos = g->debug_lister_pos;
|
|
||||||
pos.x -= size.x / 2;
|
|
||||||
|
|
||||||
UI_SetNext(LayoutAxis, Axis_Y);
|
UI_SetNext(LayoutAxis, Axis_Y);
|
||||||
UI_SetNext(Tint, Alpha32F(0xFFFFFFFF, 0.5));
|
UI_SetNext(BackgroundColor, Rgba32F(0.075, 0.075, 0.075, 0.99));
|
||||||
UI_SetNext(BackgroundColor, Rgba32F(0.3, 0.3, 0.3, 1));
|
UI_SetNext(BorderColor, Rgba32F(0.2, 0.2, 0.2, 1));
|
||||||
UI_SetNext(BorderColor, Rgba32F(0.4, 0.4, 0.4, 1));
|
|
||||||
UI_SetNext(Border, 2);
|
UI_SetNext(Border, 2);
|
||||||
UI_SetNext(Rounding, 0.25);
|
UI_SetNext(Rounding, 0.1);
|
||||||
UI_SetNext(Parent, pp_root_box);
|
UI_SetNext(Parent, pp_root_box);
|
||||||
UI_SetNext(Flags, UI_BoxFlag_Floating | UI_BoxFlag_ClampFloatingX | UI_BoxFlag_ClampFloatingY);
|
UI_SetNext(Flags, UI_BoxFlag_Floating | UI_BoxFlag_ClampFloatingX | UI_BoxFlag_ClampFloatingY);
|
||||||
UI_SetNext(FloatingPos, pos);
|
UI_SetNext(FloatingPos, g->debug_lister_pos);
|
||||||
UI_SetNext(Width, UI_PIX(size.x, 0));
|
UI_SetNext(Width, UI_PIX(size.x, 0));
|
||||||
UI_SetNext(Height, UI_PIX(size.y, 0));
|
UI_SetNext(Height, UI_PIX(size.y, 0));
|
||||||
UI_Box *lister_box = UI_BuildBox(UI_NilKey);
|
UI_Box *lister_box = UI_BuildBox(UI_NilKey);
|
||||||
|
|||||||
@ -253,7 +253,7 @@ void UI_SetBackgroundTexture(UI_Box *box, GPU_Resource *texture, Vec2 uv0, Vec2
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Begin build
|
//~ Begin build
|
||||||
|
|
||||||
void UI_BeginBuild(void)
|
void UI_BeginBuild(ControllerEventsArray *controller_events)
|
||||||
{
|
{
|
||||||
UI_SharedState *g = &UI_shared_state;
|
UI_SharedState *g = &UI_shared_state;
|
||||||
|
|
||||||
@ -312,7 +312,7 @@ void UI_BeginBuild(void)
|
|||||||
if (!g->back_build_arena)
|
if (!g->back_build_arena)
|
||||||
{
|
{
|
||||||
/* Back buffer not initialized, swap again */
|
/* Back buffer not initialized, swap again */
|
||||||
UI_BeginBuild();
|
UI_BeginBuild(controller_events);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -255,7 +255,7 @@ void UI_SetBackgroundTexture(UI_Box *box, GPU_Resource *texture, Vec2 uv0, Vec2
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Begin build
|
//~ Begin build
|
||||||
|
|
||||||
void UI_BeginBuild(void);
|
void UI_BeginBuild(ControllerEventsArray *controller_events);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ End build
|
//~ End build
|
||||||
|
|||||||
@ -34,8 +34,7 @@ Struct(WND_Frame)
|
|||||||
WND_Handle window_handle;
|
WND_Handle window_handle;
|
||||||
|
|
||||||
/* User input since last update */
|
/* User input since last update */
|
||||||
u64 inputs_count;
|
ControllerEventsArray controller_events;
|
||||||
Input *inputs;
|
|
||||||
|
|
||||||
/* Window info */
|
/* Window info */
|
||||||
Vec2I32 draw_size;
|
Vec2I32 draw_size;
|
||||||
|
|||||||
@ -106,7 +106,7 @@ JobDef(WND_W32_ProcessMessagesForever, sig, id)
|
|||||||
{
|
{
|
||||||
WND_W32_SharedState *g = &WND_W32_shared_state;
|
WND_W32_SharedState *g = &WND_W32_shared_state;
|
||||||
WND_W32_Window *window = &g->window;
|
WND_W32_Window *window = &g->window;
|
||||||
window->w2u_inputs_arena = AcquireArena(Gibi(64));
|
window->w2u_events_arena = AcquireArena(Gibi(64));
|
||||||
|
|
||||||
//- Init hwnd
|
//- Init hwnd
|
||||||
HWND hwnd = 0;
|
HWND hwnd = 0;
|
||||||
@ -167,11 +167,11 @@ JobDef(WND_W32_ProcessMessagesForever, sig, id)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Message processing
|
//~ Message processing
|
||||||
|
|
||||||
void WND_W32_PushInput(WND_W32_Window *window, Input input)
|
void WND_W32_PushEvent(WND_W32_Window *window, ControllerEvent event)
|
||||||
{
|
{
|
||||||
LockTicketMutex(&window->w2u_tm);
|
LockTicketMutex(&window->w2u_tm);
|
||||||
{
|
{
|
||||||
*PushStructNoZero(window->w2u_inputs_arena, Input) = input;
|
*PushStructNoZero(window->w2u_events_arena, ControllerEvent) = event;
|
||||||
}
|
}
|
||||||
UnlockTicketMutex(&window->w2u_tm);
|
UnlockTicketMutex(&window->w2u_tm);
|
||||||
}
|
}
|
||||||
@ -196,7 +196,7 @@ LRESULT CALLBACK WND_W32_WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM l
|
|||||||
case WM_CLOSE:
|
case WM_CLOSE:
|
||||||
case WM_DESTROY:
|
case WM_DESTROY:
|
||||||
{
|
{
|
||||||
WND_W32_PushInput(window, (Input) { .kind = InputKind_Quit });
|
WND_W32_PushEvent(window, (ControllerEvent) { .kind = ControllerEventKind_Quit });
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
//- Keyboard button
|
//- Keyboard button
|
||||||
@ -206,21 +206,21 @@ LRESULT CALLBACK WND_W32_WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM l
|
|||||||
case WM_KEYDOWN:
|
case WM_KEYDOWN:
|
||||||
{
|
{
|
||||||
WORD vk_code = LOWORD(wparam);
|
WORD vk_code = LOWORD(wparam);
|
||||||
Input input = ZI;
|
ControllerEvent event = ZI;
|
||||||
if (msg == WM_KEYDOWN || msg == WM_SYSKEYDOWN)
|
if (msg == WM_KEYDOWN || msg == WM_SYSKEYDOWN)
|
||||||
{
|
{
|
||||||
input.kind = InputKind_ButtonDown;
|
event.kind = ControllerEventKind_ButtonDown;
|
||||||
input.is_repeat = (lparam & 0x40000000) != 0;
|
event.is_repeat = (lparam & 0x40000000) != 0;
|
||||||
}
|
}
|
||||||
else if (msg == WM_KEYUP || msg == WM_SYSKEYUP)
|
else if (msg == WM_KEYUP || msg == WM_SYSKEYUP)
|
||||||
{
|
{
|
||||||
input.kind = InputKind_ButtonUp;
|
event.kind = ControllerEventKind_ButtonUp;
|
||||||
}
|
}
|
||||||
if (vk_code < countof(g->vk_to_btn))
|
if (vk_code < countof(g->vk_to_btn))
|
||||||
{
|
{
|
||||||
input.button = g->vk_to_btn[vk_code];
|
event.button = g->vk_to_btn[vk_code];
|
||||||
}
|
}
|
||||||
WND_W32_PushInput(window, input);
|
WND_W32_PushEvent(window, event);
|
||||||
if (msg == WM_SYSKEYUP || msg == WM_SYSKEYDOWN)
|
if (msg == WM_SYSKEYUP || msg == WM_SYSKEYDOWN)
|
||||||
{
|
{
|
||||||
result = DefWindowProcW(hwnd, msg, wparam, lparam);
|
result = DefWindowProcW(hwnd, msg, wparam, lparam);
|
||||||
@ -268,10 +268,10 @@ LRESULT CALLBACK WND_W32_WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM l
|
|||||||
}
|
}
|
||||||
if ((codepoint >= 32 && codepoint != 127) || codepoint == '\t' || codepoint == '\n')
|
if ((codepoint >= 32 && codepoint != 127) || codepoint == '\t' || codepoint == '\n')
|
||||||
{
|
{
|
||||||
Input input = ZI;
|
ControllerEvent event = ZI;
|
||||||
input.kind = InputKind_Text;
|
event.kind = ControllerEventKind_Text;
|
||||||
input.text_codepoint = codepoint;
|
event.text_codepoint = codepoint;
|
||||||
WND_W32_PushInput(window, input);
|
WND_W32_PushEvent(window, event);
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
@ -285,42 +285,42 @@ LRESULT CALLBACK WND_W32_WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM l
|
|||||||
case WM_RBUTTONDOWN:
|
case WM_RBUTTONDOWN:
|
||||||
case WM_XBUTTONDOWN:
|
case WM_XBUTTONDOWN:
|
||||||
{
|
{
|
||||||
Input input = ZI;
|
ControllerEvent event = ZI;
|
||||||
b32 is_down = msg == WM_LBUTTONDOWN ||
|
b32 is_down = msg == WM_LBUTTONDOWN ||
|
||||||
msg == WM_MBUTTONDOWN ||
|
msg == WM_MBUTTONDOWN ||
|
||||||
msg == WM_RBUTTONDOWN ||
|
msg == WM_RBUTTONDOWN ||
|
||||||
msg == WM_XBUTTONDOWN;
|
msg == WM_XBUTTONDOWN;
|
||||||
if (is_down)
|
if (is_down)
|
||||||
{
|
{
|
||||||
input.kind = InputKind_ButtonDown;
|
event.kind = ControllerEventKind_ButtonDown;
|
||||||
SetCapture(hwnd);
|
SetCapture(hwnd);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
input.kind = InputKind_ButtonUp;
|
event.kind = ControllerEventKind_ButtonUp;
|
||||||
ReleaseCapture();
|
ReleaseCapture();
|
||||||
}
|
}
|
||||||
switch (msg)
|
switch (msg)
|
||||||
{
|
{
|
||||||
case WM_LBUTTONUP: case WM_LBUTTONDOWN: input.button = Btn_M1; break;
|
case WM_LBUTTONUP: case WM_LBUTTONDOWN: event.button = Btn_M1; break;
|
||||||
case WM_RBUTTONUP: case WM_RBUTTONDOWN: input.button = Btn_M2; break;
|
case WM_RBUTTONUP: case WM_RBUTTONDOWN: event.button = Btn_M2; break;
|
||||||
case WM_MBUTTONUP: case WM_MBUTTONDOWN: input.button = Btn_M3; break;
|
case WM_MBUTTONUP: case WM_MBUTTONDOWN: event.button = Btn_M3; break;
|
||||||
case WM_XBUTTONUP: case WM_XBUTTONDOWN:
|
case WM_XBUTTONUP: case WM_XBUTTONDOWN:
|
||||||
{
|
{
|
||||||
u32 wparam_xbutton = GET_XBUTTON_WPARAM(wparam);
|
u32 wparam_xbutton = GET_XBUTTON_WPARAM(wparam);
|
||||||
if (wparam_xbutton == XBUTTON1)
|
if (wparam_xbutton == XBUTTON1)
|
||||||
{
|
{
|
||||||
input.button = Btn_M4;
|
event.button = Btn_M4;
|
||||||
}
|
}
|
||||||
else if (wparam_xbutton == XBUTTON2)
|
else if (wparam_xbutton == XBUTTON2)
|
||||||
{
|
{
|
||||||
input.button = Btn_M5;
|
event.button = Btn_M5;
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
if (input.button)
|
if (event.button)
|
||||||
{
|
{
|
||||||
WND_W32_PushInput(window, input);
|
WND_W32_PushEvent(window, event);
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
@ -333,8 +333,8 @@ LRESULT CALLBACK WND_W32_WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM l
|
|||||||
for (i32 i = 0; i < (dir * delta); i += WHEEL_DELTA)
|
for (i32 i = 0; i < (dir * delta); i += WHEEL_DELTA)
|
||||||
{
|
{
|
||||||
/* Send a button down & button up event simultaneously */
|
/* Send a button down & button up event simultaneously */
|
||||||
WND_W32_PushInput(window, (Input) { .kind = InputKind_ButtonDown, .button = btn });
|
WND_W32_PushEvent(window, (ControllerEvent) { .kind = ControllerEventKind_ButtonDown, .button = btn });
|
||||||
WND_W32_PushInput(window, (Input) { .kind = InputKind_ButtonUp, .button = btn });
|
WND_W32_PushEvent(window, (ControllerEvent) { .kind = ControllerEventKind_ButtonUp, .button = btn });
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
@ -343,10 +343,10 @@ LRESULT CALLBACK WND_W32_WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM l
|
|||||||
{
|
{
|
||||||
i32 x = GET_X_LPARAM(lparam);
|
i32 x = GET_X_LPARAM(lparam);
|
||||||
i32 y = GET_Y_LPARAM(lparam);
|
i32 y = GET_Y_LPARAM(lparam);
|
||||||
Input input = ZI;
|
ControllerEvent event = ZI;
|
||||||
input.kind = InputKind_CursorMove;
|
event.kind = ControllerEventKind_CursorMove;
|
||||||
input.cursor_pos = VEC2I32(x, y);
|
event.cursor_pos = VEC2I32(x, y);
|
||||||
WND_W32_PushInput(window, input);
|
WND_W32_PushEvent(window, event);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
//- Raw mouse move
|
//- Raw mouse move
|
||||||
@ -370,10 +370,10 @@ LRESULT CALLBACK WND_W32_WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM l
|
|||||||
{
|
{
|
||||||
i32 x = raw.data.mouse.lLastX;
|
i32 x = raw.data.mouse.lLastX;
|
||||||
i32 y = raw.data.mouse.lLastY;
|
i32 y = raw.data.mouse.lLastY;
|
||||||
Input input = ZI;
|
ControllerEvent event = ZI;
|
||||||
input.kind = InputKind_MouseMove;
|
event.kind = ControllerEventKind_MouseMove;
|
||||||
input.mouse_delta = VEC2I32(x, y);
|
event.mouse_delta = VEC2I32(x, y);
|
||||||
WND_W32_PushInput(window, input);
|
WND_W32_PushEvent(window, event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EndScratch(scratch);
|
EndScratch(scratch);
|
||||||
@ -424,15 +424,15 @@ WND_Frame WND_BeginFrame(Arena *arena)
|
|||||||
window->first_cmd = 0;
|
window->first_cmd = 0;
|
||||||
window->last_cmd = 0;
|
window->last_cmd = 0;
|
||||||
|
|
||||||
/* Pop inputs */
|
/* Pop user input */
|
||||||
{
|
{
|
||||||
LockTicketMutex(&window->w2u_tm);
|
LockTicketMutex(&window->w2u_tm);
|
||||||
{
|
{
|
||||||
Input *src = (Input *)ArenaBase(window->w2u_inputs_arena);
|
ControllerEvent *src = (ControllerEvent *)ArenaBase(window->w2u_events_arena);
|
||||||
result.inputs_count = ArenaCount(window->w2u_inputs_arena, Input);
|
result.controller_events.count = ArenaCount(window->w2u_events_arena, ControllerEvent);
|
||||||
result.inputs = PushStructsNoZero(arena, Input, result.inputs_count);
|
result.controller_events.events = PushStructsNoZero(arena, ControllerEvent, result.controller_events.count);
|
||||||
CopyStructs(result.inputs, src, result.inputs_count);
|
CopyStructs(result.controller_events.events, src, result.controller_events.count);
|
||||||
ResetArena(window->w2u_inputs_arena);
|
ResetArena(window->w2u_events_arena);
|
||||||
}
|
}
|
||||||
UnlockTicketMutex(&window->w2u_tm);
|
UnlockTicketMutex(&window->w2u_tm);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,7 +21,7 @@ Struct(WND_W32_Window)
|
|||||||
/* Window -> User */
|
/* Window -> User */
|
||||||
/* Reads outside of window thread must lock */
|
/* Reads outside of window thread must lock */
|
||||||
TicketMutex w2u_tm;
|
TicketMutex w2u_tm;
|
||||||
Arena *w2u_inputs_arena;
|
Arena *w2u_events_arena;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
@ -82,5 +82,5 @@ JobDecl(WND_W32_ProcessMessagesForever, EmptySig);
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Message processing
|
//~ Message processing
|
||||||
|
|
||||||
void WND_W32_PushInput(WND_W32_Window *window, Input input);
|
void WND_W32_PushEvent(WND_W32_Window *window, ControllerEvent event);
|
||||||
LRESULT CALLBACK WND_W32_WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
LRESULT CALLBACK WND_W32_WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user