MCPcopy Create free account
hub / github.com/Ubpa/Utopia / OnUpdate

Method OnUpdate

src/Core/Systems/InputSystem.cpp:10–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8using namespace Ubpa::UECS;
9
10void InputSystem::OnUpdate(Schedule& schedule) {
11 if (!ImGui::GetCurrentContext())
12 return;
13
14 schedule.RegisterJob([](Singleton<Input> input) {
15 const auto& io = ImGui::GetIO();
16
17 // ============================
18 // [Basic]
19 // ============================
20 input->DisplaySize = io.DisplaySize;
21 input->MousePos = io.MousePos;
22 memcpy(input->MouseDown, io.MouseDown, 5 * sizeof(bool));
23 input->MouseWheel = io.MouseWheel;
24 input->MouseWheelH = io.MouseWheelH;
25 input->KeyCtrl = io.KeyCtrl;
26 input->KeyShift = io.KeyShift;
27 input->KeyAlt = io.KeyAlt;
28 input->KeySuper = io.KeySuper;
29 memcpy(input->KeysDown, io.KeysDown, 512 * sizeof(bool));
30 memcpy(input->MouseClicked, io.MouseClicked, 5 * sizeof(bool));
31
32 // ============================
33 // [Pro]
34 // ============================
35 // Forward compatibility not guaranteed!
36 input->MouseInDisplayPre = input->MouseInDisplay;
37 input->MouseInDisplay = io.MousePos.x >= 0.f && io.MousePos.x <= io.DisplaySize.x
38 && io.MousePos.y >= 0.f && io.MousePos.y <= io.DisplaySize.y;
39
40 input->MousePosPrev = io.MousePosPrev;
41 input->MouseDelta = io.MouseDelta;
42 memcpy(input->MouseClickedPos, io.MouseClickedPos, 5 * sizeof(pointf2));
43 memcpy(input->MouseDoubleClicked, io.MouseDoubleClicked, 5 * sizeof(bool));
44 memcpy(input->MouseReleased, io.MouseReleased, 5 * sizeof(bool));
45 memcpy(input->MouseDownDuration, io.MouseDownDuration, 5 * sizeof(float));
46 memcpy(input->KeysDownDuration, io.KeysDownDuration, 512 * sizeof(float));
47 }, SystemFuncName);
48}

Callers

nothing calls this directly

Calls 1

RegisterJobMethod · 0.80

Tested by

no test coverage detected