/* * Copyright (C) 2023 Christopher J. Howard * * This file is part of Antkeeper source code. * * Antkeeper source code 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. * * Antkeeper source code 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 Antkeeper source code. If not, see . */ #ifndef ANTKEEPER_INPUT_INPUT_EVENTS_HPP #define ANTKEEPER_INPUT_INPUT_EVENTS_HPP #include "input/gamepad-axis.hpp" #include "input/gamepad-button.hpp" #include "input/mouse-motion-axis.hpp" #include "input/mouse-scroll-axis.hpp" #include "input/scancode.hpp" #include "input/mapping.hpp" #include "input/modifier-key.hpp" #include "math/vector.hpp" #include #include namespace input { class control; class device; class gamepad; class keyboard; class mouse; /** * Event generated when a control has been activated. */ struct control_activated_event { /// Control that was activated. control* control; }; /** * Event generated while a control is active. */ struct control_active_event { /// Active control. control* control; /// Control input value. float input_value; }; /** * Event generated when a control has been deactivated. */ struct control_deactivated_event { /// Control that was deactivated. control* control; }; /** * Event generated when an input mapping has been generated. */ struct input_mapped_event { /// Input mapping that was generated. std::shared_ptr mapping; }; /** * Event generated when an input device has been connected. */ struct device_connected_event { /// Device that was connected. device* device; }; /** * Event generated when an input device has been disconnected. */ struct device_disconnected_event { /// Device that was disconnected. device* device; }; /** * Event generated when a gamepad button has been pressed. */ struct gamepad_button_pressed_event { /// Gamepad that generated the event. gamepad* gamepad; /// Gamepad button being pressed. gamepad_button button; }; /** * Event generated when a gamepad button has been released. */ struct gamepad_button_released_event { /// Gamepad that generated the event. gamepad* gamepad; /// Gamepad button being released. gamepad_button button; }; /** * Event generated when a gamepad axis has been moved. */ struct gamepad_axis_moved_event { /// Gamepad that generated the event. gamepad* gamepad; /// Gamepad axis being moved. gamepad_axis axis; /// Position of the gamepad axis, on `[-1, 1]`. float position; }; /** * Event generated when a keyboard key has been pressed. */ struct key_pressed_event { /// Keyboard that generated the event. keyboard* keyboard; /// Scancode of the key being pressed. scancode scancode; /// `true` if the key press was generated by a key repeat, `false` otherwise. bool repeat; /// Bit mask containing the active modifier keys. std::uint16_t modifiers; }; /** * Event generated when a keyboard key has been released. */ struct key_released_event { /// Keyboard that generated the event. keyboard* keyboard; /// Scancode of the key being released. scancode scancode; /// `true` if the key release was generated by a key repeat, `false` otherwise. bool repeat; /// Bit mask containing the active modifier keys. std::uint16_t modifiers; }; /** * Event generated when a mouse has been moved. */ struct mouse_moved_event { /// Mouse that generated the event. mouse* mouse; /// Mouse position, in pixels, relative to the window. math::vector position; /// Relative movement of the mouse, in pixels. math::vector difference; }; /** * Event generated when a mouse button has been pressed. */ struct mouse_button_pressed_event { /// Mouse that generated the event. mouse* mouse; /// Mouse position, in pixels, relative to the window, when the button was pressed. math::vector position; /// Mouse button being pressed. mouse_button button; }; /** * Event generated when a mouse button has been released. */ struct mouse_button_released_event { /// Mouse that generated the event. mouse* mouse; /// Mouse position, in pixels, relative to the window, when the button was released. math::vector position; /// Mouse button being released. mouse_button button; }; /** * Event generated when a mouse has been scrolled. */ struct mouse_scrolled_event { /// Mouse that generated the event. mouse* mouse; /// Mouse position, in pixels, relative to the window, when the mouse was scrolled. math::vector position; /// Scroll velocity. math::vector velocity; }; /** * Event generated when the application has been requested to quit. */ struct application_quit_event {}; } // namespace input #endif // ANTKEEPER_INPUT_INPUT_EVENTS_HPP