Skip to content

Commit

Permalink
feat(input): finish virtual input
Browse files Browse the repository at this point in the history
  • Loading branch information
Milerius committed Oct 31, 2019
1 parent 7580958 commit 59ba90f
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 2 deletions.
5 changes: 3 additions & 2 deletions modules/ecs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ add_library(antara_ecs_shared_sources STATIC)
target_sources(antara_ecs_shared_sources PRIVATE
antara/gaming/ecs/base.system.cpp
antara/gaming/ecs/system.manager.cpp
antara/gaming/ecs/event.add.base.system.cpp)
antara/gaming/ecs/event.add.base.system.cpp
antara/gaming/ecs/virtual.input.system.cpp)
target_include_directories(antara_ecs_shared_sources PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(antara_ecs_shared_sources PUBLIC antara::core antara::math antara::transform antara::geometry antara::graphics EnTT strong_type expected range-v3 antara::default_settings antara::timer antara::event doom::meta)
target_link_libraries(antara_ecs_shared_sources PUBLIC antara::core antara::input antara::math antara::transform antara::geometry antara::graphics EnTT strong_type expected range-v3 antara::default_settings antara::timer antara::event doom::meta)
add_library(antara::ecs ALIAS antara_ecs_shared_sources)

if (ANTARA_BUILD_UNIT_TESTS)
Expand Down
9 changes: 9 additions & 0 deletions modules/ecs/antara/gaming/ecs/antara.ecs.system.tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "antara/gaming/core/safe.refl.hpp"
#include "antara/gaming/ecs/base.system.hpp"
#include "antara/gaming/ecs/system.hpp"
#include "antara/gaming/ecs/virtual.input.system.hpp"

namespace antara::gaming::ecs::tests
{
Expand Down Expand Up @@ -209,6 +210,14 @@ namespace antara::gaming::ecs::tests
}
}
}

TEST_CASE("virtual input")
{
entt::registry registry;
registry.set<entt::dispatcher>();
ecs::virtual_input_system system{registry};
system.update();
}
}

REFL_AUTO(type(antara::gaming::ecs::tests::logic_concrete_system))
Expand Down
27 changes: 27 additions & 0 deletions modules/ecs/antara/gaming/ecs/virtual.input.system.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/******************************************************************************
* Copyright © 2013-2019 The Komodo Platform Developers. *
* *
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at *
* the top-level directory of this distribution for the individual copyright *
* holder information and the developer policies on copyright and licensing. *
* *
* Unless otherwise agreed in a custom licensing agreement, no part of the *
* Komodo Platform software, including this file may be copied, modified, *
* propagated or distributed except according to the terms contained in the *
* LICENSE file *
* *
* Removal or modification of this copyright notice is prohibited. *
* *
******************************************************************************/

#include <antara/gaming/ecs/virtual.input.system.hpp>

namespace antara::gaming::ecs {
virtual_input_system::virtual_input_system(entt::registry &registry) noexcept : system(registry) {
input::virtual_input::init(registry);
}

void virtual_input_system::update() noexcept {
input::virtual_input::update();
}
}
31 changes: 31 additions & 0 deletions modules/ecs/antara/gaming/ecs/virtual.input.system.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/******************************************************************************
* Copyright © 2013-2019 The Komodo Platform Developers. *
* *
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at *
* the top-level directory of this distribution for the individual copyright *
* holder information and the developer policies on copyright and licensing. *
* *
* Unless otherwise agreed in a custom licensing agreement, no part of the *
* Komodo Platform software, including this file may be copied, modified, *
* propagated or distributed except according to the terms contained in the *
* LICENSE file *
* *
* Removal or modification of this copyright notice is prohibited. *
* *
******************************************************************************/

#pragma once

#include <antara/gaming/core/safe.refl.hpp>
#include <antara/gaming/input/virtual.hpp>
#include <antara/gaming/ecs/system.hpp>

namespace antara::gaming::ecs {
struct virtual_input_system final : ecs::logic_update_system<virtual_input_system> {
virtual_input_system(entt::registry &registry) noexcept;

void update() noexcept final;
};
}

REFL_AUTO (type(antara::gaming::ecs::virtual_input_system));
2 changes: 2 additions & 0 deletions modules/input/antara/gaming/input/virtual.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include "antara/gaming/input/virtual.hpp"

namespace antara::gaming::input {
input::virtual_input::input_state_collection input::virtual_input::cached_states_ = {};

void virtual_input::init(entt::registry &registry) noexcept {
entt::dispatcher &dispatcher = registry.ctx<entt::dispatcher>();
dispatcher.sink<event::key_pressed>().connect<&virtual_input::on_key_pressed>();
Expand Down

0 comments on commit 59ba90f

Please sign in to comment.