Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revamp Input to reintroduce KeyStateFrameChangeLog #591

Merged
merged 20 commits into from
Nov 11, 2023
Merged
Show file tree
Hide file tree
Changes from 17 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
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ add_subdirectory(thirdparty)
add_subdirectory(resources)
add_subdirectory(graphics)
add_subdirectory(audio)
add_subdirectory(input)
add_subdirectory(src)

if(NOVELRT_BUILD_SAMPLES)
Expand Down
6 changes: 5 additions & 1 deletion include/NovelRT/Ecs/Input/Ecs.Input.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
#error NovelRT does not support including types explicitly by default. Please include Ecs.h instead for the Ecs namespace subset.
#endif

#include "../../Input/Input.h"
#include <NovelRT/Input/IInputDevice.hpp>
#include <NovelRT/Input/InputAction.hpp>
#include <NovelRT/Input/KeyState.hpp>
#include <NovelRT/Input/KeyStateFrameChangeLog.hpp>
#include <NovelRT/Input/NovelKey.hpp>
#include <map>

namespace NovelRT::Ecs::Input
Expand Down
6 changes: 2 additions & 4 deletions include/NovelRT/Exceptions/Exceptions.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//
// Created by Matt on 06/01/2021.
//
// Copyright © Matt Jones and Contributors. Licensed under the MIT Licence (MIT). See LICENCE.md in the repository root
// for more information.

#ifndef NOVELRT_EXCEPTIONS_H
#define NOVELRT_EXCEPTIONS_H
Expand All @@ -17,7 +16,6 @@
#include "NotInitialisedException.h"
#include "NotSupportedException.h"
#include "NullPointerException.h"
#include "OpenGLLinkageFailureException.h"
#include "OutOfMemoryException.h"
#include "RuntimeNotFoundException.h"
#include "TimeoutException.h"
Expand Down
23 changes: 0 additions & 23 deletions include/NovelRT/Exceptions/OpenGLLinkageFailureException.h

This file was deleted.

26 changes: 0 additions & 26 deletions include/NovelRT/Input/Glfw/Input.Glfw.h

This file was deleted.

34 changes: 0 additions & 34 deletions include/NovelRT/Input/Input.h

This file was deleted.

25 changes: 0 additions & 25 deletions include/NovelRT/Input/KeyState.h

This file was deleted.

2 changes: 0 additions & 2 deletions include/NovelRT/NovelRT.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@
#include <NovelRT/Threading/Threading.h>
#include <NovelRT/Windowing/Windowing.h>
#include <NovelRT/Windowing/Glfw/Windowing.Glfw.h>
#include <NovelRT/Input/Input.h>
#include <NovelRT/Input/Glfw/Input.Glfw.h>

// Plugin Management types
#include <NovelRT/PluginManagement/PluginManagement.h>
Expand Down
2 changes: 1 addition & 1 deletion include/NovelRT/PluginManagement/PluginManagement.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
#define NOVELRT_PLUGINMANAGEMENT_H

// PluginManagement Dependencies
#include "../Input/Input.h"
#include "../ResourceManagement/ResourceManagement.h"
#include "../Windowing/Windowing.h"
#include <NovelRT/Graphics/Graphics.hpp>
#include <NovelRT/Input/IInputDevice.hpp>

/**
* @brief The NovelRT engine plugin system for loading modules such as Vulkan, GLFW3, OpenAL, and more.
Expand Down
1 change: 1 addition & 0 deletions include/NovelRT/Utilities/Misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ namespace NovelRT::Utilities
static inline const char* CONSOLE_LOG_AUDIO = "Audio";
static inline const char* CONSOLE_LOG_INPUT = "Input";
static inline const char* CONSOLE_LOG_WINDOWING = "WindowManager";
static inline const char* CONSOLE_LOG_ECS_INPUT = "EcsInputSystem";

template<class T>
#ifdef NOVELRT_USE_STD_SPAN
Expand Down
17 changes: 17 additions & 0 deletions include/NovelRT/Windowing/Glfw/GlfwWindowingDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,23 @@ namespace NovelRT::Windowing::Glfw
{
class GlfwWindowingDevice final : public IWindowingDevice
{
public:
struct CursorPositionEventArgs
{
double x = 0;
double y = 0;
};

struct ButtonChangeEventArgs
{
int32_t key = 0;
int32_t action = 0;
};

Utilities::Event<CursorPositionEventArgs> CursorMoved;
Utilities::Event<ButtonChangeEventArgs> MouseButtonClicked;
Utilities::Event<ButtonChangeEventArgs> KeyboardButtonChanged;

private:
std::unique_ptr<GLFWwindow, decltype(&glfwDestroyWindow)> _window;
std::string _currentTitle;
Expand Down
67 changes: 67 additions & 0 deletions input/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
add_library(NovelRT-Input STATIC
KeyStateFrameChangeLog.cpp
NovelKey.cpp
Glfw/GlfwInputDevice.cpp
Glfw/GlfwInputPluginProvider.cpp
)

target_sources(NovelRT-Input
PUBLIC
FILE_SET public_headers
TYPE HEADERS
BASE_DIRS include
FILES
include/NovelRT/Input/IInputDevice.hpp
include/NovelRT/Input/InputAction.hpp
include/NovelRT/Input/KeyState.hpp
include/NovelRT/Input/KeyStateFrameChangeLog.hpp
include/NovelRT/Input/NovelKey.hpp
include/NovelRT/Input/Glfw/GlfwInputDevice.hpp
include/NovelRT/Input/Glfw/GlfwInputPluginProvider.hpp
)

set_target_properties(NovelRT-Input
PROPERTIES
EXPORT_NAME Input
POSITION_INDEPENDENT_CODE ON
)

target_compile_features(NovelRT-Input
PUBLIC
cxx_std_17
)

target_compile_options(NovelRT-Input
PRIVATE
$<$<CXX_COMPILER_ID:GNU>:-Wall>
$<$<CXX_COMPILER_ID:GNU>:-Wabi>
$<$<CXX_COMPILER_ID:GNU>:-Werror>
$<$<CXX_COMPILER_ID:GNU>:-Wextra>
$<$<CXX_COMPILER_ID:GNU>:-Wpedantic>
$<$<CXX_COMPILER_ID:GNU>:-pedantic-errors>

$<$<CXX_COMPILER_ID:Clang>:-Wall>
$<$<CXX_COMPILER_ID:Clang>:-Werror>
$<$<CXX_COMPILER_ID:Clang>:-Wextra>
$<$<CXX_COMPILER_ID:Clang>:-Wpedantic>
$<$<CXX_COMPILER_ID:Clang>:-pedantic-errors>

$<$<CXX_COMPILER_ID:MSVC>:/W4>
$<$<CXX_COMPILER_ID:MSVC>:/WX>
$<$<CXX_COMPILER_ID:MSVC>:/permissive->
)

target_include_directories(NovelRT-Input PRIVATE "$<TARGET_PROPERTY:Engine,INCLUDE_DIRECTORIES>")
target_link_libraries(NovelRT-Input
PUBLIC
spdlog
glfw
tbb
)

install(
TARGETS NovelRT-Input
EXPORT NovelRTConfig
LIBRARY DESTINATION lib
FILE_SET public_headers DESTINATION include
)
Loading
Loading