L'adaptateur traduit clavier et manette en actions SEQUA (PlayerInput) ; le Core ne recoit et n'enregistre que ces actions, le rejeu reste exact. - SEQUA 3D : PlayerInput, poll_input(), capacite player_input (interface des adaptateurs en version 2) - protocole Core - rendu 0.2 : render/input, envoye quand les actions changent ; entree remise au neutre si le rendu disparait - Godot : InputMap du projet (ZQSD, fleches, espace, manette) ou script SequaInput.sequa_player_input() pour une correspondance avancee ; entree neutre sans focus ; exemple examples/sequa_input.gd - adaptateur debug : entrees scriptees par numero d'image - Studio : ligne "Entrees du joueur" du panneau Rendu
53 lines
1.8 KiB
C++
53 lines
1.8 KiB
C++
// SPDX-License-Identifier: MPL-2.0
|
|
#include "sequa/3d/input.hpp"
|
|
#include "sequa/3d/null_adapter.hpp"
|
|
|
|
#include <doctest/doctest.h>
|
|
|
|
#include <limits>
|
|
|
|
using namespace sequa::three_d;
|
|
|
|
TEST_CASE("quantize_axis : bornes, arrondi, valeurs non finies")
|
|
{
|
|
CHECK(quantize_axis(0.0) == 0);
|
|
CHECK(quantize_axis(1.0) == axis_max);
|
|
CHECK(quantize_axis(-1.0) == -axis_max);
|
|
CHECK(quantize_axis(0.5) == 16384); // 16383,5 arrondi au plus proche
|
|
CHECK(quantize_axis(-0.5) == -16384);
|
|
CHECK(quantize_axis(3.0) == axis_max);
|
|
CHECK(quantize_axis(-3.0) == -axis_max);
|
|
CHECK(quantize_axis(std::numeric_limits<double>::quiet_NaN()) == 0);
|
|
CHECK(quantize_axis(std::numeric_limits<double>::infinity()) == 0);
|
|
}
|
|
|
|
TEST_CASE("PlayerInput : neutre et egalite")
|
|
{
|
|
CHECK(PlayerInput{}.is_neutral());
|
|
CHECK_FALSE(PlayerInput{1, 0, 0}.is_neutral());
|
|
CHECK_FALSE(PlayerInput{0, 0, -5}.is_neutral());
|
|
CHECK(PlayerInput{1, 2, 3} == PlayerInput{1, 2, 3});
|
|
CHECK_FALSE(PlayerInput{1, 2, 3} == PlayerInput{1, 2, 4});
|
|
}
|
|
|
|
TEST_CASE("NullEngineAdapter : entrees seulement si declarees et demarre")
|
|
{
|
|
NullEngineAdapter silent;
|
|
EngineConfig config;
|
|
config.headless = true;
|
|
REQUIRE_FALSE(silent.start(config));
|
|
CHECK_FALSE(silent.poll_input().has_value()); // capacite non declaree
|
|
|
|
EngineCapabilities caps{"null", "0", BufferSet::all(), false, true, 0, 0};
|
|
caps.player_input = true;
|
|
NullEngineAdapter adapter(caps);
|
|
CHECK_FALSE(adapter.poll_input().has_value()); // pas encore demarre
|
|
REQUIRE_FALSE(adapter.start(config));
|
|
REQUIRE(adapter.poll_input().has_value());
|
|
CHECK(adapter.poll_input()->is_neutral());
|
|
adapter.set_input(PlayerInput{1, axis_max, 0});
|
|
CHECK(*adapter.poll_input() == PlayerInput{1, axis_max, 0});
|
|
adapter.stop();
|
|
CHECK_FALSE(adapter.poll_input().has_value());
|
|
}
|