Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 29 additions & 12 deletions Engine/razix_engine.lua
Original file line number Diff line number Diff line change
Expand Up @@ -232,15 +232,24 @@ project "Razix"
-- Windows specific source files for compilation
files
{
-- platform sepecific implementatioon
"src/Razix/Platform/Windows/*.h",
"src/Razix/Platform/Windows/*.cpp",

"src/Razix/Platform/GLFW/*.h",
"src/Razix/Platform/GLFW/*.cpp",

-- Platform supported Graphics API implementatioon

-- Platform specific implementation (excluding input)
"src/Razix/Platform/Windows/WindowsFileSystem.cpp",
"src/Razix/Platform/Windows/WindowsOS.cpp",
"src/Razix/Platform/Windows/WindowsOS.h",
"src/Razix/Platform/Windows/WindowsSockets.cpp",
"src/Razix/Platform/Windows/WindowsTimer.cpp",
"src/Razix/Platform/Windows/WindowsWindow.cpp",
"src/Razix/Platform/Windows/WindowsWindow.h",

-- GLFW platform files
"src/Razix/Platform/GLFW/GLFWWindow.cpp",
"src/Razix/Platform/GLFW/GLFWWindow.h",

-- Default: Use GLFW input for Windows (can be overridden with premake options)
"src/Razix/Platform/GLFW/GLFWInput.h",
"src/Razix/Platform/GLFW/GLFWInput.cpp",

-- Platform supported Graphics API implementation
"src/Razix/Platform/API/Vulkan/*.h",
"src/Razix/Platform/API/Vulkan/*.cpp",

Expand All @@ -251,6 +260,13 @@ project "Razix"
"vendor/glad/src/glad.c"
}

-- Conditionally include Windows input if option is specified
if _OPTIONS["use-windows-input"] then
removefiles { "src/Razix/Platform/GLFW/GLFWInput.h", "src/Razix/Platform/GLFW/GLFWInput.cpp" }
files { "src/Razix/Platform/Windows/WindowsInput.h", "src/Razix/Platform/Windows/WindowsInput.cpp" }
defines { "RAZIX_USE_WINDOWS_INPUT" }
end

Comment thread
Pikachuxxxx marked this conversation as resolved.
-- Windows specific incldue directories
includedirs
{
Expand Down Expand Up @@ -327,17 +343,18 @@ project "Razix"
"TRACY_ENABLE"
}

