93 lines
2.9 KiB
C++
93 lines
2.9 KiB
C++
// IAEngine: 2D Game Engine by IA
|
|
// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
#pragma once
|
|
|
|
#include <IAEngine/Base.hpp>
|
|
|
|
#include <SDL3/SDL.h>
|
|
|
|
namespace ia::iae
|
|
{
|
|
class InputManager
|
|
{
|
|
public:
|
|
struct KeyboardGamePadMapping
|
|
{
|
|
IN InputKey AxisLeft;
|
|
IN InputKey AxisRight;
|
|
IN InputKey AxisDown;
|
|
IN InputKey AxisUp;
|
|
IN InputKey ButtonA;
|
|
IN InputKey ButtonB;
|
|
IN InputKey ButtonC;
|
|
IN InputKey ButtonD;
|
|
};
|
|
|
|
public:
|
|
STATIC VOID SwitchModeToText();
|
|
STATIC VOID SwitchModeToAction();
|
|
|
|
STATIC Vec2 GetPointerPosition();
|
|
|
|
STATIC BOOL IsKeyDown(IN InputKey key);
|
|
STATIC BOOL WasKeyPressed(IN InputKey key);
|
|
STATIC BOOL WasKeyReleased(IN InputKey key);
|
|
|
|
STATIC VOID SetupOnScreenGamePad();
|
|
STATIC VOID SetupKeyboardGamePad(IN CONST KeyboardGamePadMapping& mapping);
|
|
|
|
STATIC BOOL GetButtonA();
|
|
STATIC BOOL GetButtonB();
|
|
STATIC BOOL GetButtonC();
|
|
STATIC BOOL GetButtonD();
|
|
STATIC INT16 GetVerticalAxis();
|
|
STATIC INT16 GetHorizontalAxis();
|
|
STATIC IVec2 GetDirectionalInput();
|
|
|
|
STATIC VOID SetButtonA(IN BOOL value);
|
|
STATIC VOID SetButtonB(IN BOOL value);
|
|
STATIC VOID SetButtonC(IN BOOL value);
|
|
STATIC VOID SetButtonD(IN BOOL value);
|
|
STATIC VOID SetVerticalAxis(IN INT16 value);
|
|
STATIC VOID SetHorizontalAxis(IN INT16 value);
|
|
|
|
private:
|
|
STATIC BOOL s_buttonA;
|
|
STATIC BOOL s_buttonB;
|
|
STATIC BOOL s_buttonC;
|
|
STATIC BOOL s_buttonD;
|
|
STATIC INT16 s_verticalAxis;
|
|
STATIC INT16 s_horizontalAxis;
|
|
STATIC BOOL s_keys[256];
|
|
STATIC BOOL s_prevKeys[256];
|
|
STATIC Vec2 s_pointerPosition;
|
|
STATIC BOOL s_onScreenGamePadEnabled;
|
|
STATIC BOOL s_keyboardGamePadEnabled;
|
|
STATIC KeyboardGamePadMapping s_keyboardGamePadMapping;
|
|
|
|
private:
|
|
STATIC VOID Initialize();
|
|
STATIC VOID Terminate();
|
|
|
|
STATIC VOID Draw();
|
|
STATIC VOID Update();
|
|
|
|
STATIC VOID OnSDLEvent(IN SDL_Event *event);
|
|
|
|
friend class __Internal_Engine;
|
|
};
|
|
} // namespace ia::iae
|