chore(event): consolidate window and input functions

This commit is contained in:
fallenoak 2023-03-17 21:57:05 -05:00 committed by GitHub
parent c2a5dd0568
commit dbf840e6ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 62 additions and 74 deletions

View File

@ -1,5 +1,5 @@
#include "client/Console.hpp"
#include "event/Window.hpp"
#include "event/Input.hpp"
#include "gx/Device.hpp"
#include "util/CVar.hpp"
#include <cstring>

View File

@ -53,6 +53,8 @@ void IEvtInputSetMouseMode(EvtContext* context, MOUSEMODE mode, uint32_t holdBut
const char* KeyCodeToString(KEY key);
int32_t OsGuiProcessMessage(void* message);
int32_t OsInputGet(OSINPUT* id, int32_t* param0, int32_t* param1, int32_t* param2, int32_t* param3);
void OsInputInitialize();
@ -69,4 +71,6 @@ void OsQueuePut(OSINPUT id, int32_t param0, int32_t param1, int32_t param2, int3
void OsQueueSetParam(int32_t index, int32_t param);
int32_t OsWindowProc(void* window, uint32_t message, uintptr_t wparam, intptr_t lparam);
#endif

View File

@ -1,10 +0,0 @@
#ifndef EVENT_WINDOW_HPP
#define EVENT_WINDOW_HPP
#include <cstdint>
int32_t OsGuiProcessMessage(void* message);
int32_t OsWindowProc(void* window, uint32_t message, uintptr_t wparam, intptr_t lparam);
#endif

View File

@ -1,5 +1,9 @@
#include "event/Input.hpp"
int32_t OsGuiProcessMessage(void* message) {
return 0;
}
int32_t OsInputGet(OSINPUT* id, int32_t* param0, int32_t* param1, int32_t* param2, int32_t* param3) {
// TODO
return 0;
@ -8,3 +12,7 @@ int32_t OsInputGet(OSINPUT* id, int32_t* param0, int32_t* param1, int32_t* param
void OsInputSetMouseMode(OS_MOUSE_MODE mode) {
// TODO
}
int32_t OsWindowProc(void* window, uint32_t message, uintptr_t wparam, intptr_t lparam) {
return 0;
}

View File

@ -1,9 +0,0 @@
#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;
}

View File

@ -1,6 +1,10 @@
#include "event/Input.hpp"
#include <common/Time.hpp>
int32_t OsGuiProcessMessage(void* message) {
return 0;
}
int32_t OsInputGet(OSINPUT* id, int32_t* param0, int32_t* param1, int32_t* param2, int32_t* param3) {
// TODO
// Unknown logic
@ -25,3 +29,7 @@ int32_t OsInputGet(OSINPUT* id, int32_t* param0, int32_t* param1, int32_t* param
void OsInputSetMouseMode(OS_MOUSE_MODE mode) {
// TODO
}
int32_t OsWindowProc(void* window, uint32_t message, uintptr_t wparam, intptr_t lparam) {
return 0;
}

View File

@ -1,9 +0,0 @@
#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;
}

View File

@ -1,5 +1,4 @@
#include "event/Input.hpp"
#include "event/Window.hpp"
#include <storm/Error.hpp>
#include <windows.h>
@ -11,6 +10,11 @@ void RestoreMouse() {
// TODO
}
int32_t OsGuiProcessMessage(void* message) {
// TODO
return 0;
}
int32_t OsInputGet(OSINPUT* id, int32_t* param0, int32_t* param1, int32_t* param2, int32_t* param3) {
// TODO window rect comparisons
@ -74,3 +78,39 @@ void OsInputSetMouseMode(OS_MOUSE_MODE mode) {
CenterMouse();
}
}
int32_t OsWindowProc(void* window, uint32_t message, uintptr_t wparam, intptr_t lparam) {
auto hwnd = static_cast<HWND>(window);
// TODO
switch (message) {
// TODO handle remaining message types
case WM_ACTIVATE: {
auto isMinimized = IsIconic(hwnd);
auto isActive = wparam != WA_INACTIVE;
Input::s_windowFocused = isActive && !isMinimized;
// TODO capture
// TODO mouse speed
OsQueuePut(OS_INPUT_FOCUS, Input::s_windowFocused != 0, 0, 0, 0);
break;
}
case WM_CLOSE: {
OsQueuePut(OS_INPUT_CLOSE, 0, 0, 0, 0);
return 0;
}
default:
break;
}
// TODO
return DefWindowProc(static_cast<HWND>(window), message, wparam, lparam);
}

View File

@ -1,44 +0,0 @@
#include "event/Window.hpp"
#include "event/Input.hpp"
#include <windows.h>
int32_t OsGuiProcessMessage(void* message) {
// TODO
return 0;
}
int32_t OsWindowProc(void* window, uint32_t message, uintptr_t wparam, intptr_t lparam) {
auto hwnd = static_cast<HWND>(window);
// TODO
switch (message) {
// TODO handle remaining message types
case WM_ACTIVATE: {
auto isMinimized = IsIconic(hwnd);
auto isActive = wparam != WA_INACTIVE;
Input::s_windowFocused = isActive && !isMinimized;
// TODO capture
// TODO mouse speed
OsQueuePut(OS_INPUT_FOCUS, Input::s_windowFocused != 0, 0, 0, 0);
break;
}
case WM_CLOSE: {
OsQueuePut(OS_INPUT_CLOSE, 0, 0, 0, 0);
return 0;
}
default:
break;
}
// TODO
return DefWindowProc(static_cast<HWND>(window), message, wparam, lparam);
}