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
49 lines
1.6 KiB
C++
49 lines
1.6 KiB
C++
// SPDX-License-Identifier: MPL-2.0
|
|
#include "sequa/godot/input_mapping.hpp"
|
|
|
|
#include <doctest/doctest.h>
|
|
|
|
#include <limits>
|
|
|
|
using namespace sequa::godot;
|
|
using sequa::three_d::axis_max;
|
|
using sequa::three_d::PlayerInput;
|
|
|
|
TEST_CASE("Godot : noms des actions de boutons")
|
|
{
|
|
CHECK(button_action_name(0) == "sequa_jump");
|
|
CHECK(button_action_name(1) == "sequa_button_1");
|
|
CHECK(button_action_name(31) == "sequa_button_31");
|
|
}
|
|
|
|
TEST_CASE("Godot : niveau 1, forces des actions vers PlayerInput")
|
|
{
|
|
CHECK(map_actions({}).is_neutral());
|
|
|
|
ActionStrengths right;
|
|
right.right = 1.0;
|
|
CHECK(map_actions(right) == PlayerInput{0, axis_max, 0});
|
|
|
|
ActionStrengths both; // gauche et droite ensemble s'annulent
|
|
both.left = 1.0;
|
|
both.right = 1.0;
|
|
CHECK(map_actions(both).move_x == 0);
|
|
|
|
ActionStrengths analog; // manette a mi-course vers le bas, saut presse
|
|
analog.down = 0.5;
|
|
analog.buttons = 1;
|
|
CHECK(map_actions(analog) == PlayerInput{1, 0, -16384});
|
|
}
|
|
|
|
TEST_CASE("Godot : niveau 2, resultat du script")
|
|
{
|
|
CHECK(map_script_result(0, 0.0, 0.0) == PlayerInput{});
|
|
CHECK(map_script_result(0xFFFFFFFFLL, -1.0, 1.0) == PlayerInput{0xFFFFFFFFu, -axis_max, axis_max});
|
|
CHECK(map_script_result(5, 2.0, -7.0) == PlayerInput{5, axis_max, -axis_max}); // axes bornes
|
|
|
|
CHECK_FALSE(map_script_result(-1, 0.0, 0.0).has_value());
|
|
CHECK_FALSE(map_script_result(0x100000000LL, 0.0, 0.0).has_value());
|
|
CHECK_FALSE(map_script_result(0, std::numeric_limits<double>::quiet_NaN(), 0.0).has_value());
|
|
CHECK_FALSE(map_script_result(0, 0.0, std::numeric_limits<double>::infinity()).has_value());
|
|
}
|