-- Windows specific source files for compilation
-- macOS specific source files for compilation
files
{
-- platform sepecific implementatioon
-- Platform specific implementation
"src/Razix/Platform/MacOS/*.h",
"src/Razix/Platform/MacOS/*.cpp",

"src/Razix/Platform/Unix/*.h",
"src/Razix/Platform/Unix/*.cpp",

"src/Razix/Platform/GLFW/*.h",
-- GLFW platform files (default for macOS)
"src/Razix/Platform/GLFW/*.h",
"src/Razix/Platform/GLFW/*.cpp",

"src/Razix/Platform/API/Vulkan/*.h",
Expand Down
11 changes: 0 additions & 11 deletions Engine/src/Razix/Core/OS/RZInput.cpp

This file was deleted.

83 changes: 27 additions & 56 deletions Engine/src/Razix/Core/OS/RZInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,68 +7,39 @@ namespace Razix {
/**
* Input manager for the Engine to interface with various input devices
* such as Keyboard, Mouse, Joystick and other HID devices
*
* Implementation is provided by platform-specific files:
* - GLFWInput.cpp for cross-platform GLFW support
* - WindowsInput.cpp for native Windows support
* Build system selects the appropriate implementation per platform
*/
class RAZIX_API RZInput
{
public:
// TODO: Use a better API convention for selecting input API implementation
// TODO: ReWrite this using a simple static function design pattern rather than using Impls, this is cumbersome to extend
/* Selects the GLFW Input class for polling and reporting input events */
static void SelectGLFWInputManager();

// Keyboard
inline static bool IsKeyPressed(Razix::KeyCode::Key keycode) { return s_Instance->IsKeyPressedImpl(int(keycode)); }
inline static bool IsKeyReleased(Razix::KeyCode::Key keycode) { return s_Instance->IsKeyReleasedImpl(int(keycode)); }
inline static bool IsKeyHeld(Razix::KeyCode::Key keycode) { return s_Instance->IsIsKeyHeldImpl(int(keycode)); }
static bool IsKeyPressed(Razix::KeyCode::Key keycode);
static bool IsKeyReleased(Razix::KeyCode::Key keycode);
static bool IsKeyHeld(Razix::KeyCode::Key keycode);

// Mouse
inline static bool IsMouseButtonPressed(Razix::KeyCode::MouseKey button) { return s_Instance->IsMouseButtonPressedImpl(int(button)); }
inline static bool IsMouseButtonReleased(Razix::KeyCode::MouseKey button) { return s_Instance->IsMouseButtonReleasedImpl(int(button)); }
inline static bool IsMouseButtonHeld(Razix::KeyCode::MouseKey button) { return s_Instance->IsMouseButtonHeldImpl(int(button)); }
inline static std::pair<f32, f32> GetMousePosition() { return s_Instance->GetMousePositionImpl(); }
inline static f32 GetMouseX() { return s_Instance->GetMouseXImpl(); }
inline static f32 GetMouseY() { return s_Instance->GetMouseYImpl(); }

// This is written with the PS5 DualSense controller in mind
// TODO: Support all DualSense buttons
inline static bool IsGamepadConnected() { return s_Instance->IsGamepadConnectedImpl(); }

inline static f32 GetJoyLeftStickHorizontal() { return s_Instance->GetJoyLeftStickHorizontalImpl(); }
inline static f32 GetJoyLeftStickVertical() { return s_Instance->GetJoyLeftStickVerticalImpl(); }
inline static f32 GetJoyRightStickHorizontal() { return s_Instance->GetJoyRightStickHorizontalImpl(); }
inline static f32 GetJoyRightStickVertical() { return s_Instance->GetJoyRightStickVerticalImpl(); }
inline static f32 GetJoyDPadHorizontal() { return s_Instance->GetJoyDPadHorizontalImpl(); }
inline static f32 GetJoyDPadVertical() { return s_Instance->GetJoyDPadVerticalImpl(); }

inline static bool IsCrossPressed() { return s_Instance->IsCrossPressedImpl(); }
inline static bool IsCirclePressed() { return s_Instance->IsCirclePressedImpl(); }
inline static bool IsTrianglePressed() { return s_Instance->IsTrianglePressedImpl(); }
inline static bool IsSquarePressed() { return s_Instance->IsSquarePressedImpl(); }

protected:
virtual bool IsKeyPressedImpl(int keycode) = 0;
virtual bool IsKeyReleasedImpl(int keycode) = 0;
virtual bool IsIsKeyHeldImpl(int keycode) = 0;
virtual bool IsMouseButtonPressedImpl(int button) = 0;
virtual bool IsMouseButtonReleasedImpl(int button) = 0;
virtual bool IsMouseButtonHeldImpl(int button) = 0;
virtual std::pair<f32, f32> GetMousePositionImpl() = 0;
virtual f32 GetMouseXImpl() = 0;
virtual f32 GetMouseYImpl() = 0;

virtual bool IsGamepadConnectedImpl() = 0;
virtual f32 GetJoyLeftStickHorizontalImpl() = 0;
virtual f32 GetJoyLeftStickVerticalImpl() = 0;
virtual f32 GetJoyRightStickHorizontalImpl() = 0;
virtual f32 GetJoyRightStickVerticalImpl() = 0;
virtual f32 GetJoyDPadHorizontalImpl() = 0;
virtual f32 GetJoyDPadVerticalImpl() = 0;
virtual bool IsCrossPressedImpl() = 0;
virtual bool IsCirclePressedImpl() = 0;
virtual bool IsTrianglePressedImpl() = 0;
virtual bool IsSquarePressedImpl() = 0;

protected:
static RZInput* s_Instance;
static bool IsMouseButtonPressed(Razix::KeyCode::MouseKey button);
static bool IsMouseButtonReleased(Razix::KeyCode::MouseKey button);
static bool IsMouseButtonHeld(Razix::KeyCode::MouseKey button);
static std::pair<f32, f32> GetMousePosition();
static f32 GetMouseX();
static f32 GetMouseY();

// Gamepad support for multi-device HID (PS5 DualSense, Xbox controllers, etc.)
static bool IsGamepadConnected();
static f32 GetJoyLeftStickHorizontal();
static f32 GetJoyLeftStickVertical();
static f32 GetJoyRightStickHorizontal();
static f32 GetJoyRightStickVertical();
static f32 GetJoyDPadHorizontal();
static f32 GetJoyDPadVertical();
static bool IsCrossPressed();
static bool IsCirclePressed();
static bool IsTrianglePressed();
static bool IsSquarePressed();
};
} // namespace Razix
Loading