@ -0,0 +1,32 @@ | |||
/* | |||
* 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 <http://www.gnu.org/licenses/>. | |||
*/ | |||
#ifndef ANTKEEPER_INPUT_APPLICATION_EVENTS_HPP | |||
#define ANTKEEPER_INPUT_APPLICATION_EVENTS_HPP | |||
namespace input { | |||
/** | |||
* Event generated when the application has been requested to quit. | |||
*/ | |||
struct application_quit_event {}; | |||
} // namespace input | |||
#endif // ANTKEEPER_INPUT_APPLICATION_EVENTS_HPP |
@ -0,0 +1,59 @@ | |||
/* | |||
* 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 <http://www.gnu.org/licenses/>. | |||
*/ | |||
#ifndef ANTKEEPER_INPUT_CONTROL_EVENTS_HPP | |||
#define ANTKEEPER_INPUT_CONTROL_EVENTS_HPP | |||
namespace input { | |||
class control; | |||
/** | |||
* 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; | |||
}; | |||
} // namespace input | |||
#endif // ANTKEEPER_INPUT_CONTROL_EVENTS_HPP |
@ -0,0 +1,47 @@ | |||
/* | |||
* 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 <http://www.gnu.org/licenses/>. | |||
*/ | |||
#ifndef ANTKEEPER_INPUT_DEVICE_EVENTS_HPP | |||
#define ANTKEEPER_INPUT_DEVICE_EVENTS_HPP | |||
namespace input { | |||
class device; | |||
/** | |||
* 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; | |||
}; | |||
} // namespace input | |||
#endif // ANTKEEPER_INPUT_DEVICE_EVENTS_HPP |
@ -0,0 +1,71 @@ | |||
/* | |||
* 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 <http://www.gnu.org/licenses/>. | |||
*/ | |||
#ifndef ANTKEEPER_INPUT_GAMEPAD_EVENTS_HPP | |||
#define ANTKEEPER_INPUT_GAMEPAD_EVENTS_HPP | |||
#include "input/gamepad-axis.hpp" | |||
#include "input/gamepad-button.hpp" | |||
namespace input { | |||
class gamepad; | |||
/** | |||
* 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; | |||
}; | |||
} // namespace input | |||
#endif // ANTKEEPER_INPUT_GAMEPAD_EVENTS_HPP |
@ -1,238 +0,0 @@ | |||
/* | |||
* 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 <http://www.gnu.org/licenses/>. | |||
*/ | |||
#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 <cstdint> | |||
#include <memory> | |||
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> 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; | |||
/// Bit mask containing the active modifier keys. | |||
std::uint16_t modifiers; | |||
/// `true` if the key press was generated by a key repeat, `false` otherwise. | |||
bool repeat; | |||
}; | |||
/** | |||
* 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; | |||
/// 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<std::int32_t, 2> position; | |||
/// Relative movement of the mouse, in pixels. | |||
math::vector<std::int32_t, 2> 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<std::int32_t, 2> 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<std::int32_t, 2> 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<std::int32_t, 2> position; | |||
/// Scroll velocity. | |||
math::vector<float, 2> velocity; | |||
}; | |||
/** | |||
* Event generated when the application has been requested to quit. | |||
*/ | |||
struct application_quit_event {}; | |||
} // namespace input | |||
#endif // ANTKEEPER_INPUT_INPUT_EVENTS_HPP |
@ -0,0 +1,28 @@ | |||
/* | |||
* 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 <http://www.gnu.org/licenses/>. | |||
*/ | |||
#ifndef ANTKEEPER_INPUT_HPP | |||
#define ANTKEEPER_INPUT_HPP | |||
/** | |||
* Input devices, events, and mapping. | |||
*/ | |||
namespace input {} | |||
#endif // ANTKEEPER_INPUT_HPP |
@ -0,0 +1,66 @@ | |||
/* | |||
* 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 <http://www.gnu.org/licenses/>. | |||
*/ | |||
#ifndef ANTKEEPER_INPUT_KEYBOARD_EVENTS_HPP | |||
#define ANTKEEPER_INPUT_KEYBOARD_EVENTS_HPP | |||
#include "input/scancode.hpp" | |||
#include "input/modifier-key.hpp" | |||
#include <cstdint> | |||
namespace input { | |||
class keyboard; | |||
/** | |||
* 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; | |||
/// Bit mask containing the active modifier keys. | |||
std::uint16_t modifiers; | |||
/// `true` if the key press was generated by a key repeat, `false` otherwise. | |||
bool repeat; | |||
}; | |||
/** | |||
* 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; | |||
/// Bit mask containing the active modifier keys. | |||
std::uint16_t modifiers; | |||
}; | |||
} // namespace input | |||
#endif // ANTKEEPER_INPUT_KEYBOARD_EVENTS_HPP |
@ -0,0 +1,83 @@ | |||
/* | |||
* 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 <http://www.gnu.org/licenses/>. | |||
*/ | |||
#ifndef ANTKEEPER_INPUT_MAPPING_EVENTS_HPP | |||
#define ANTKEEPER_INPUT_MAPPING_EVENTS_HPP | |||
#include "input/mapping.hpp" | |||
namespace input { | |||
/** | |||
* Event generated when a gamepad axis mapping has been generated. | |||
*/ | |||
struct gamepad_axis_mapped_event | |||
{ | |||
/// Gamepad axis mapping that was generated. | |||
gamepad_axis_mapping mapping; | |||
}; | |||
/** | |||
* Event generated when a gamepad button mapping has been generated. | |||
*/ | |||
struct gamepad_button_mapped_event | |||
{ | |||
/// Gamepad button mapping that was generated. | |||
gamepad_button_mapping mapping; | |||
}; | |||
/** | |||
* Event generated when a key mapping has been generated. | |||
*/ | |||
struct key_mapped_event | |||
{ | |||
/// Key mapping that was generated. | |||
key_mapping mapping; | |||
}; | |||
/** | |||
* Event generated when a mouse button mapping has been generated. | |||
*/ | |||
struct mouse_button_mapped_event | |||
{ | |||
/// Mouse button mapping that was generated. | |||
mouse_button_mapping mapping; | |||
}; | |||
/** | |||
* Event generated when a mouse motion mapping has been generated. | |||
*/ | |||
struct mouse_motion_mapped_event | |||
{ | |||
/// Mouse motion mapping that was generated. | |||
mouse_motion_mapping mapping; | |||
}; | |||
/** | |||
* Event generated when a mouse scroll mapping has been generated. | |||
*/ | |||
struct mouse_scroll_mapped_event | |||
{ | |||
/// Mouse scroll mapping that was generated. | |||
mouse_scroll_mapping mapping; | |||
}; | |||
} // namespace input | |||
#endif // ANTKEEPER_INPUT_MAPPING_EVENTS_HPP |
@ -0,0 +1,95 @@ | |||
/* | |||
* 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 <http://www.gnu.org/licenses/>. | |||
*/ | |||
#ifndef ANTKEEPER_INPUT_MOUSE_EVENTS_HPP | |||
#define ANTKEEPER_INPUT_MOUSE_EVENTS_HPP | |||
#include "input/mouse-button.hpp" | |||
#include "input/mouse-motion-axis.hpp" | |||
#include "input/mouse-scroll-axis.hpp" | |||
#include "math/vector.hpp" | |||
#include <cstdint> | |||
namespace input { | |||
class mouse; | |||
/** | |||
* 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<std::int32_t, 2> position; | |||
/// Relative movement of the mouse, in pixels. | |||
math::vector<std::int32_t, 2> 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<std::int32_t, 2> 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<std::int32_t, 2> 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<std::int32_t, 2> position; | |||
/// Scroll velocity. | |||
math::vector<float, 2> velocity; | |||
}; | |||
} // namespace input | |||
#endif // ANTKEEPER_INPUT_MOUSE_EVENTS_HPP |