Skip to content

feat(core): input plugin#26

Merged
Miou-zora merged 13 commits into
mainfrom
15-input-plugin
Oct 15, 2024
Merged

feat(core): input plugin#26
Miou-zora merged 13 commits into
mainfrom
15-input-plugin

Conversation

@ripel2
Copy link
Copy Markdown
Contributor

@ripel2 ripel2 commented Oct 13, 2024

Related to:

I've implemented a very simple wrapper for GLFW GetKey function.
I also had to implement window handling in this issue to allow the usage of GLFW functions

No unit tests because it is (almost) impossible to test this kind of stuff

(see below for test main)

@ripel2 ripel2 added the enhancement New feature or request label Oct 13, 2024
@ripel2 ripel2 requested a review from a team October 13, 2024 13:55
@ripel2 ripel2 self-assigned this Oct 13, 2024
@ripel2 ripel2 linked an issue Oct 13, 2024 that may be closed by this pull request
@ripel2
Copy link
Copy Markdown
Contributor Author

ripel2 commented Oct 13, 2024

Test main function:

#include <GLFW/glfw3.h>
#include <iostream>
#include "Registry.hpp"
#include "window/resource/Window.hpp"
#include "input/resource/InputManager.hpp"

int main()
{
    ES::Engine::Registry registry;

    registry.RegisterResource<ES::Plugin::Window::Resource::Window>({800, 600, "GLFW Window"});
    registry.RegisterResource<ES::Plugin::Input::Resource::InputManager>({});

    ES::Plugin::Window::Resource::Window &window = registry.GetResource<ES::Plugin::Window::Resource::Window>();
    ES::Plugin::Input::Resource::InputManager &inputManager = registry.GetResource<ES::Plugin::Input::Resource::InputManager>();

    window.Create();

    while (window.ShouldClose() == false)
    {
        glfwPollEvents();
        glfwSwapBuffers(window.GetGLFWWindow());

        if (inputManager.IsKeyPressed(GLFW_KEY_Z))
        {
            std::cout << "Z key pressed" << std::endl;
        }

        if (inputManager.IsMouseButtonPressed(GLFW_MOUSE_BUTTON_LEFT))
        {
            std::pair<double, double> mousePos = inputManager.GetMousePosition();
            std::cout << "mouse pos: " << mousePos.first << ", " << mousePos.second << std::endl;
        }
    }

    return 0;
}

@ripel2 ripel2 marked this pull request as ready for review October 13, 2024 14:00
Comment thread src/plugin/input/resource/InputManager.hpp Outdated
Comment thread src/plugin/window/resource/Window.hpp Outdated
Comment thread src/plugin/window/resource/Window.hpp Outdated
Comment thread src/plugin/window/resource/Window.hpp Outdated
Comment thread src/plugin/window/resource/Window.hpp Outdated
@ripel2 ripel2 requested a review from Miou-zora October 15, 2024 08:19
@Miou-zora Miou-zora merged commit 390d73c into main Oct 15, 2024
@Miou-zora Miou-zora deleted the 15-input-plugin branch October 15, 2024 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Input Plugin

2 participants