Browse Source

input: remove useless code.

legacy
Sam Hocevar 6 years ago
parent
commit
fc43bd7e5b
5 changed files with 13 additions and 32 deletions
  1. +1
    -1
      doc/tutorial/07_input.cpp
  2. +1
    -1
      doc/tutorial/09_sound.cpp
  3. +1
    -1
      doc/tutorial/11_fractal.cpp
  4. +2
    -2
      src/ui/controller.cpp
  5. +8
    -27
      src/ui/controller.h

+ 1
- 1
doc/tutorial/07_input.cpp View File

@@ -51,7 +51,7 @@ public:
} }
# else # else
m_profile m_profile
<< InputProfile::Keyboard(KEY_MANUAL_ROTATION, "Space")
<< InputProfile::KeyboardKey(KEY_MANUAL_ROTATION, "Space")
<< InputProfile::MouseKey(KEY_DRAG_MESH, "Left") << InputProfile::MouseKey(KEY_DRAG_MESH, "Left")
<< InputProfile::JoystickAxis(1, AXIS_PITCH, "Axis2") << InputProfile::JoystickAxis(1, AXIS_PITCH, "Axis2")
<< InputProfile::JoystickAxis(1, AXIS_YAW, "Axis1") << InputProfile::JoystickAxis(1, AXIS_YAW, "Axis1")


+ 1
- 1
doc/tutorial/09_sound.cpp View File

@@ -29,7 +29,7 @@ public:
val = -1; val = -1;


m_controller = new Controller("Default"); m_controller = new Controller("Default");
m_profile << InputProfile::Keyboard(0, "Space")
m_profile << InputProfile::KeyboardKey(0, "Space")
<< InputProfile::MouseKey(1, "Left"); << InputProfile::MouseKey(1, "Left");
m_controller->Init(m_profile); m_controller->Init(m_profile);
m_mouse = InputDevice::GetMouse(); m_mouse = InputDevice::GetMouse();


+ 1
- 1
doc/tutorial/11_fractal.cpp View File

@@ -46,7 +46,7 @@ public:
m_profile << InputProfile::MouseKey(0, "Left") m_profile << InputProfile::MouseKey(0, "Left")
<< InputProfile::MouseKey(1, "Right") << InputProfile::MouseKey(1, "Right")
<< InputProfile::MouseKey(2, "Middle") << InputProfile::MouseKey(2, "Middle")
<< InputProfile::Keyboard(3, "Space");
<< InputProfile::KeyboardKey(3, "Space");
m_controller->Init(m_profile); m_controller->Init(m_profile);
m_mouse = InputDevice::GetMouse(); m_mouse = InputDevice::GetMouse();




+ 2
- 2
src/ui/controller.cpp View File

@@ -348,7 +348,7 @@ void Controller::UnbindProfile()
//Keyboard //Keyboard
if (m_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); GetKey(key.m_idx).UnbindKeyboard(key.m_name);
m_keyboard = nullptr; m_keyboard = nullptr;
} }
@@ -391,7 +391,7 @@ void Controller::BindProfile(InputProfile const& setup)
m_keyboard = InputDevice::GetKeyboard(); m_keyboard = InputDevice::GetKeyboard();
if (m_keyboard) 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); GetKey(key.m_idx).BindKeyboard(key.m_name);
} }




+ 8
- 27
src/ui/controller.h View File

@@ -166,14 +166,12 @@ private:
}; };
public: public:
//--------------------------------------------------------------------- //---------------------------------------------------------------------
class Keyboard : public Key
class KeyboardKey : public Key
{ {
friend class Controller; friend class Controller;
friend class InputProfile; friend class InputProfile;
public: 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 class MouseKey : public Key
@@ -181,9 +179,7 @@ public:
friend class Controller; friend class Controller;
friend class InputProfile; friend class InputProfile;
public: public:
MouseKey() : Key() { }
MouseKey(int idx, std::string const& name) : Key(idx, name) { } 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 class MouseAxis : public Key
@@ -191,9 +187,7 @@ public:
friend class Controller; friend class Controller;
friend class InputProfile; friend class InputProfile;
public: public:
MouseAxis() : Key() { }
MouseAxis(int idx, std::string const& name) : Key(idx, name) { } 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 class JoystickKey : public Joystick
@@ -201,9 +195,7 @@ public:
friend class Controller; friend class Controller;
friend class InputProfile; friend class InputProfile;
public: public:
JoystickKey() : Joystick() { }
JoystickKey(uint64_t joy, int idx, std::string const& name) : Joystick(joy, idx, name) { } 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 class JoystickAxis : public Joystick
@@ -211,22 +203,11 @@ public:
friend class Controller; friend class Controller;
friend class InputProfile; friend class InputProfile;
public: public:
JoystickAxis() : Joystick() { }
JoystickAxis(uint64_t joy, int idx, std::string const& name) : Joystick(joy, idx, name) { } 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: 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 bool IsEmpty() const
{ {
@@ -241,12 +222,12 @@ public:
return m_mouse_axis.count() + m_joystick_axis.count(); return m_mouse_axis.count() + m_joystick_axis.count();
} }
//Keys -------------------------------------------------------------------- //Keys --------------------------------------------------------------------
InputProfile& operator<<(InputProfile::Keyboard const& binding)
InputProfile& operator<<(InputProfile::KeyboardKey const& binding)
{ {
m_keys.push_unique(binding); m_keys.push_unique(binding);
return *this; return *this;
} }
InputProfile& operator<<(array<InputProfile::Keyboard> const& bindings)
InputProfile& operator<<(array<InputProfile::KeyboardKey> const& bindings)
{ {
m_keys += bindings; m_keys += bindings;
return *this; return *this;
@@ -304,12 +285,12 @@ public:


void register_default_keys() 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" #include "ui/keys.inc"
} }


private: private:
array<Keyboard> m_keys;
array<KeyboardKey> m_keys;
array<MouseKey> m_mouse_keys; array<MouseKey> m_mouse_keys;
array<MouseAxis> m_mouse_axis; array<MouseAxis> m_mouse_axis;
array<uint64_t> m_joystick; array<uint64_t> m_joystick;


Loading…
Cancel
Save