From 8ce104f0a06dbdf729760eaf9999fc77bb4bd78e Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 2 Aug 2018 21:41:51 -0400 Subject: [PATCH 1/2] input_common: Add missing override specifiers --- src/input_common/keyboard.cpp | 2 +- src/input_common/motion_emu.cpp | 2 +- src/input_common/sdl/sdl.cpp | 12 ------------ 3 files changed, 2 insertions(+), 14 deletions(-) diff --git a/src/input_common/keyboard.cpp b/src/input_common/keyboard.cpp index 0f0d10f237..0410ff3288 100644 --- a/src/input_common/keyboard.cpp +++ b/src/input_common/keyboard.cpp @@ -14,7 +14,7 @@ public: explicit KeyButton(std::shared_ptr key_button_list_) : key_button_list(key_button_list_) {} - ~KeyButton(); + ~KeyButton() override; bool GetStatus() const override { return status.load(); diff --git a/src/input_common/motion_emu.cpp b/src/input_common/motion_emu.cpp index 4596910000..31e11875de 100644 --- a/src/input_common/motion_emu.cpp +++ b/src/input_common/motion_emu.cpp @@ -133,7 +133,7 @@ public: device = std::make_shared(update_millisecond, sensitivity, tilt_clamp); } - std::tuple, Math::Vec3> GetStatus() const { + std::tuple, Math::Vec3> GetStatus() const override { return device->GetStatus(); } diff --git a/src/input_common/sdl/sdl.cpp b/src/input_common/sdl/sdl.cpp index 294836e66c..21b859ed08 100644 --- a/src/input_common/sdl/sdl.cpp +++ b/src/input_common/sdl/sdl.cpp @@ -314,10 +314,6 @@ namespace Polling { class SDLPoller : public InputCommon::Polling::DevicePoller { public: - SDLPoller() = default; - - ~SDLPoller() = default; - void Start() override { // SDL joysticks must be opened, otherwise they don't generate events SDL_JoystickUpdate(); @@ -341,10 +337,6 @@ private: class SDLButtonPoller final : public SDLPoller { public: - SDLButtonPoller() = default; - - ~SDLButtonPoller() = default; - Common::ParamPackage GetNextInput() override { SDL_Event event; while (SDL_PollEvent(&event)) { @@ -364,10 +356,6 @@ public: class SDLAnalogPoller final : public SDLPoller { public: - SDLAnalogPoller() = default; - - ~SDLAnalogPoller() = default; - void Start() override { SDLPoller::Start(); From 384c9e5382b88bac75598d70b58aa2b6e8ae2035 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 2 Aug 2018 21:51:08 -0400 Subject: [PATCH 2/2] input_common: Use std::move where applicable Avoids unnecessary atomic reference count increments and decrements --- src/input_common/keyboard.cpp | 3 ++- src/input_common/sdl/sdl.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/input_common/keyboard.cpp b/src/input_common/keyboard.cpp index 0410ff3288..525fe6abcf 100644 --- a/src/input_common/keyboard.cpp +++ b/src/input_common/keyboard.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include "input_common/keyboard.h" namespace InputCommon { @@ -12,7 +13,7 @@ namespace InputCommon { class KeyButton final : public Input::ButtonDevice { public: explicit KeyButton(std::shared_ptr key_button_list_) - : key_button_list(key_button_list_) {} + : key_button_list(std::move(key_button_list_)) {} ~KeyButton() override; diff --git a/src/input_common/sdl/sdl.cpp b/src/input_common/sdl/sdl.cpp index 21b859ed08..2810080cc1 100644 --- a/src/input_common/sdl/sdl.cpp +++ b/src/input_common/sdl/sdl.cpp @@ -82,7 +82,7 @@ private: class SDLButton final : public Input::ButtonDevice { public: explicit SDLButton(std::shared_ptr joystick_, int button_) - : joystick(joystick_), button(button_) {} + : joystick(std::move(joystick_)), button(button_) {} bool GetStatus() const override { return joystick->GetButton(button); @@ -96,7 +96,7 @@ private: class SDLDirectionButton final : public Input::ButtonDevice { public: explicit SDLDirectionButton(std::shared_ptr joystick_, int hat_, Uint8 direction_) - : joystick(joystick_), hat(hat_), direction(direction_) {} + : joystick(std::move(joystick_)), hat(hat_), direction(direction_) {} bool GetStatus() const override { return joystick->GetHatDirection(hat, direction); @@ -112,7 +112,7 @@ class SDLAxisButton final : public Input::ButtonDevice { public: explicit SDLAxisButton(std::shared_ptr joystick_, int axis_, float threshold_, bool trigger_if_greater_) - : joystick(joystick_), axis(axis_), threshold(threshold_), + : joystick(std::move(joystick_)), axis(axis_), threshold(threshold_), trigger_if_greater(trigger_if_greater_) {} bool GetStatus() const override { @@ -132,7 +132,7 @@ private: class SDLAnalog final : public Input::AnalogDevice { public: SDLAnalog(std::shared_ptr joystick_, int axis_x_, int axis_y_) - : joystick(joystick_), axis_x(axis_x_), axis_y(axis_y_) {} + : joystick(std::move(joystick_)), axis_x(axis_x_), axis_y(axis_y_) {} std::tuple GetStatus() const override { return joystick->GetAnalog(axis_x, axis_y);