From fc43bd7e5b700aad94ce86d92e5f82040bc7b0a3 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Thu, 21 Feb 2019 13:01:38 +0100 Subject: [PATCH] input: remove useless code. --- doc/tutorial/07_input.cpp | 2 +- doc/tutorial/09_sound.cpp | 2 +- doc/tutorial/11_fractal.cpp | 2 +- src/ui/controller.cpp | 4 ++-- src/ui/controller.h | 35 ++++++++--------------------------- 5 files changed, 13 insertions(+), 32 deletions(-) diff --git a/doc/tutorial/07_input.cpp b/doc/tutorial/07_input.cpp index 0f21d0a4..eb265c01 100644 --- a/doc/tutorial/07_input.cpp +++ b/doc/tutorial/07_input.cpp @@ -51,7 +51,7 @@ public: } # else m_profile - << InputProfile::Keyboard(KEY_MANUAL_ROTATION, "Space") + << InputProfile::KeyboardKey(KEY_MANUAL_ROTATION, "Space") << InputProfile::MouseKey(KEY_DRAG_MESH, "Left") << InputProfile::JoystickAxis(1, AXIS_PITCH, "Axis2") << InputProfile::JoystickAxis(1, AXIS_YAW, "Axis1") diff --git a/doc/tutorial/09_sound.cpp b/doc/tutorial/09_sound.cpp index e09cbae4..02ab41bb 100644 --- a/doc/tutorial/09_sound.cpp +++ b/doc/tutorial/09_sound.cpp @@ -29,7 +29,7 @@ public: val = -1; m_controller = new Controller("Default"); - m_profile << InputProfile::Keyboard(0, "Space") + m_profile << InputProfile::KeyboardKey(0, "Space") << InputProfile::MouseKey(1, "Left"); m_controller->Init(m_profile); m_mouse = InputDevice::GetMouse(); diff --git a/doc/tutorial/11_fractal.cpp b/doc/tutorial/11_fractal.cpp index fec44c75..8410f5b6 100644 --- a/doc/tutorial/11_fractal.cpp +++ b/doc/tutorial/11_fractal.cpp @@ -46,7 +46,7 @@ public: m_profile << InputProfile::MouseKey(0, "Left") << InputProfile::MouseKey(1, "Right") << InputProfile::MouseKey(2, "Middle") - << InputProfile::Keyboard(3, "Space"); + << InputProfile::KeyboardKey(3, "Space"); m_controller->Init(m_profile); m_mouse = InputDevice::GetMouse(); diff --git a/src/ui/controller.cpp b/src/ui/controller.cpp index a0b118cb..caab57e6 100644 --- a/src/ui/controller.cpp +++ b/src/ui/controller.cpp @@ -348,7 +348,7 @@ void Controller::UnbindProfile() //Keyboard if (m_keyboard) { - for (InputProfile::Keyboard& key : m_profile.m_keys) + for (InputProfile::KeyboardKey& key : m_profile.m_keys) GetKey(key.m_idx).UnbindKeyboard(key.m_name); m_keyboard = nullptr; } @@ -391,7 +391,7 @@ void Controller::BindProfile(InputProfile const& setup) m_keyboard = InputDevice::GetKeyboard(); if (m_keyboard) { - for (InputProfile::Keyboard& key : m_profile.m_keys) + for (InputProfile::KeyboardKey& key : m_profile.m_keys) GetKey(key.m_idx).BindKeyboard(key.m_name); } diff --git a/src/ui/controller.h b/src/ui/controller.h index 2fc5a6ed..db858e0a 100644 --- a/src/ui/controller.h +++ b/src/ui/controller.h @@ -166,14 +166,12 @@ private: }; public: //--------------------------------------------------------------------- - class Keyboard : public Key + class KeyboardKey : public Key { friend class Controller; friend class InputProfile; public: - Keyboard() : Key() { } - Keyboard(int idx, std::string const& name) : Key(idx, name) { } - Keyboard(const Keyboard& other) : Key(other.m_idx, other.m_name) { } + KeyboardKey(int idx, std::string const& name) : Key(idx, name) { } }; //--------------------------------------------------------------------- class MouseKey : public Key @@ -181,9 +179,7 @@ public: friend class Controller; friend class InputProfile; public: - MouseKey() : Key() { } MouseKey(int idx, std::string const& name) : Key(idx, name) { } - MouseKey(const Keyboard& other) : Key(other.m_idx, other.m_name) { } }; //--------------------------------------------------------------------- class MouseAxis : public Key @@ -191,9 +187,7 @@ public: friend class Controller; friend class InputProfile; public: - MouseAxis() : Key() { } MouseAxis(int idx, std::string const& name) : Key(idx, name) { } - MouseAxis(const Keyboard& other) : Key(other.m_idx, other.m_name) { } }; //--------------------------------------------------------------------- class JoystickKey : public Joystick @@ -201,9 +195,7 @@ public: friend class Controller; friend class InputProfile; public: - JoystickKey() : Joystick() { } JoystickKey(uint64_t joy, int idx, std::string const& name) : Joystick(joy, idx, name) { } - JoystickKey(const JoystickKey& other) : Joystick(other.m_joy, other.m_idx, other.m_name) { } }; //--------------------------------------------------------------------- class JoystickAxis : public Joystick @@ -211,22 +203,11 @@ public: friend class Controller; friend class InputProfile; public: - JoystickAxis() : Joystick() { } JoystickAxis(uint64_t joy, int idx, std::string const& name) : Joystick(joy, idx, name) { } - JoystickAxis(const JoystickAxis& other) : Joystick(other.m_joy, other.m_idx, other.m_name) { } }; public: - InputProfile() { } - InputProfile(const InputProfile& other) - { - m_keys = other.m_keys; - m_mouse_keys = other.m_mouse_keys; - m_mouse_axis = other.m_mouse_axis; - m_joystick = other.m_joystick; - m_joystick_keys = other.m_joystick_keys; - m_joystick_axis = other.m_joystick_axis; - } - virtual ~InputProfile() { } + InputProfile() = default; + virtual ~InputProfile() = default; bool IsEmpty() const { @@ -241,12 +222,12 @@ public: return m_mouse_axis.count() + m_joystick_axis.count(); } //Keys -------------------------------------------------------------------- - InputProfile& operator<<(InputProfile::Keyboard const& binding) + InputProfile& operator<<(InputProfile::KeyboardKey const& binding) { m_keys.push_unique(binding); return *this; } - InputProfile& operator<<(array const& bindings) + InputProfile& operator<<(array const& bindings) { m_keys += bindings; return *this; @@ -304,12 +285,12 @@ public: void register_default_keys() { -#define _SC(id, str, name) *this << InputProfile::Keyboard(id, #name); +#define _SC(id, str, name) *this << InputProfile::KeyboardKey(id, #name); #include "ui/keys.inc" } private: - array m_keys; + array m_keys; array m_mouse_keys; array m_mouse_axis; array m_joystick;