From 885eeeabd8223ea58d9afa6e410c840c028824d2 Mon Sep 17 00:00:00 2001 From: fallenoak Date: Wed, 15 Mar 2023 17:40:07 -0500 Subject: [PATCH] feat(event): implement OsInputGet for windows --- src/event/Input.cpp | 4 ++-- src/event/Input.hpp | 2 ++ src/event/Window.hpp | 2 ++ src/event/linux/Window.cpp | 4 ++++ src/event/mac/Window.cpp | 4 ++++ src/event/win/Input.cpp | 34 ++++++++++++++++++++++++++++++++-- src/event/win/Window.cpp | 5 +++++ 7 files changed, 51 insertions(+), 4 deletions(-) diff --git a/src/event/Input.cpp b/src/event/Input.cpp index 28859bb..5b6b770 100644 --- a/src/event/Input.cpp +++ b/src/event/Input.cpp @@ -19,8 +19,6 @@ namespace Input { CRect s_boundingRect; - int32_t s_queueHead; - int32_t s_queueTail; OSEVENT s_queue[32]; MOUSEBUTTON s_buttonConversion[16] = { @@ -51,6 +49,8 @@ MOUSEMODE Input::s_mouseMode; int32_t Input::s_numlockState; int32_t Input::s_simulatedRightButtonClick; uint32_t Input::s_metaKeyState; +int32_t Input::s_queueHead; +int32_t Input::s_queueTail; #if defined(WHOA_SYSTEM_WIN) int32_t Input::s_savedMouseSpeed; diff --git a/src/event/Input.hpp b/src/event/Input.hpp index 171dba6..2c8c04c 100644 --- a/src/event/Input.hpp +++ b/src/event/Input.hpp @@ -19,6 +19,8 @@ namespace Input { extern int32_t s_numlockState; extern int32_t s_simulatedRightButtonClick; extern uint32_t s_metaKeyState; + extern int32_t s_queueHead; + extern int32_t s_queueTail; #if defined(WHOA_SYSTEM_WIN) extern int32_t s_savedMouseSpeed; diff --git a/src/event/Window.hpp b/src/event/Window.hpp index d694951..0772910 100644 --- a/src/event/Window.hpp +++ b/src/event/Window.hpp @@ -3,6 +3,8 @@ #include +int32_t OsGuiProcessMessage(void* message); + int32_t OsWindowProc(void* window, uint32_t message, uintptr_t wparam, intptr_t lparam); #endif diff --git a/src/event/linux/Window.cpp b/src/event/linux/Window.cpp index 5f6899f..971365c 100644 --- a/src/event/linux/Window.cpp +++ b/src/event/linux/Window.cpp @@ -1,5 +1,9 @@ #include "event/Window.hpp" +int32_t OsGuiProcessMessage(void* message) { + return 0; +} + int32_t OsWindowProc(void* window, uint32_t message, uintptr_t wparam, intptr_t lparam) { return 0; } diff --git a/src/event/mac/Window.cpp b/src/event/mac/Window.cpp index 5f6899f..971365c 100644 --- a/src/event/mac/Window.cpp +++ b/src/event/mac/Window.cpp @@ -1,5 +1,9 @@ #include "event/Window.hpp" +int32_t OsGuiProcessMessage(void* message) { + return 0; +} + int32_t OsWindowProc(void* window, uint32_t message, uintptr_t wparam, intptr_t lparam) { return 0; } diff --git a/src/event/win/Input.cpp b/src/event/win/Input.cpp index 38475df..00a48c0 100644 --- a/src/event/win/Input.cpp +++ b/src/event/win/Input.cpp @@ -1,6 +1,36 @@ #include "event/Input.hpp" +#include "event/Window.hpp" +#include int32_t OsInputGet(OSINPUT* id, int32_t* param0, int32_t* param1, int32_t* param2, int32_t* param3) { - // TODO - return 0; + // TODO window rect comparisons + + while (Input::s_queueTail == Input::s_queueHead) { + MSG msg; + + if (!PeekMessage(&msg, nullptr, 0, 0, 0)) { + return 0; + } + + if (!GetMessage(&msg, nullptr, 0, 0)) { + *id = OS_INPUT_SHUTDOWN; + break; + } + + if (OsGuiProcessMessage(&msg)) { + break; + } + + if (Input::s_queueTail != Input::s_queueHead) { + break; + } + + TranslateMessage(&msg); + + DispatchMessage(&msg); + } + + OsQueueGet(id, param0, param1, param2, param3); + + return 1; } diff --git a/src/event/win/Window.cpp b/src/event/win/Window.cpp index df317c8..cd6a1cd 100644 --- a/src/event/win/Window.cpp +++ b/src/event/win/Window.cpp @@ -2,6 +2,11 @@ #include "event/Input.hpp" #include +int32_t OsGuiProcessMessage(void* message) { + // TODO + return 0; +} + int32_t OsWindowProc(void* window, uint32_t message, uintptr_t wparam, intptr_t lparam) { // TODO