docs: update TEST_SPEC.md and README.md to reflect new directory structure
- TEST_SPEC.md: Updated test directory structure to reflect Core/Asset, Core/IO, and Resources/<Type> subdirectories - TEST_SPEC.md: Updated module names and test counts (852 total) - TEST_SPEC.md: Updated build commands for new Resources subdirectories - README.md: Updated engine structure with Core/Asset/ and Core/IO/ - README.md: Updated Resources section with layered architecture - README.md: Updated test coverage table with accurate counts
This commit is contained in:
@@ -1,250 +0,0 @@
|
||||
#include "Input/Platform/WindowsInputModule.h"
|
||||
#include "Input/InputManager.h"
|
||||
#include <Windows.h>
|
||||
|
||||
namespace XCEngine {
|
||||
namespace Input {
|
||||
namespace Platform {
|
||||
|
||||
WindowsInputModule::WindowsInputModule()
|
||||
: m_hwnd(nullptr)
|
||||
, m_isInitialized(false) {
|
||||
}
|
||||
|
||||
WindowsInputModule::~WindowsInputModule() {
|
||||
Shutdown();
|
||||
}
|
||||
|
||||
void WindowsInputModule::Initialize(void* windowHandle) {
|
||||
if (m_isInitialized) return;
|
||||
|
||||
m_hwnd = reinterpret_cast<HWND>(windowHandle);
|
||||
m_isInitialized = true;
|
||||
m_lastMousePosition = Math::Vector2::Zero();
|
||||
}
|
||||
|
||||
void WindowsInputModule::Shutdown() {
|
||||
if (!m_isInitialized) return;
|
||||
|
||||
m_hwnd = nullptr;
|
||||
m_isInitialized = false;
|
||||
}
|
||||
|
||||
void WindowsInputModule::PumpEvents() {
|
||||
}
|
||||
|
||||
void WindowsInputModule::HandleMessage(size_t hwnd, unsigned int message, size_t wParam, size_t lParam) {
|
||||
if (!m_isInitialized) return;
|
||||
|
||||
switch (message) {
|
||||
case WM_KEYDOWN:
|
||||
ProcessKeyDown(wParam, lParam);
|
||||
break;
|
||||
|
||||
case WM_KEYUP:
|
||||
ProcessKeyUp(wParam);
|
||||
break;
|
||||
|
||||
case WM_CHAR:
|
||||
ProcessCharInput(wParam);
|
||||
break;
|
||||
|
||||
case WM_MOUSEMOVE:
|
||||
ProcessMouseMove(wParam, lParam);
|
||||
break;
|
||||
|
||||
case WM_LBUTTONDOWN:
|
||||
ProcessMouseButton(wParam, lParam, true, MouseButton::Left);
|
||||
break;
|
||||
|
||||
case WM_LBUTTONUP:
|
||||
ProcessMouseButton(wParam, lParam, false, MouseButton::Left);
|
||||
break;
|
||||
|
||||
case WM_RBUTTONDOWN:
|
||||
ProcessMouseButton(wParam, lParam, true, MouseButton::Right);
|
||||
break;
|
||||
|
||||
case WM_RBUTTONUP:
|
||||
ProcessMouseButton(wParam, lParam, false, MouseButton::Right);
|
||||
break;
|
||||
|
||||
case WM_MBUTTONDOWN:
|
||||
ProcessMouseButton(wParam, lParam, true, MouseButton::Middle);
|
||||
break;
|
||||
|
||||
case WM_MBUTTONUP:
|
||||
ProcessMouseButton(wParam, lParam, false, MouseButton::Middle);
|
||||
break;
|
||||
|
||||
case WM_MOUSEWHEEL:
|
||||
ProcessMouseWheel(wParam, lParam);
|
||||
break;
|
||||
|
||||
case WM_XBUTTONDOWN:
|
||||
ProcessMouseButton(wParam, lParam, true,
|
||||
(HIWORD(static_cast<UINT>(wParam)) == 1) ? MouseButton::Button4 : MouseButton::Button5);
|
||||
break;
|
||||
|
||||
case WM_XBUTTONUP:
|
||||
ProcessMouseButton(wParam, lParam, false,
|
||||
(HIWORD(static_cast<UINT>(wParam)) == 1) ? MouseButton::Button4 : MouseButton::Button5);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void WindowsInputModule::ProcessKeyDown(size_t wParam, size_t lParam) {
|
||||
bool repeat = (lParam & (1 << 30)) != 0;
|
||||
KeyCode keyCode = VKCodeToKeyCode(static_cast<int>(wParam));
|
||||
|
||||
bool alt = (GetKeyState(VK_MENU) & 0x8000) != 0;
|
||||
bool ctrl = (GetKeyState(VK_CONTROL) & 0x8000) != 0;
|
||||
bool shift = (GetKeyState(VK_SHIFT) & 0x8000) != 0;
|
||||
bool meta = false;
|
||||
|
||||
if (keyCode != KeyCode::None) {
|
||||
InputManager::Get().ProcessKeyDown(keyCode, repeat, alt, ctrl, shift, meta);
|
||||
}
|
||||
}
|
||||
|
||||
void WindowsInputModule::ProcessKeyUp(size_t wParam) {
|
||||
KeyCode keyCode = VKCodeToKeyCode(static_cast<int>(wParam));
|
||||
|
||||
bool alt = (GetKeyState(VK_MENU) & 0x8000) != 0;
|
||||
bool ctrl = (GetKeyState(VK_CONTROL) & 0x8000) != 0;
|
||||
bool shift = (GetKeyState(VK_SHIFT) & 0x8000) != 0;
|
||||
bool meta = false;
|
||||
|
||||
if (keyCode != KeyCode::None) {
|
||||
InputManager::Get().ProcessKeyUp(keyCode, alt, ctrl, shift, meta);
|
||||
}
|
||||
}
|
||||
|
||||
void WindowsInputModule::ProcessMouseMove(size_t wParam, size_t lParam) {
|
||||
int x = LOWORD(static_cast<UINT>(lParam));
|
||||
int y = HIWORD(static_cast<UINT>(lParam));
|
||||
|
||||
int deltaX = x - static_cast<int>(m_lastMousePosition.x);
|
||||
int deltaY = y - static_cast<int>(m_lastMousePosition.y);
|
||||
|
||||
m_lastMousePosition.x = static_cast<float>(x);
|
||||
m_lastMousePosition.y = static_cast<float>(y);
|
||||
|
||||
InputManager::Get().ProcessMouseMove(x, y, deltaX, deltaY);
|
||||
}
|
||||
|
||||
void WindowsInputModule::ProcessMouseButton(size_t wParam, size_t lParam, bool pressed, MouseButton button) {
|
||||
int x = LOWORD(static_cast<UINT>(lParam));
|
||||
int y = HIWORD(static_cast<UINT>(lParam));
|
||||
|
||||
InputManager::Get().ProcessMouseButton(button, pressed, x, y);
|
||||
}
|
||||
|
||||
void WindowsInputModule::ProcessMouseWheel(size_t wParam, size_t lParam) {
|
||||
int x = LOWORD(static_cast<UINT>(lParam));
|
||||
int y = HIWORD(static_cast<UINT>(lParam));
|
||||
short delta = static_cast<short>(HIWORD(static_cast<UINT>(wParam)));
|
||||
|
||||
InputManager::Get().ProcessMouseWheel(static_cast<float>(delta) / 120.0f, x, y);
|
||||
}
|
||||
|
||||
void WindowsInputModule::ProcessCharInput(size_t wParam) {
|
||||
char c = static_cast<char>(wParam);
|
||||
|
||||
if (c >= 32 && c < 127) {
|
||||
InputManager::Get().ProcessTextInput(c);
|
||||
}
|
||||
}
|
||||
|
||||
KeyCode WindowsInputModule::VKCodeToKeyCode(int vkCode) {
|
||||
switch (vkCode) {
|
||||
case 'A': return KeyCode::A;
|
||||
case 'B': return KeyCode::B;
|
||||
case 'C': return KeyCode::C;
|
||||
case 'D': return KeyCode::D;
|
||||
case 'E': return KeyCode::E;
|
||||
case 'F': return KeyCode::F;
|
||||
case 'G': return KeyCode::G;
|
||||
case 'H': return KeyCode::H;
|
||||
case 'I': return KeyCode::I;
|
||||
case 'J': return KeyCode::J;
|
||||
case 'K': return KeyCode::K;
|
||||
case 'L': return KeyCode::L;
|
||||
case 'M': return KeyCode::M;
|
||||
case 'N': return KeyCode::N;
|
||||
case 'O': return KeyCode::O;
|
||||
case 'P': return KeyCode::P;
|
||||
case 'Q': return KeyCode::Q;
|
||||
case 'R': return KeyCode::R;
|
||||
case 'S': return KeyCode::S;
|
||||
case 'T': return KeyCode::T;
|
||||
case 'U': return KeyCode::U;
|
||||
case 'V': return KeyCode::V;
|
||||
case 'W': return KeyCode::W;
|
||||
case 'X': return KeyCode::X;
|
||||
case 'Y': return KeyCode::Y;
|
||||
case 'Z': return KeyCode::Z;
|
||||
|
||||
case '0': return KeyCode::Zero;
|
||||
case '1': return KeyCode::One;
|
||||
case '2': return KeyCode::Two;
|
||||
case '3': return KeyCode::Three;
|
||||
case '4': return KeyCode::Four;
|
||||
case '5': return KeyCode::Five;
|
||||
case '6': return KeyCode::Six;
|
||||
case '7': return KeyCode::Seven;
|
||||
case '8': return KeyCode::Eight;
|
||||
case '9': return KeyCode::Nine;
|
||||
|
||||
case VK_SPACE: return KeyCode::Space;
|
||||
case VK_TAB: return KeyCode::Tab;
|
||||
case VK_RETURN: return KeyCode::Enter;
|
||||
case VK_ESCAPE: return KeyCode::Escape;
|
||||
case VK_SHIFT: return KeyCode::LeftShift;
|
||||
case VK_CONTROL: return KeyCode::LeftCtrl;
|
||||
case VK_MENU: return KeyCode::LeftAlt;
|
||||
|
||||
case VK_UP: return KeyCode::Up;
|
||||
case VK_DOWN: return KeyCode::Down;
|
||||
case VK_LEFT: return KeyCode::Left;
|
||||
case VK_RIGHT: return KeyCode::Right;
|
||||
|
||||
case VK_HOME: return KeyCode::Home;
|
||||
case VK_END: return KeyCode::End;
|
||||
case VK_PRIOR: return KeyCode::PageUp;
|
||||
case VK_NEXT: return KeyCode::PageDown;
|
||||
case VK_DELETE: return KeyCode::Delete;
|
||||
case VK_BACK: return KeyCode::Backspace;
|
||||
|
||||
case VK_F1: return KeyCode::F1;
|
||||
case VK_F2: return KeyCode::F2;
|
||||
case VK_F3: return KeyCode::F3;
|
||||
case VK_F4: return KeyCode::F4;
|
||||
case VK_F5: return KeyCode::F5;
|
||||
case VK_F6: return KeyCode::F6;
|
||||
case VK_F7: return KeyCode::F7;
|
||||
case VK_F8: return KeyCode::F8;
|
||||
case VK_F9: return KeyCode::F9;
|
||||
case VK_F10: return KeyCode::F10;
|
||||
case VK_F11: return KeyCode::F11;
|
||||
case VK_F12: return KeyCode::F12;
|
||||
|
||||
case VK_OEM_MINUS: return KeyCode::Minus;
|
||||
case VK_OEM_PLUS: return KeyCode::Equals;
|
||||
case VK_OEM_4: return KeyCode::BracketLeft;
|
||||
case VK_OEM_6: return KeyCode::BracketRight;
|
||||
case 0xBA: return KeyCode::Semicolon;
|
||||
case 0xDE: return KeyCode::Quote;
|
||||
case VK_OEM_COMMA: return KeyCode::Comma;
|
||||
case VK_OEM_PERIOD: return KeyCode::Period;
|
||||
case VK_OEM_2: return KeyCode::Slash;
|
||||
case VK_OEM_5: return KeyCode::Backslash;
|
||||
case VK_OEM_3: return KeyCode::Backtick;
|
||||
|
||||
default: return KeyCode::None;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Platform
|
||||
} // namespace Input
|
||||
} // namespace XCEngine
|
||||
Reference in New Issue
Block a user