diff --git a/src/app/sdl/sdl-input-manager.cpp b/src/app/sdl/sdl-input-manager.cpp index 08e0868..90215af 100644 --- a/src/app/sdl/sdl-input-manager.cpp +++ b/src/app/sdl/sdl-input-manager.cpp @@ -86,7 +86,7 @@ void sdl_input_manager::update() { case SDL_QUIT: debug::log::debug("Application quit requested"); - this->event_queue.enqueue({}); + this->event_queue.enqueue({}); break; default: diff --git a/src/game/context.hpp b/src/game/context.hpp index 48f6500..4b3c0c9 100644 --- a/src/game/context.hpp +++ b/src/game/context.hpp @@ -134,6 +134,14 @@ struct context // Resource management and paths resource_manager* resource_manager; + std::filesystem::path data_path; + std::filesystem::path local_config_path; + std::filesystem::path shared_config_path; + std::filesystem::path mods_path; + std::filesystem::path saves_path; + std::filesystem::path screenshots_path; + std::filesystem::path controls_path; + std::filesystem::path data_package_path; // Persistent settings dict* settings; @@ -199,16 +207,6 @@ struct context /// Game loop game::loop loop; - // Paths - std::filesystem::path data_path; - std::filesystem::path local_config_path; - std::filesystem::path shared_config_path; - std::filesystem::path mods_path; - std::filesystem::path saves_path; - std::filesystem::path screenshots_path; - std::filesystem::path controls_path; - std::filesystem::path data_package_path; - // Framebuffers gl::texture_2d* hdr_color_texture; gl::texture_2d* hdr_depth_texture; diff --git a/src/game/state/boot.cpp b/src/game/state/boot.cpp index 3cefa66..30a2f59 100644 --- a/src/game/state/boot.cpp +++ b/src/game/state/boot.cpp @@ -187,7 +187,7 @@ void boot::parse_options(int argc, char** argv) ("n,new-game", "Starts a new game") ("q,quick-start", "Skips to the main menu") ("r,reset", "Resets all settings to default") - ("v,vsync", "Enables or disables v-sync", cxxopts::value()) + ("v,v-sync", "Enables or disables v-sync", cxxopts::value()) ("w,windowed", "Starts in windowed mode"); auto result = options.parse(argc, argv); @@ -227,10 +227,10 @@ void boot::parse_options(int argc, char** argv) ctx.option_reset = true; } - // --v_sync - if (result.count("vsync")) + // --v-sync + if (result.count("v-sync")) { - ctx.option_v_sync = result["vsync"].as(); + ctx.option_v_sync = result["v-sync"].as(); } // --window @@ -249,7 +249,7 @@ void boot::parse_options(int argc, char** argv) void boot::setup_resources() { - // Setup resource manager + // Allocate resource manager ctx.resource_manager = new resource_manager(); // Detect paths @@ -312,9 +312,12 @@ void boot::setup_resources() // Determine data package path if (ctx.option_data) { - ctx.data_package_path = std::filesystem::path(ctx.option_data.value()); + // Handle command-line data package path option + ctx.data_package_path = ctx.option_data.value(); if (ctx.data_package_path.is_relative()) + { ctx.data_package_path = ctx.data_path / ctx.data_package_path; + } } else { @@ -450,7 +453,7 @@ void boot::setup_input() ctx.input_manager = app::input_manager::instance(); // Setup application quit callback - ctx.application_quit_subscription = ctx.input_manager->get_event_queue().subscribe + ctx.application_quit_subscription = ctx.input_manager->get_event_queue().subscribe ( [&](const auto& event) { diff --git a/src/input/control-map.cpp b/src/input/control-map.cpp index 74d955d..246df80 100644 --- a/src/input/control-map.cpp +++ b/src/input/control-map.cpp @@ -27,15 +27,15 @@ namespace input { void control_map::connect(::event::queue& queue) { - subscriptions.emplace_back(queue.subscribe(std::bind_front(&control_map::handle_gamepad_axis_moved, this))); - subscriptions.emplace_back(queue.subscribe(std::bind_front(&control_map::handle_gamepad_button_pressed, this))); - subscriptions.emplace_back(queue.subscribe(std::bind_front(&control_map::handle_gamepad_button_released, this))); - subscriptions.emplace_back(queue.subscribe(std::bind_front(&control_map::handle_key_pressed, this))); - subscriptions.emplace_back(queue.subscribe(std::bind_front(&control_map::handle_key_released, this))); - subscriptions.emplace_back(queue.subscribe(std::bind_front(&control_map::handle_mouse_button_pressed, this))); - subscriptions.emplace_back(queue.subscribe(std::bind_front(&control_map::handle_mouse_button_released, this))); - subscriptions.emplace_back(queue.subscribe(std::bind_front(&control_map::handle_mouse_moved, this))); - subscriptions.emplace_back(queue.subscribe(std::bind_front(&control_map::handle_mouse_scrolled, this))); + subscriptions.emplace_back(queue.subscribe(std::bind_front(&control_map::handle_gamepad_axis_moved, this))); + subscriptions.emplace_back(queue.subscribe(std::bind_front(&control_map::handle_gamepad_button_pressed, this))); + subscriptions.emplace_back(queue.subscribe(std::bind_front(&control_map::handle_gamepad_button_released, this))); + subscriptions.emplace_back(queue.subscribe(std::bind_front(&control_map::handle_key_pressed, this))); + subscriptions.emplace_back(queue.subscribe(std::bind_front(&control_map::handle_key_released, this))); + subscriptions.emplace_back(queue.subscribe(std::bind_front(&control_map::handle_mouse_button_pressed, this))); + subscriptions.emplace_back(queue.subscribe(std::bind_front(&control_map::handle_mouse_button_released, this))); + subscriptions.emplace_back(queue.subscribe(std::bind_front(&control_map::handle_mouse_moved, this))); + subscriptions.emplace_back(queue.subscribe(std::bind_front(&control_map::handle_mouse_scrolled, this))); } void control_map::disconnect() @@ -171,7 +171,7 @@ void control_map::remove_mappings() mouse_scroll_mappings.clear(); } -void control_map::handle_gamepad_axis_moved(const event::gamepad_axis_moved& event) +void control_map::handle_gamepad_axis_moved(const gamepad_axis_moved_event& event) { for (const auto& [control, mapping]: gamepad_axis_mappings) { @@ -190,7 +190,7 @@ void control_map::handle_gamepad_axis_moved(const event::gamepad_axis_moved& eve } } -void control_map::handle_gamepad_button_pressed(const event::gamepad_button_pressed& event) +void control_map::handle_gamepad_button_pressed(const gamepad_button_pressed_event& event) { for (const auto& [control, mapping]: gamepad_button_mappings) { @@ -202,7 +202,7 @@ void control_map::handle_gamepad_button_pressed(const event::gamepad_button_pres } } -void control_map::handle_gamepad_button_released(const event::gamepad_button_released& event) +void control_map::handle_gamepad_button_released(const gamepad_button_released_event& event) { for (const auto& [control, mapping]: gamepad_button_mappings) { @@ -214,7 +214,7 @@ void control_map::handle_gamepad_button_released(const event::gamepad_button_rel } } -void control_map::handle_key_pressed(const event::key_pressed& event) +void control_map::handle_key_pressed(const key_pressed_event& event) { for (const auto& [control, mapping]: key_mappings) { @@ -226,7 +226,7 @@ void control_map::handle_key_pressed(const event::key_pressed& event) } } -void control_map::handle_key_released(const event::key_released& event) +void control_map::handle_key_released(const key_released_event& event) { for (const auto& [control, mapping]: key_mappings) { @@ -238,7 +238,7 @@ void control_map::handle_key_released(const event::key_released& event) } } -void control_map::handle_mouse_moved(const event::mouse_moved& event) +void control_map::handle_mouse_moved(const mouse_moved_event& event) { for (const auto& [control, mapping]: mouse_motion_mappings) { @@ -255,7 +255,7 @@ void control_map::handle_mouse_moved(const event::mouse_moved& event) } } -void control_map::handle_mouse_scrolled(const event::mouse_scrolled& event) +void control_map::handle_mouse_scrolled(const mouse_scrolled_event& event) { for (const auto& [control, mapping]: mouse_scroll_mappings) { @@ -272,7 +272,7 @@ void control_map::handle_mouse_scrolled(const event::mouse_scrolled& event) } } -void control_map::handle_mouse_button_pressed(const event::mouse_button_pressed& event) +void control_map::handle_mouse_button_pressed(const mouse_button_pressed_event& event) { for (const auto& [control, mapping]: mouse_button_mappings) { @@ -284,7 +284,7 @@ void control_map::handle_mouse_button_pressed(const event::mouse_button_pressed& } } -void control_map::handle_mouse_button_released(const event::mouse_button_released& event) +void control_map::handle_mouse_button_released(const mouse_button_released_event& event) { for (const auto& [control, mapping]: mouse_button_mappings) { diff --git a/src/input/control-map.hpp b/src/input/control-map.hpp index a887225..85c4863 100644 --- a/src/input/control-map.hpp +++ b/src/input/control-map.hpp @@ -23,7 +23,7 @@ #include "event/subscription.hpp" #include "event/queue.hpp" #include "input/control.hpp" -#include "input/event.hpp" +#include "input/input-events.hpp" #include "input/mapping.hpp" #include #include @@ -87,15 +87,15 @@ public: void remove_mappings(); private: - void handle_gamepad_axis_moved(const event::gamepad_axis_moved& event); - void handle_gamepad_button_pressed(const event::gamepad_button_pressed& event); - void handle_gamepad_button_released(const event::gamepad_button_released& event); - void handle_key_pressed(const event::key_pressed& event); - void handle_key_released(const event::key_released& event); - void handle_mouse_button_pressed(const event::mouse_button_pressed& event); - void handle_mouse_button_released(const event::mouse_button_released& event); - void handle_mouse_moved(const event::mouse_moved& event); - void handle_mouse_scrolled(const event::mouse_scrolled& event); + void handle_gamepad_axis_moved(const gamepad_axis_moved_event& event); + void handle_gamepad_button_pressed(const gamepad_button_pressed_event& event); + void handle_gamepad_button_released(const gamepad_button_released_event& event); + void handle_key_pressed(const key_pressed_event& event); + void handle_key_released(const key_released_event& event); + void handle_mouse_button_pressed(const mouse_button_pressed_event& event); + void handle_mouse_button_released(const mouse_button_released_event& event); + void handle_mouse_moved(const mouse_moved_event& event); + void handle_mouse_scrolled(const mouse_scrolled_event& event); std::vector> subscriptions; std::vector> gamepad_axis_mappings; diff --git a/src/input/control.hpp b/src/input/control.hpp index fa9cf68..621f5b2 100644 --- a/src/input/control.hpp +++ b/src/input/control.hpp @@ -20,7 +20,7 @@ #ifndef ANTKEEPER_INPUT_CONTROL_HPP #define ANTKEEPER_INPUT_CONTROL_HPP -#include "input/event.hpp" +#include "input/input-events.hpp" #include "event/publisher.hpp" #include @@ -69,19 +69,19 @@ public: } /// Returns the channel through which control activated events are published. - [[nodiscard]] inline ::event::channel& get_activated_channel() noexcept + [[nodiscard]] inline ::event::channel& get_activated_channel() noexcept { return activated_publisher.channel(); } /// Returns the channel through which control active events are published. - [[nodiscard]] inline ::event::channel& get_active_channel() noexcept + [[nodiscard]] inline ::event::channel& get_active_channel() noexcept { return active_publisher.channel(); } /// Returns the channel through which control deactivated events are published. - [[nodiscard]] inline ::event::channel& get_deactivated_channel() noexcept + [[nodiscard]] inline ::event::channel& get_deactivated_channel() noexcept { return deactivated_publisher.channel(); } @@ -90,13 +90,13 @@ private: threshold_function_type threshold_function; bool active; - event::control_activated activated_event; - event::control_active active_event; - event::control_deactivated deactivated_event; + control_activated_event activated_event; + control_active_event active_event; + control_deactivated_event deactivated_event; - ::event::publisher activated_publisher; - ::event::publisher active_publisher; - ::event::publisher deactivated_publisher; + ::event::publisher activated_publisher; + ::event::publisher active_publisher; + ::event::publisher deactivated_publisher; }; } // namespace input diff --git a/src/input/device.hpp b/src/input/device.hpp index a12e6d5..cc14039 100644 --- a/src/input/device.hpp +++ b/src/input/device.hpp @@ -21,7 +21,7 @@ #define ANTKEEPER_INPUT_DEVICE_HPP #include "input/device-type.hpp" -#include "input/event.hpp" +#include "input/input-events.hpp" #include "event/publisher.hpp" #include "utility/uuid.hpp" #include @@ -73,13 +73,13 @@ public: } /// Returns the channel through which device connected events are published. - [[nodiscard]] inline ::event::channel& get_connected_channel() noexcept + [[nodiscard]] inline ::event::channel& get_connected_channel() noexcept { return connected_publisher.channel(); } /// Returns the channel through which device disconnected events are published. - [[nodiscard]] inline ::event::channel& get_disconnected_channel() noexcept + [[nodiscard]] inline ::event::channel& get_disconnected_channel() noexcept { return disconnected_publisher.channel(); } @@ -91,8 +91,8 @@ private: ::uuid uuid; bool connected; - ::event::publisher connected_publisher; - ::event::publisher disconnected_publisher; + ::event::publisher connected_publisher; + ::event::publisher disconnected_publisher; }; } // namespace input diff --git a/src/input/gamepad.hpp b/src/input/gamepad.hpp index d2b9538..7ae7f3f 100644 --- a/src/input/gamepad.hpp +++ b/src/input/gamepad.hpp @@ -21,7 +21,7 @@ #define ANTKEEPER_INPUT_GAMEPAD_HPP #include "input/device.hpp" -#include "input/event.hpp" +#include "input/input-events.hpp" #include "input/gamepad-axis.hpp" #include "input/gamepad-button.hpp" #include "event/publisher.hpp" @@ -123,19 +123,19 @@ public: void move(gamepad_axis axis, float position); /// Returns the channel through which gamepad button pressed events are published. - [[nodiscard]] inline ::event::channel& get_button_pressed_channel() noexcept + [[nodiscard]] inline ::event::channel& get_button_pressed_channel() noexcept { return button_pressed_publisher.channel(); } /// Returns the channel through which gamepad button released events are published. - [[nodiscard]] inline ::event::channel& get_button_released_channel() noexcept + [[nodiscard]] inline ::event::channel& get_button_released_channel() noexcept { return button_released_publisher.channel(); } /// Returns the channel through which gamepad axis moved events are published. - [[nodiscard]] inline ::event::channel& get_axis_moved_channel() noexcept + [[nodiscard]] inline ::event::channel& get_axis_moved_channel() noexcept { return axis_moved_publisher.channel(); } @@ -161,9 +161,9 @@ private: float left_deadzone_roundness; float right_deadzone_roundness; - ::event::publisher button_pressed_publisher; - ::event::publisher button_released_publisher; - ::event::publisher axis_moved_publisher; + ::event::publisher button_pressed_publisher; + ::event::publisher button_released_publisher; + ::event::publisher axis_moved_publisher; }; } // namespace input diff --git a/src/input/event.hpp b/src/input/input-events.hpp similarity index 88% rename from src/input/event.hpp rename to src/input/input-events.hpp index 9a89a69..73ffbbc 100644 --- a/src/input/event.hpp +++ b/src/input/input-events.hpp @@ -17,8 +17,8 @@ * along with Antkeeper source code. If not, see . */ -#ifndef ANTKEEPER_INPUT_EVENT_HPP -#define ANTKEEPER_INPUT_EVENT_HPP +#ifndef ANTKEEPER_INPUT_INPUT_EVENTS_HPP +#define ANTKEEPER_INPUT_INPUT_EVENTS_HPP #include "input/gamepad-axis.hpp" #include "input/gamepad-button.hpp" @@ -39,15 +39,10 @@ class gamepad; class keyboard; class mouse; -/** - * Input events. - */ -namespace event { - /** * Event generated when a control has been activated. */ -struct control_activated +struct control_activated_event { /// Control that was activated. control* control; @@ -56,7 +51,7 @@ struct control_activated /** * Event generated while a control is active. */ -struct control_active +struct control_active_event { /// Active control. control* control; @@ -68,7 +63,7 @@ struct control_active /** * Event generated when a control has been deactivated. */ -struct control_deactivated +struct control_deactivated_event { /// Control that was deactivated. control* control; @@ -77,7 +72,7 @@ struct control_deactivated /** * Event generated when an input mapping has been generated. */ -struct input_mapped +struct input_mapped_event { /// Input mapping that was generated. std::shared_ptr mapping; @@ -86,7 +81,7 @@ struct input_mapped /** * Event generated when an input device has been connected. */ -struct device_connected +struct device_connected_event { /// Device that was connected. device* device; @@ -95,7 +90,7 @@ struct device_connected /** * Event generated when an input device has been disconnected. */ -struct device_disconnected +struct device_disconnected_event { /// Device that was disconnected. device* device; @@ -104,7 +99,7 @@ struct device_disconnected /** * Event generated when a gamepad button has been pressed. */ -struct gamepad_button_pressed +struct gamepad_button_pressed_event { /// Gamepad that generated the event. gamepad* gamepad; @@ -116,7 +111,7 @@ struct gamepad_button_pressed /** * Event generated when a gamepad button has been released. */ -struct gamepad_button_released +struct gamepad_button_released_event { /// Gamepad that generated the event. gamepad* gamepad; @@ -128,7 +123,7 @@ struct gamepad_button_released /** * Event generated when a gamepad axis has been moved. */ -struct gamepad_axis_moved +struct gamepad_axis_moved_event { /// Gamepad that generated the event. gamepad* gamepad; @@ -143,7 +138,7 @@ struct gamepad_axis_moved /** * Event generated when a keyboard key has been pressed. */ -struct key_pressed +struct key_pressed_event { /// Keyboard that generated the event. keyboard* keyboard; @@ -161,7 +156,7 @@ struct key_pressed /** * Event generated when a keyboard key has been released. */ -struct key_released +struct key_released_event { /// Keyboard that generated the event. keyboard* keyboard; @@ -179,7 +174,7 @@ struct key_released /** * Event generated when a mouse has been moved. */ -struct mouse_moved +struct mouse_moved_event { /// Mouse that generated the event. mouse* mouse; @@ -194,7 +189,7 @@ struct mouse_moved /** * Event generated when a mouse button has been pressed. */ -struct mouse_button_pressed +struct mouse_button_pressed_event { /// Mouse that generated the event. mouse* mouse; @@ -209,7 +204,7 @@ struct mouse_button_pressed /** * Event generated when a mouse button has been released. */ -struct mouse_button_released +struct mouse_button_released_event { /// Mouse that generated the event. mouse* mouse; @@ -224,7 +219,7 @@ struct mouse_button_released /** * Event generated when a mouse has been scrolled. */ -struct mouse_scrolled +struct mouse_scrolled_event { /// Mouse that generated the event. mouse* mouse; @@ -239,9 +234,8 @@ struct mouse_scrolled /** * Event generated when the application has been requested to quit. */ -struct application_quit {}; +struct application_quit_event {}; -} // namespace event } // namespace input -#endif // ANTKEEPER_INPUT_EVENT_HPP +#endif // ANTKEEPER_INPUT_INPUT_EVENTS_HPP diff --git a/src/input/keyboard.hpp b/src/input/keyboard.hpp index af45867..733a1ac 100644 --- a/src/input/keyboard.hpp +++ b/src/input/keyboard.hpp @@ -21,7 +21,7 @@ #define ANTKEEPER_INPUT_KEYBOARD_HPP #include "input/device.hpp" -#include "input/event.hpp" +#include "input/input-events.hpp" #include "input/scancode.hpp" #include "input/modifier-key.hpp" #include "event/publisher.hpp" @@ -61,13 +61,13 @@ public: void release(scancode scancode, bool repeat = false, std::uint16_t modifiers = modifier_key::none); /// Returns the channel through which key pressed events are published. - [[nodiscard]] inline ::event::channel& get_key_pressed_channel() noexcept + [[nodiscard]] inline ::event::channel& get_key_pressed_channel() noexcept { return key_pressed_publisher.channel(); } /// Returns the channel through which key released events are published. - [[nodiscard]] inline ::event::channel& get_key_released_channel() noexcept + [[nodiscard]] inline ::event::channel& get_key_released_channel() noexcept { return key_released_publisher.channel(); } @@ -79,8 +79,8 @@ public: } private: - ::event::publisher key_pressed_publisher; - ::event::publisher key_released_publisher; + ::event::publisher key_pressed_publisher; + ::event::publisher key_released_publisher; }; } // namespace input diff --git a/src/input/mapper.cpp b/src/input/mapper.cpp index 8f3941d..a0b02ef 100644 --- a/src/input/mapper.cpp +++ b/src/input/mapper.cpp @@ -24,12 +24,12 @@ namespace input { void mapper::connect(::event::queue& queue) { - subscriptions.emplace_back(queue.subscribe(std::bind_front(&mapper::handle_gamepad_axis_moved, this))); - subscriptions.emplace_back(queue.subscribe(std::bind_front(&mapper::handle_gamepad_button_pressed, this))); - subscriptions.emplace_back(queue.subscribe(std::bind_front(&mapper::handle_key_pressed, this))); - subscriptions.emplace_back(queue.subscribe(std::bind_front(&mapper::handle_mouse_button_pressed, this))); - subscriptions.emplace_back(queue.subscribe(std::bind_front(&mapper::handle_mouse_moved, this))); - subscriptions.emplace_back(queue.subscribe(std::bind_front(&mapper::handle_mouse_scrolled, this))); + subscriptions.emplace_back(queue.subscribe(std::bind_front(&mapper::handle_gamepad_axis_moved, this))); + subscriptions.emplace_back(queue.subscribe(std::bind_front(&mapper::handle_gamepad_button_pressed, this))); + subscriptions.emplace_back(queue.subscribe(std::bind_front(&mapper::handle_key_pressed, this))); + subscriptions.emplace_back(queue.subscribe(std::bind_front(&mapper::handle_mouse_button_pressed, this))); + subscriptions.emplace_back(queue.subscribe(std::bind_front(&mapper::handle_mouse_moved, this))); + subscriptions.emplace_back(queue.subscribe(std::bind_front(&mapper::handle_mouse_scrolled, this))); } void mapper::disconnect() @@ -37,27 +37,27 @@ void mapper::disconnect() subscriptions.clear(); } -void mapper::handle_gamepad_axis_moved(const event::gamepad_axis_moved& event) +void mapper::handle_gamepad_axis_moved(const gamepad_axis_moved_event& event) { input_mapped_publisher.publish({std::shared_ptr(new gamepad_axis_mapping(event.gamepad, event.axis, std::signbit(event.position)))}); } -void mapper::handle_gamepad_button_pressed(const event::gamepad_button_pressed& event) +void mapper::handle_gamepad_button_pressed(const gamepad_button_pressed_event& event) { input_mapped_publisher.publish({std::shared_ptr(new gamepad_button_mapping(event.gamepad, event.button))}); } -void mapper::handle_key_pressed(const event::key_pressed& event) +void mapper::handle_key_pressed(const key_pressed_event& event) { input_mapped_publisher.publish({std::shared_ptr(new key_mapping(event.keyboard, event.scancode))}); } -void mapper::handle_mouse_button_pressed(const event::mouse_button_pressed& event) +void mapper::handle_mouse_button_pressed(const mouse_button_pressed_event& event) { input_mapped_publisher.publish({std::shared_ptr(new mouse_button_mapping(event.mouse, event.button))}); } -void mapper::handle_mouse_moved(const event::mouse_moved& event) +void mapper::handle_mouse_moved(const mouse_moved_event& event) { if (event.difference.x()) { @@ -70,7 +70,7 @@ void mapper::handle_mouse_moved(const event::mouse_moved& event) } } -void mapper::handle_mouse_scrolled(const event::mouse_scrolled& event) +void mapper::handle_mouse_scrolled(const mouse_scrolled_event& event) { if (event.velocity.x()) { diff --git a/src/input/mapper.hpp b/src/input/mapper.hpp index 9418e4e..fb06aea 100644 --- a/src/input/mapper.hpp +++ b/src/input/mapper.hpp @@ -23,7 +23,7 @@ #include "event/subscription.hpp" #include "event/queue.hpp" #include "event/publisher.hpp" -#include "input/event.hpp" +#include "input/input-events.hpp" #include "input/mapping.hpp" #include #include @@ -49,21 +49,21 @@ public: void disconnect(); /// Returns the channel through which input mapped events are published. - [[nodiscard]] inline ::event::channel& get_input_mapped_channel() noexcept + [[nodiscard]] inline ::event::channel& get_input_mapped_channel() noexcept { return input_mapped_publisher.channel(); } private: - void handle_gamepad_axis_moved(const event::gamepad_axis_moved& event); - void handle_gamepad_button_pressed(const event::gamepad_button_pressed& event); - void handle_key_pressed(const event::key_pressed& event); - void handle_mouse_button_pressed(const event::mouse_button_pressed& event); - void handle_mouse_moved(const event::mouse_moved& event); - void handle_mouse_scrolled(const event::mouse_scrolled& event); + void handle_gamepad_axis_moved(const gamepad_axis_moved_event& event); + void handle_gamepad_button_pressed(const gamepad_button_pressed_event& event); + void handle_key_pressed(const key_pressed_event& event); + void handle_mouse_button_pressed(const mouse_button_pressed_event& event); + void handle_mouse_moved(const mouse_moved_event& event); + void handle_mouse_scrolled(const mouse_scrolled_event& event); std::vector> subscriptions; - ::event::publisher input_mapped_publisher; + ::event::publisher input_mapped_publisher; }; } // namespace input diff --git a/src/input/mouse.hpp b/src/input/mouse.hpp index 71bc3aa..c29dd4d 100644 --- a/src/input/mouse.hpp +++ b/src/input/mouse.hpp @@ -21,7 +21,7 @@ #define ANTKEEPER_INPUT_MOUSE_HPP #include "input/device.hpp" -#include "input/event.hpp" +#include "input/input-events.hpp" #include "input/mouse-button.hpp" #include "event/publisher.hpp" #include "math/vector.hpp" @@ -79,25 +79,25 @@ public: } /// Returns the channel through which mouse button pressed events are published. - [[nodiscard]] inline ::event::channel& get_button_pressed_channel() noexcept + [[nodiscard]] inline ::event::channel& get_button_pressed_channel() noexcept { return button_pressed_publisher.channel(); } /// Returns the channel through which mouse button released events are published. - [[nodiscard]] inline ::event::channel& get_button_released_channel() noexcept + [[nodiscard]] inline ::event::channel& get_button_released_channel() noexcept { return button_released_publisher.channel(); } /// Returns the channel through which mouse moved events are published. - [[nodiscard]] inline ::event::channel& get_moved_channel() noexcept + [[nodiscard]] inline ::event::channel& get_moved_channel() noexcept { return moved_publisher.channel(); } /// Returns the channel through which mouse scrolled events are published. - [[nodiscard]] inline ::event::channel& get_scrolled_channel() noexcept + [[nodiscard]] inline ::event::channel& get_scrolled_channel() noexcept { return scrolled_publisher.channel(); } @@ -111,10 +111,10 @@ public: private: math::vector position; - ::event::publisher button_pressed_publisher; - ::event::publisher button_released_publisher; - ::event::publisher moved_publisher; - ::event::publisher scrolled_publisher; + ::event::publisher button_pressed_publisher; + ::event::publisher button_released_publisher; + ::event::publisher moved_publisher; + ::event::publisher scrolled_publisher; }; } // namespace input diff --git a/src/main.cpp b/src/main.cpp index a7d86c4..81e2c8e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -67,12 +67,12 @@ int main(int argc, char* argv[]) std::osyncstream(std::cout) << std::format ( - "{:8.03f} {}:{}:{}: {}{}: {}{}\n", + "{}{:8.03f} {}:{}:{}: {}: {}{}\n", + colors[static_cast(event.severity)], std::chrono::duration(event.time - launch_time).count(), std::filesystem::path(event.location.file_name()).filename().string(), event.location.line(), event.location.column(), - colors[static_cast(event.severity)], severities[static_cast(event.severity)], event.message, ansi::reset diff --git a/src/ui/ui.hpp b/src/ui/ui.hpp index f0c9419..0d79184 100644 --- a/src/ui/ui.hpp +++ b/src/ui/ui.hpp @@ -20,9 +20,7 @@ #ifndef ANTKEEPER_UI_HPP #define ANTKEEPER_UI_HPP -/// UI elements +/// UI elements. namespace ui {} -#include "ui/element.hpp" - #endif // ANTKEEPER_UI_HPP