Fixing gamepad controls

This commit is contained in:
Zoe Roux
2021-06-19 15:25:20 +02:00
parent a9bf6d3192
commit 4bc5b54a2e
2 changed files with 4 additions and 2 deletions
+3 -1
View File
@@ -17,7 +17,7 @@ namespace BBM
: System(wal)
{}
void GamepadSystem::onFixedUpdate(WAL::ViewEntity<GamepadComponent, ControllableComponent> &entity)
void GamepadSystem::onUpdate(WAL::ViewEntity<GamepadComponent, ControllableComponent> &entity, std::chrono::nanoseconds)
{
const auto &gamepadComponent = entity.get<GamepadComponent>();
auto &controllable = entity.get<ControllableComponent>();
@@ -34,6 +34,8 @@ namespace BBM
for (auto key : keyPressedMap)
key.second = controllable.fastClick ? gamepad.isDown(key.first) : gamepad.isPressed(key.first);
if (gamepad.isPressed(GAMEPAD_BUTTON_MIDDLE_LEFT) || gamepad.isPressed(GAMEPAD_BUTTON_MIDDLE_RIGHT))
controllable.pause = true;
controllable.move.x = gamepad.getAxisValue(gamepadComponent.LeftStickX) * -1;
controllable.move.y = gamepad.getAxisValue(gamepadComponent.LeftStickY) * -1;
controllable.move.x -= static_cast<float>(gamepad.isDown(gamepadComponent.keyRight));
+1 -1
View File
@@ -16,7 +16,7 @@ namespace BBM
{
public:
//! @inherit
void onFixedUpdate(WAL::ViewEntity<GamepadComponent, ControllableComponent> &entity) override;
void onUpdate(WAL::ViewEntity<GamepadComponent, ControllableComponent> &entity, std::chrono::nanoseconds) override;
//! @brief A default constructor
explicit GamepadSystem(WAL::Wal &wal);