// 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 . #pragma once #include #include 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 BOOL IsPointerDown(); STATIC Vec2 GetPointerPosition(); STATIC BOOL IsPointerDown(IN CONST Vec2& start, IN CONST Vec2& end); STATIC BOOL DidPointerClick(IN CONST Vec2& start, IN CONST Vec2& end); STATIC BOOL DidPointerClick(IN CONST Vec2& center, IN FLOAT32 radius); STATIC BOOL IsPointerDown(IN CONST Vec2& center, IN FLOAT32 radius); 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 BOOL s_pointerState; STATIC BOOL s_pointerPrevState; 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 Engine; friend class __Internal_Engine; }; } // namespace ia::iae