fixed input with keyboard and controller at the same time

This commit is contained in:
Sarah Faey 2025-04-18 15:47:07 +02:00
parent d8fa53801b
commit eabeb55115
11 changed files with 95 additions and 68 deletions

View file

@ -7,6 +7,7 @@
#include "GameCommands/GameCommand.h"
#include "GameCommands/AxisCommand.h"
#include "Actors/MovingActor.h"
#include "DataStructures/DirectionButtonStatus.h"
class Game
{
@ -25,7 +26,6 @@ private:
const float c_GamepadAxisDeadzone = 0.2; //TODO: make this a setting?
bool m_running = true;
bool m_ButtonInput = true;
uint64_t m_TickCount;
std::map<SDL_Scancode, GameCommand*> m_KeyboardCommandMap;
std::map<SDL_GamepadButton, GameCommand*> m_Gamepad1ButtonCommandMap;
@ -37,7 +37,8 @@ private:
std::shared_ptr<MovingActor> m_Player2;
SDL_FPoint m_Player1DirectionInput;
SDL_FPoint m_Player2DirectionInput;
const float c_NormalizedDiagonal = 1 / sqrt(2);
DirectionButtonStatus m_Player1DirectionButtonStatus;
DirectionButtonStatus m_Player2DirectionButtonStatus;
std::unique_ptr<SDL_Window, decltype(&SDL_DestroyWindow)> m_Window;
std::unique_ptr<SDL_Renderer, decltype(&SDL_DestroyRenderer)> m_Renderer;