Added controller support
This commit is contained in:
parent
e5cc1565fd
commit
f4e6198a99
15 changed files with 310 additions and 6 deletions
9
src/gfx/Input.cpp
Normal file
9
src/gfx/Input.cpp
Normal file
|
@ -0,0 +1,9 @@
|
|||
#include "Window.hpp"
|
||||
#include "Input.hpp"
|
||||
|
||||
Window* Input::window = nullptr;
|
||||
|
||||
bool Input::IsKeyDown(int key)
|
||||
{
|
||||
return (glfwGetKey(window->GetNativeWindow(), key) == GLFW_PRESS);
|
||||
}
|
16
src/gfx/Input.hpp
Normal file
16
src/gfx/Input.hpp
Normal file
|
@ -0,0 +1,16 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
class Window;
|
||||
|
||||
class Input
|
||||
{
|
||||
public:
|
||||
static inline void SetWindow(Window* source) { window = source; }
|
||||
static bool IsKeyDown(int key);
|
||||
|
||||
private:
|
||||
static Window* window;
|
||||
};
|
|
@ -5,6 +5,8 @@
|
|||
#include <imgui/backends/imgui_impl_opengl3.h>
|
||||
#include <imgui/imgui.h>
|
||||
|
||||
#include "Input.hpp"
|
||||
|
||||
Window::Window(uint16_t width, uint16_t height, const std::string& title) :
|
||||
handle(nullptr)
|
||||
{
|
||||
|
@ -17,6 +19,7 @@ Window::Window(uint16_t width, uint16_t height, const std::string& title) :
|
|||
}
|
||||
|
||||
glfwMakeContextCurrent(handle);
|
||||
Input::SetWindow(this);
|
||||
}
|
||||
|
||||
Window::~Window()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue