From 0c535a1526d725fbd242c5ce348a7f2252d1fd34 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Wed, 16 Nov 2022 12:26:55 -0500 Subject: input bindings; mouse clear dialog box --- src/input.hpp | 60 ++++++++++++++++------------------------------------------- 1 file changed, 16 insertions(+), 44 deletions(-) (limited to 'src/input.hpp') diff --git a/src/input.hpp b/src/input.hpp index 8f7aa8f..3e666b2 100644 --- a/src/input.hpp +++ b/src/input.hpp @@ -2,7 +2,7 @@ * @file input.hpp * Handles user input received from SDL. * - * Copyright (C) 2019 Clyne Sullivan + * Copyright (C) 2022 Clyne Sullivan * * 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 @@ -21,51 +21,11 @@ #ifndef SYSTEM_INPUT_HPP_ #define SYSTEM_INPUT_HPP_ -#include -#include - -/** - * @class KeyUpEvent - * Stores info regarding key releases. - */ -struct KeyUpEvent -{ - SDL_Keycode sym; - Uint16 mod; +#include "events/input.hpp" - explicit KeyUpEvent(const SDL_Keysym& keysym) : - sym(keysym.sym), mod(keysym.mod) {} -}; - -/** - * @class KeyDownEvent - * Stores info regarding key presses. - */ -struct KeyDownEvent { - SDL_Keycode sym; - Uint16 mod; - - explicit KeyDownEvent(const SDL_Keysym& keysym) : - sym(keysym.sym), mod(keysym.mod) {} -}; - -struct MouseUpEvent { - Uint8 button; - Sint32 x; - Sint32 y; - - explicit MouseUpEvent(const SDL_MouseButtonEvent& mbe) : - button(mbe.button), x(mbe.x), y(mbe.y) {} -}; - -struct MouseDownEvent { - Uint8 button; - Sint32 x; - Sint32 y; +#include - explicit MouseDownEvent(const SDL_MouseButtonEvent& mbe) : - button(mbe.button), x(mbe.x), y(mbe.y) {} -}; +#include /** * @class InputSystem @@ -90,6 +50,18 @@ public: entityx::TimeDelta dt) final; private: + // TODO add 'mod' to comparison check + // TODO allow binding configuration + struct Binding { + SDL_Keycode sym = 0; + Uint16 mod = 0; + + auto operator<=>(const Binding& other) const { + return sym <=> other.sym; + } + }; + + std::map bindings; bool isMouseDown; }; -- cgit v1.2.3