summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2014-01-30 19:51:21 -0500
committerLioncash <mathew1800@gmail.com>2014-01-30 19:51:21 -0500
commitd91a5abba1d66948cc43cc7a6c80827ede061bc8 (patch)
tree7693269f83a0343cac3b411575edaa05603ba40b /Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp
parentb5b02de663eb1fbad38ba3e3bcca85349963a65e (diff)
Light cleanup to a little bit of InputCommon. Replaces much of the iterators that litter this section of the codebase.
Also clean up a little bit of the comments that describe the interface classes.
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp')
-rw-r--r--Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp82
1 files changed, 37 insertions, 45 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp
index 66a7b1e56c..9eca17118d 100644
--- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp
@@ -38,9 +38,9 @@ const float INPUT_DETECT_THRESHOLD = 0.55f;
ControllerInterface g_controller_interface;
//
-// Init
+// Init
//
-// detect devices and inputs outputs / will make refresh function later
+// Detect devices and inputs outputs / will make refresh function later
//
void ControllerInterface::Initialize()
{
@@ -79,31 +79,26 @@ if (GLWin.platform == EGL_PLATFORM_X11) {
}
//
-// DeInit
+// DeInit
//
-// remove all devices/ call library cleanup functions
+// Remove all devices/ call library cleanup functions
//
void ControllerInterface::Shutdown()
{
- if (false == m_is_init)
+ if (!m_is_init)
return;
- std::vector<Device*>::const_iterator
- d = m_devices.begin(),
- de = m_devices.end();
- for ( ;d != de; ++d )
+ for (Device* d : m_devices)
{
- std::vector<Device::Output*>::const_iterator
- o = (*d)->Outputs().begin(),
- oe = (*d)->Outputs().end();
- // set outputs to ZERO before destroying device
- for ( ;o!=oe; ++o)
- (*o)->SetState(0);
- // update output
- (*d)->UpdateOutput();
-
- //delete device
- delete *d;
+ // Set outputs to ZERO before destroying device
+ for (Device::Output* o : d->Outputs())
+ o->SetState(0);
+
+ // Update output
+ d->UpdateOutput();
+
+ // Delete device
+ delete d;
}
m_devices.clear();
@@ -132,9 +127,9 @@ void ControllerInterface::Shutdown()
}
//
-// SetHwnd
+// SetHwnd
//
-// sets the hwnd used for some crap when initializing, use before calling Init
+// Sets the hwnd used for some crap when initializing, use before calling Init
//
void ControllerInterface::SetHwnd( void* const hwnd )
{
@@ -142,9 +137,9 @@ void ControllerInterface::SetHwnd( void* const hwnd )
}
//
-// UpdateInput
+// UpdateInput
//
-// update input for all devices, return true if all devices returned successful
+// Update input for all devices, return true if all devices returned successful
//
bool ControllerInterface::UpdateInput(const bool force)
{
@@ -153,16 +148,13 @@ bool ControllerInterface::UpdateInput(const bool force)
if (force)
lk.lock();
else if (!lk.try_lock())
- return false;
+ return false;
size_t ok_count = 0;
- std::vector<Device*>::const_iterator
- d = m_devices.begin(),
- e = m_devices.end();
- for ( ;d != e; ++d )
+ for (Device* d : m_devices)
{
- if ((*d)->UpdateInput())
+ if (d->UpdateInput())
++ok_count;
//else
// disabled. it might be causing problems
@@ -173,9 +165,9 @@ bool ControllerInterface::UpdateInput(const bool force)
}
//
-// UpdateOutput
+// UpdateOutput
//
-// update output for all devices, return true if all devices returned successful
+// Update output for all devices, return true if all devices returned successful
//
bool ControllerInterface::UpdateOutput(const bool force)
{
@@ -188,9 +180,9 @@ bool ControllerInterface::UpdateOutput(const bool force)
size_t ok_count = 0;
- for (auto d = m_devices.cbegin(); d != m_devices.cend(); ++d)
+ for (Device* d : m_devices)
{
- if ((*d)->UpdateOutput())
+ if (d->UpdateOutput())
++ok_count;
}
@@ -198,9 +190,9 @@ bool ControllerInterface::UpdateOutput(const bool force)
}
//
-// InputReference :: State
+// InputReference :: State
//
-// get the state of an input reference
+// Gets the state of an input reference
// override function for ControlReference::State ...
//
ControlState ControllerInterface::InputReference::State( const ControlState ignore )
@@ -212,11 +204,11 @@ ControlState ControllerInterface::InputReference::State( const ControlState igno
}
//
-// OutputReference :: State
+// OutputReference :: State
//
-// set the state of all binded outputs
-// overrides ControlReference::State .. combined them so i could make the gui simple / inputs == same as outputs one list
-// i was lazy and it works so watever
+// Set the state of all binded outputs
+// overrides ControlReference::State .. combined them so I could make the GUI simple / inputs == same as outputs one list
+// I was lazy and it works so watever
//
ControlState ControllerInterface::OutputReference::State(const ControlState state)
{
@@ -226,9 +218,9 @@ ControlState ControllerInterface::OutputReference::State(const ControlState stat
}
//
-// UpdateReference
+// UpdateReference
//
-// updates a controlreference's binded devices/controls
+// Updates a controlreference's binded devices/controls
// need to call this to re-parse a control reference's expression after changing it
//
void ControllerInterface::UpdateReference(ControllerInterface::ControlReference* ref
@@ -242,9 +234,9 @@ void ControllerInterface::UpdateReference(ControllerInterface::ControlReference*
}
//
-// InputReference :: Detect
+// InputReference :: Detect
//
-// wait for input on all binded devices
+// Wait for input on all binded devices
// supports not detecting inputs that were held down at the time of Detect start,
// which is useful for those crazy flightsticks that have certain buttons that are always held down
// or some crazy axes or something
@@ -294,7 +286,7 @@ Device::Control* ControllerInterface::InputReference::Detect(const unsigned int
}
//
-// OutputReference :: Detect
+// OutputReference :: Detect
//
// Totally different from the inputReference detect / I have them combined so it was simpler to make the GUI.
// The GUI doesn't know the difference between an input and an output / it's odd but I was lazy and it was easy