Browse Source

Controller refactor to enforce InputProfile usage (because why not)

DefaultThreadManager build FIX
undefined
Benjamin ‘Touky’ Huet Sam Hocevar <sam@hocevar.net> 10 years ago
parent
commit
6c3dd67bc0
8 changed files with 52 additions and 23 deletions
  1. +2
    -1
      doc/samples/btphystest.cpp
  2. +2
    -1
      doc/samples/meshviewer.cpp
  3. +3
    -0
      doc/samples/meshviewer.vcxproj
  4. +2
    -1
      doc/tutorial/07_input.cpp
  5. +2
    -1
      doc/tutorial/12_voronoi.cpp
  6. +30
    -4
      src/input/controller.cpp
  7. +9
    -13
      src/input/controller.h
  8. +2
    -2
      src/lol/sys/threadtypes.h

+ 2
- 1
doc/samples/btphystest.cpp View File

@@ -72,7 +72,8 @@ void BtPhysTest::InitApp()
#endif //CAT_MODE

/* Register an input controller for the keyboard */
m_controller = new Controller("Default", KEY_MAX, 0);
m_controller = new Controller("Default");
m_controller->SetInputCount(KEY_MAX, 0);
m_controller->GetKey(KEY_MOVE_FORWARD).Bind("Keyboard", "Up");
m_controller->GetKey(KEY_MOVE_BACK).Bind("Keyboard", "Down");
m_controller->GetKey(KEY_MOVE_LEFT).Bind("Keyboard", "Left");


+ 2
- 1
doc/samples/meshviewer.cpp View File

@@ -264,7 +264,8 @@ public:

#if NO_NACL_EM_INPUT
/* Register an input controller for the keyboard */
m_controller = new Controller("Default", MAX_KEYS, MAX_AXIS);
m_controller = new Controller("Default");
m_controller->SetInputCount(MAX_KEYS, MAX_AXIS);

if (InputDevice::Get(g_name_mouse.C()))
{


+ 3
- 0
doc/samples/meshviewer.vcxproj View File

@@ -53,6 +53,9 @@
<None Include="data\mesh-buffer.txt">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
</None>
<None Include="Makefile.am">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
</None>
<None Include="meshviewer.index.html">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
</None>


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

@@ -24,7 +24,8 @@ class InputTutorial : public WorldEntity
public:
InputTutorial()
{
m_controller = new Controller("Default", KEY_MAX, AXIS_MAX);
m_controller = new Controller("Default");
m_controller->SetInputCount(KEY_MAX, AXIS_MAX);

m_keyboard = InputDevice::Get("Keyboard");
if (m_keyboard)


+ 2
- 1
doc/tutorial/12_voronoi.cpp View File

@@ -62,7 +62,8 @@ public:
m_time = .0f;
m_timer = -1.0f;
mode = 0;
m_controller = new Controller("Default", KEY_MAX, 0);
m_controller = new Controller("Default");
m_controller->SetInputCount(KEY_MAX, 0);
m_controller->GetKey(KEY_ESC).Bind("Keyboard", "Escape");
m_controller->GetKey(KEY_PUSH).Bind("Keyboard", "p");
m_controller->GetKey(KEY_POP).Bind("Keyboard", "o");


+ 30
- 4
src/input/controller.cpp View File

@@ -226,12 +226,10 @@ float AxisBinding::RetrieveCurrentValue()
array<Controller*> Controller::controllers;

//-----------------------------------------------------------------------------
Controller::Controller(String const &name, int nb_keys, int nb_axis)
Controller::Controller(String const &name)
{
m_gamegroup = GAMEGROUP_BEFORE;
m_name = name;
m_keys.Resize(nb_keys);
m_axis.Resize(nb_axis);
m_activate_nextframe = true;
m_deactivate_nextframe = false;
m_active = false;
@@ -243,7 +241,7 @@ Controller::Controller(String const &name, int nb_keys, int nb_axis)
}

Controller::Controller(String const &name, InputProfile const& profile)
: Controller(name, 0, 0)
: Controller(name)
{
Init(profile);
}
@@ -261,6 +259,34 @@ Controller::~Controller()
}
}

//Init mode 1: Input profile system -------------------------------------------
void Controller::Init(InputProfile const& profile)
{
UnbindProfile();
BindProfile(profile);
}
void Controller::ClearProfile()
{
UnbindProfile();
}

//Init mode 2: By hand, key/axis by key/axis ----------------------------------
void Controller::SetInputCount(int nb_keys, int nb_axis)
{
m_keys.Resize(nb_keys);
m_axis.Resize(nb_axis);
}

//GetKeys/Axis stuff ----------------------------------------------------------
KeyBinding& Controller::GetKey(int index)
{
return m_keys[index];
}
AxisBinding& Controller::GetAxis(int index)
{
return m_axis[index];
}

//-----------------------------------------------------------------------------
Controller* Controller::Get(String const &name)
{


+ 9
- 13
src/input/controller.h View File

@@ -315,7 +315,7 @@ private:
class Controller : public Entity
{
public:
Controller(String const &name, int nb_keys = 0, int nb_axis = 0);
Controller(String const &name);
Controller(String const &name, InputProfile const& setup);
virtual ~Controller();

@@ -328,20 +328,16 @@ public:
/** Deactivate every active controller on next frame and return an array of deactivated (previously active) controllers */
static array<Controller*> DeactivateAll();

/** Input profile system */
void Init(InputProfile const& profile)
{
UnbindProfile();
BindProfile(profile);
}
void ClearProfile()
{
UnbindProfile();
}
/** Init mode 1: Input profile system */
void Init(InputProfile const& profile);
void ClearProfile();

/** Init mode 2: By hand, key/axis by key/axis */
void SetInputCount(int nb_keys, int nb_axis);

/** GetKeys/Axis stuff */
KeyBinding& GetKey(int index) { return m_keys[index]; }
AxisBinding& GetAxis(int index) { return m_axis[index]; }
KeyBinding& GetKey(int index);
AxisBinding& GetAxis(int index);

static Controller* Get(String const &name);



+ 2
- 2
src/lol/sys/threadtypes.h View File

@@ -26,10 +26,10 @@ class DefaultThreadManager : public BaseThreadManager
{
public:
DefaultThreadManager(int thread_count)
: DefaultThreadManager(thread_count, thread_count)
: BaseThreadManager(thread_count, thread_count)
{ }
DefaultThreadManager(int thread_count, int thread_min)
: DefaultThreadManager(thread_count, thread_min)
: BaseThreadManager(thread_count, thread_min)
{ }

char const *GetName() { return "<DefaultThreadManager>"; }


Loading…
Cancel
Save