Ver código fonte

small tweak in controller

undefined
Benjamin ‘Touky’ Huet Sam Hocevar <sam@hocevar.net> 9 anos atrás
pai
commit
f3d30c4111
2 arquivos alterados com 17 adições e 12 exclusões
  1. +13
    -10
      src/input/controller.cpp
  2. +4
    -2
      src/input/controller.h

+ 13
- 10
src/input/controller.cpp Ver arquivo

@@ -27,7 +27,7 @@ void KeyBinding::Bind(const String& device_name, const String& key_name)
return;
}

int keyindex = device->GetKeyIndex(key_name);
ptrdiff_t keyindex = device->GetKeyIndex(key_name);
if (keyindex < 0)
{
Log::Warn("trying to bind nonexistent key %s.%s\n",
@@ -72,7 +72,7 @@ void AxisBinding::Bind(const String& device_name, const String& axis_name)
return;
}

int axisindex = device->GetAxisIndex(axis_name);
ptrdiff_t axisindex = device->GetAxisIndex(axis_name);
if (axisindex < 0)
{
Log::Warn("trying to bind nonexistent axis %s.%s\n",
@@ -93,7 +93,7 @@ void AxisBinding::BindKey(const String& device_name, const String& key_name)
return;
}

int keyindex = device->GetKeyIndex(key_name);
ptrdiff_t keyindex = device->GetKeyIndex(key_name);
if (keyindex < 0)
{
Log::Warn("trying to bind nonexistent axis key %s.%s\n",
@@ -114,7 +114,7 @@ void AxisBinding::BindKeys(const String& device_name, const String& min_key_name
return;
}

int minkeyindex = device->GetKeyIndex(min_key_name);
ptrdiff_t minkeyindex = device->GetKeyIndex(min_key_name);
if (minkeyindex < 0)
{
Log::Warn("trying to bind nonexistent axis key %s.%s\n",
@@ -122,7 +122,7 @@ void AxisBinding::BindKeys(const String& device_name, const String& min_key_name
return;
}

int maxkeyindex = device->GetKeyIndex(max_key_name);
ptrdiff_t maxkeyindex = device->GetKeyIndex(max_key_name);
if (maxkeyindex < 0)
{
Log::Warn("trying to bind nonexistent axis key %s.%s\n",
@@ -231,7 +231,7 @@ Controller::Controller(String const &name, int nb_keys, int nb_axis)
m_name = name;
m_keys.Resize(nb_keys);
m_axis.Resize(nb_axis);
m_activate_nextframe = false;
m_activate_nextframe = true;
m_deactivate_nextframe = false;
m_active = false;
if (Get(name) != nullptr)
@@ -267,11 +267,14 @@ void Controller::TickGame(float seconds)
{
Entity::TickGame(seconds);

for (int i = 0; i < m_keys.Count(); ++i)
m_keys[i].Update();
if (m_active)
{
for (int i = 0; i < m_keys.Count(); ++i)
m_keys[i].Update();

for (int i = 0; i < m_axis.Count(); ++i)
m_axis[i].Update();
for (int i = 0; i < m_axis.Count(); ++i)
m_axis[i].Update();
}

if (m_activate_nextframe)
m_active = true;


+ 4
- 2
src/input/controller.h Ver arquivo

@@ -13,6 +13,7 @@
namespace lol
{

//-----------------------------------------------------------------------------
class KeyBinding
{
public:
@@ -68,6 +69,7 @@ protected:
friend class Controller;
};

//-----------------------------------------------------------------------------
class AxisBinding
{
public:
@@ -131,12 +133,12 @@ protected:
friend class Controller;
};

//-----------------------------------------------------------------------------
class Controller : public Entity
{
public:
Controller(String const &name, int nb_keys, int nb_axis);
~Controller();
virtual ~Controller();

virtual void TickGame(float seconds);



Carregando…
Cancelar
Salvar