summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerInterface
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
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')
-rw-r--r--Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp82
-rw-r--r--Source/Core/InputCommon/ControllerInterface/ControllerInterface.h40
-rw-r--r--Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp134
-rw-r--r--Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.h22
-rw-r--r--Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.cpp12
-rw-r--r--Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.h16
-rw-r--r--Source/Core/InputCommon/ControllerInterface/Device.cpp79
-rw-r--r--Source/Core/InputCommon/ControllerInterface/Device.h34
8 files changed, 196 insertions, 223 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
diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h
index 4efb8941b7..5e0cd9db8b 100644
--- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h
+++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h
@@ -35,24 +35,24 @@
using namespace ciface::Core;
//
-// ControllerInterface
+// ControllerInterface
//
-// some crazy shit I made to control different device inputs and outputs
-// from lots of different sources, hopefully more easily
+// Some crazy shit I made to control different device inputs and outputs
+// from lots of different sources, hopefully more easily.
//
class ControllerInterface : public DeviceContainer
{
public:
//
- // ControlReference
+ // ControlReference
//
- // these are what you create to actually use the inputs, InputReference or OutputReference
+ // These are what you create to actually use the inputs, InputReference or OutputReference.
//
- // after being bound to devices and controls with ControllerInterface::UpdateReference,
- // each one can link to multiple devices and controls
- // when you change a ControlReference's expression,
- // you must use ControllerInterface::UpdateReference on it to rebind controls
+ // After being bound to devices and controls with ControllerInterface::UpdateReference,
+ // each one can link to multiple devices and controls
+ // when you change a ControlReference's expression,
+ // you must use ControllerInterface::UpdateReference on it to rebind controls
//
class ControlReference
{
@@ -62,15 +62,17 @@ public:
virtual Device::Control* Detect(const unsigned int ms, Device* const device) = 0;
ControlState range;
- std::string expression;
- const bool is_input;
+ std::string expression;
+ const bool is_input;
ciface::ExpressionParser::ExpressionParseStatus parse_error;
- virtual ~ControlReference() {
+ virtual ~ControlReference()
+ {
delete parsed_expression;
}
- int BoundCount() {
+ int BoundCount()
+ {
if (parsed_expression)
return parsed_expression->num_controls;
else
@@ -83,9 +85,9 @@ public:
};
//
- // InputReference
+ // InputReference
//
- // control reference for inputs
+ // Control reference for inputs
//
class InputReference : public ControlReference
{
@@ -96,9 +98,9 @@ public:
};
//
- // OutputReference
+ // OutputReference
//
- // control reference for outputs
+ // Control reference for outputs
//
class OutputReference : public ControlReference
{
@@ -122,8 +124,8 @@ public:
std::recursive_mutex update_lock;
private:
- bool m_is_init;
- void* m_hwnd;
+ bool m_is_init;
+ void* m_hwnd;
};
extern ControllerInterface g_controller_interface;
diff --git a/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp b/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp
index 7211559e93..a8d1ba53c8 100644
--- a/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp
@@ -49,81 +49,81 @@ void GetXInputGUIDS( std::vector<DWORD>& guids )
#define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } }
- IWbemLocator* pIWbemLocator = NULL;
+ IWbemLocator* pIWbemLocator = NULL;
IEnumWbemClassObject* pEnumDevices = NULL;
- IWbemClassObject* pDevices[20] = {0};
- IWbemServices* pIWbemServices = NULL;
- BSTR bstrNamespace = NULL;
- BSTR bstrDeviceID = NULL;
- BSTR bstrClassName = NULL;
- DWORD uReturned = 0;
- VARIANT var;
- HRESULT hr;
+ IWbemClassObject* pDevices[20] = {0};
+ IWbemServices* pIWbemServices = NULL;
+ BSTR bstrNamespace = NULL;
+ BSTR bstrDeviceID = NULL;
+ BSTR bstrClassName = NULL;
+ DWORD uReturned = 0;
+ VARIANT var;
+ HRESULT hr;
// CoInit if needed
hr = CoInitialize(NULL);
bool bCleanupCOM = SUCCEEDED(hr);
// Create WMI
- hr = CoCreateInstance( __uuidof(WbemLocator),
- NULL,
- CLSCTX_INPROC_SERVER,
- __uuidof(IWbemLocator),
- (LPVOID*) &pIWbemLocator);
- if( FAILED(hr) || pIWbemLocator == NULL )
+ hr = CoCreateInstance(__uuidof(WbemLocator),
+ NULL,
+ CLSCTX_INPROC_SERVER,
+ __uuidof(IWbemLocator),
+ (LPVOID*) &pIWbemLocator);
+ if (FAILED(hr) || pIWbemLocator == NULL)
goto LCleanup;
- bstrNamespace = SysAllocString( L"\\\\.\\root\\cimv2" );if( bstrNamespace == NULL ) goto LCleanup;
- bstrClassName = SysAllocString( L"Win32_PNPEntity" ); if( bstrClassName == NULL ) goto LCleanup;
- bstrDeviceID = SysAllocString( L"DeviceID" ); if( bstrDeviceID == NULL ) goto LCleanup;
+ bstrNamespace = SysAllocString(L"\\\\.\\root\\cimv2");if(bstrNamespace == NULL) goto LCleanup;
+ bstrClassName = SysAllocString(L"Win32_PNPEntity"); if(bstrClassName == NULL) goto LCleanup;
+ bstrDeviceID = SysAllocString(L"DeviceID"); if(bstrDeviceID == NULL) goto LCleanup;
// Connect to WMI
- hr = pIWbemLocator->ConnectServer( bstrNamespace, NULL, NULL, 0L, 0L, NULL, NULL, &pIWbemServices );
- if( FAILED(hr) || pIWbemServices == NULL )
+ hr = pIWbemLocator->ConnectServer(bstrNamespace, NULL, NULL, 0L, 0L, NULL, NULL, &pIWbemServices);
+ if (FAILED(hr) || pIWbemServices == NULL)
goto LCleanup;
// Switch security level to IMPERSONATE.
- CoSetProxyBlanket( pIWbemServices, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, NULL,
- RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE );
+ CoSetProxyBlanket(pIWbemServices, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, NULL,
+ RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE);
- hr = pIWbemServices->CreateInstanceEnum( bstrClassName, 0, NULL, &pEnumDevices );
- if( FAILED(hr) || pEnumDevices == NULL )
+ hr = pIWbemServices->CreateInstanceEnum(bstrClassName, 0, NULL, &pEnumDevices);
+ if (FAILED(hr) || pEnumDevices == NULL)
goto LCleanup;
// Loop over all devices
- while( true )
+ while (true)
{
// Get 20 at a time
- hr = pEnumDevices->Next( 10000, 20, pDevices, &uReturned );
- if( FAILED(hr) || uReturned == 0 )
+ hr = pEnumDevices->Next(10000, 20, pDevices, &uReturned);
+ if (FAILED(hr) || uReturned == 0)
break;
- for( UINT iDevice=0; iDevice<uReturned; ++iDevice )
+ for (UINT iDevice = 0; iDevice < uReturned; ++iDevice)
{
// For each device, get its device ID
- hr = pDevices[iDevice]->Get( bstrDeviceID, 0L, &var, NULL, NULL );
- if( SUCCEEDED( hr ) && var.vt == VT_BSTR && var.bstrVal != NULL )
+ hr = pDevices[iDevice]->Get(bstrDeviceID, 0L, &var, NULL, NULL);
+ if (SUCCEEDED(hr) && var.vt == VT_BSTR && var.bstrVal != NULL)
{
// Check if the device ID contains "IG_". If it does, then it's an XInput device
- // This information can not be found from DirectInput
- if( wcsstr( var.bstrVal, L"IG_" ) )
+ // This information can not be found from DirectInput
+ if (wcsstr(var.bstrVal, L"IG_"))
{
// If it does, then get the VID/PID from var.bstrVal
DWORD dwPid = 0, dwVid = 0;
- WCHAR* strVid = wcsstr( var.bstrVal, L"VID_" );
- if( strVid && swscanf( strVid, L"VID_%4X", &dwVid ) != 1 )
+ WCHAR* strVid = wcsstr(var.bstrVal, L"VID_");
+ if (strVid && swscanf(strVid, L"VID_%4X", &dwVid) != 1)
dwVid = 0;
- WCHAR* strPid = wcsstr( var.bstrVal, L"PID_" );
- if( strPid && swscanf( strPid, L"PID_%4X", &dwPid ) != 1 )
+ WCHAR* strPid = wcsstr(var.bstrVal, L"PID_");
+ if (strPid && swscanf(strPid, L"PID_%4X", &dwPid) != 1)
dwPid = 0;
// Compare the VID/PID to the DInput device
- DWORD dwVidPid = MAKELONG( dwVid, dwPid );
- guids.push_back( dwVidPid );
+ DWORD dwVidPid = MAKELONG(dwVid, dwPid);
+ guids.push_back(dwVidPid);
//bIsXinputDevice = true;
}
}
- SAFE_RELEASE( pDevices[iDevice] );
+ SAFE_RELEASE(pDevices[iDevice]);
}
}
@@ -134,13 +134,13 @@ LCleanup:
SysFreeString(bstrDeviceID);
if(bstrClassName)
SysFreeString(bstrClassName);
- for( UINT iDevice=0; iDevice<20; iDevice++ )
- SAFE_RELEASE( pDevices[iDevice] );
- SAFE_RELEASE( pEnumDevices );
- SAFE_RELEASE( pIWbemLocator );
- SAFE_RELEASE( pIWbemServices );
+ for (UINT iDevice = 0; iDevice < 20; iDevice++)
+ SAFE_RELEASE(pDevices[iDevice]);
+ SAFE_RELEASE(pEnumDevices);
+ SAFE_RELEASE(pIWbemLocator);
+ SAFE_RELEASE(pIWbemServices);
- if( bCleanupCOM )
+ if (bCleanupCOM)
CoUninitialize();
}
@@ -156,17 +156,14 @@ void InitJoystick(IDirectInput8* const idi8, std::vector<Core::Device*>& devices
std::vector<DWORD> xinput_guids;
GetXInputGUIDS( xinput_guids );
- std::list<DIDEVICEINSTANCE>::iterator
- i = joysticks.begin(),
- e = joysticks.end();
- for ( ; i!=e; ++i )
+ for (DIDEVICEINSTANCE& joystick : joysticks)
{
// skip XInput Devices
- if ( std::find( xinput_guids.begin(), xinput_guids.end(), i->guidProduct.Data1 ) != xinput_guids.end() )
+ if (std::find(xinput_guids.begin(), xinput_guids.end(), joystick.guidProduct.Data1) != xinput_guids.end())
continue;
LPDIRECTINPUTDEVICE8 js_device;
- if (SUCCEEDED(idi8->CreateDevice(i->guidInstance, &js_device, NULL)))
+ if (SUCCEEDED(idi8->CreateDevice(joystick.guidInstance, &js_device, NULL)))
{
if (SUCCEEDED(js_device->SetDataFormat(&c_dfDIJoystick)))
{
@@ -182,7 +179,7 @@ void InitJoystick(IDirectInput8* const idi8, std::vector<Core::Device*>& devices
}
}
- Joystick* js = new Joystick(/*&*i, */js_device, name_counts[i->tszInstanceName]++);
+ Joystick* js = new Joystick(/*&*i, */js_device, name_counts[joystick.tszInstanceName]++);
// only add if it has some inputs/outputs
if (js->Inputs().size() || js->Outputs().size())
devices.push_back(js);
@@ -359,14 +356,11 @@ Joystick::Joystick( /*const LPCDIDEVICEINSTANCE lpddi, */const LPDIRECTINPUTDEVI
Joystick::~Joystick()
{
// release the ff effect iface's
- std::list<EffectState>::iterator
- i = m_state_out.begin(),
- e = m_state_out.end();
- for (; i!=e; ++i)
+ for (EffectState& state : m_state_out)
{
- i->iface->Stop();
- i->iface->Unload();
- i->iface->Release();
+ state.iface->Stop();
+ state.iface->Unload();
+ state.iface->Release();
}
m_device->Unacquire();
@@ -377,7 +371,7 @@ void Joystick::ClearInputState()
{
ZeroMemory(&m_state_in, sizeof(m_state_in));
// set hats to center
- memset( m_state_in.rgdwPOV, 0xFF, sizeof(m_state_in.rgdwPOV) );
+ memset(m_state_in.rgdwPOV, 0xFF, sizeof(m_state_in.rgdwPOV));
}
std::string Joystick::GetName() const
@@ -449,26 +443,23 @@ bool Joystick::UpdateOutput()
eff.dwSize = sizeof(DIEFFECT);
eff.dwFlags = DIEFF_CARTESIAN | DIEFF_OBJECTOFFSETS;
- std::list<EffectState>::iterator
- i = m_state_out.begin(),
- e = m_state_out.end();
- for (; i!=e; ++i)
+ for (EffectState& state : m_state_out)
{
- if (i->params)
+ if (state.params)
{
- if (i->size)
+ if (state.size)
{
- eff.cbTypeSpecificParams = i->size;
- eff.lpvTypeSpecificParams = i->params;
+ eff.cbTypeSpecificParams = state.size;
+ eff.lpvTypeSpecificParams = state.params;
// set params and start effect
- ok_count += SUCCEEDED(i->iface->SetParameters(&eff, DIEP_TYPESPECIFICPARAMS | DIEP_START));
+ ok_count += SUCCEEDED(state.iface->SetParameters(&eff, DIEP_TYPESPECIFICPARAMS | DIEP_START));
}
else
{
- ok_count += SUCCEEDED(i->iface->Stop());
+ ok_count += SUCCEEDED(state.iface->Stop());
}
- i->params = NULL;
+ state.params = NULL;
}
else
{
@@ -540,6 +531,7 @@ ControlState Joystick::Hat::GetState() const
// hat centered code from MSDN
if (0xFFFF == LOWORD(m_hat))
return 0;
+
return (abs((int)(m_hat / 4500 - m_direction * 2 + 8) % 8 - 4) > 2);
}
diff --git a/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.h b/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.h
index 20b38c8a69..6b6be58193 100644
--- a/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.h
+++ b/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.h
@@ -25,9 +25,9 @@ private:
{
EffectState(LPDIRECTINPUTEFFECT eff) : iface(eff), params(NULL), size(0) {}
- LPDIRECTINPUTEFFECT iface;
- void* params; // null when force hasn't changed
- u8 size; // zero when force should stop
+ LPDIRECTINPUTEFFECT iface;
+ void* params; // null when force hasn't changed
+ u8 size; // zero when force should stop
};
class Button : public Input
@@ -76,9 +76,9 @@ private:
P params;
const u8 m_index;
};
- typedef Force<DICONSTANTFORCE> ForceConstant;
- typedef Force<DIRAMPFORCE> ForceRamp;
- typedef Force<DIPERIODIC> ForcePeriodic;
+ typedef Force<DICONSTANTFORCE> ForceConstant;
+ typedef Force<DIRAMPFORCE> ForceRamp;
+ typedef Force<DIPERIODIC> ForcePeriodic;
public:
bool UpdateInput();
@@ -94,13 +94,13 @@ public:
std::string GetSource() const;
private:
- const LPDIRECTINPUTDEVICE8 m_device;
- const unsigned int m_index;
+ const LPDIRECTINPUTDEVICE8 m_device;
+ const unsigned int m_index;
- DIJOYSTATE m_state_in;
- std::list<EffectState> m_state_out;
+ DIJOYSTATE m_state_in;
+ std::list<EffectState> m_state_out;
- bool m_buffered;
+ bool m_buffered;
};
}
diff --git a/Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.cpp b/Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.cpp
index 850ff27281..50f065f92f 100644
--- a/Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.cpp
@@ -5,11 +5,11 @@
// (lower would be more sensitive) user can lower sensitivity by setting range
// seems decent here ( at 8 ), I don't think anyone would need more sensitive than this
// and user can lower it much farther than they would want to with the range
-#define MOUSE_AXIS_SENSITIVITY 8
+#define MOUSE_AXIS_SENSITIVITY 8
// if input hasn't been received for this many ms, mouse input will be skipped
// otherwise it is just some crazy value
-#define DROP_INPUT_TIME 250
+#define DROP_INPUT_TIME 250
namespace ciface
{
@@ -18,8 +18,8 @@ namespace DInput
static const struct
{
- const BYTE code;
- const char* const name;
+ const BYTE code;
+ const char* const name;
} named_keys[] =
{
#include "NamedKeys.h"
@@ -27,8 +27,8 @@ static const struct
static const struct
{
- const BYTE code;
- const char* const name;
+ const BYTE code;
+ const char* const name;
} named_lights[] =
{
{ VK_NUMLOCK, "NUM LOCK" },
diff --git a/Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.h b/Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.h
index 73398ca1b1..4973979052 100644
--- a/Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.h
+++ b/Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.h
@@ -21,8 +21,8 @@ class KeyboardMouse : public Core::Device
private:
struct State
{
- BYTE keyboard[256];
- DIMOUSESTATE2 mouse;
+ BYTE keyboard[256];
+ DIMOUSESTATE2 mouse;
struct
{
float x, y;
@@ -98,13 +98,13 @@ public:
std::string GetSource() const;
private:
- const LPDIRECTINPUTDEVICE8 m_kb_device;
- const LPDIRECTINPUTDEVICE8 m_mo_device;
+ const LPDIRECTINPUTDEVICE8 m_kb_device;
+ const LPDIRECTINPUTDEVICE8 m_mo_device;
- DWORD m_last_update;
- State m_state_in;
- unsigned char m_state_out[3]; // NUM CAPS SCROLL
- bool m_current_state_out[3]; // NUM CAPS SCROLL
+ DWORD m_last_update;
+ State m_state_in;
+ unsigned char m_state_out[3]; // NUM CAPS SCROLL
+ bool m_current_state_out[3]; // NUM CAPS SCROLL
};
}
diff --git a/Source/Core/InputCommon/ControllerInterface/Device.cpp b/Source/Core/InputCommon/ControllerInterface/Device.cpp
index 965ecfc817..1a7295c2c5 100644
--- a/Source/Core/InputCommon/ControllerInterface/Device.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/Device.cpp
@@ -10,29 +10,19 @@ namespace Core
{
//
-// Device :: ~Device
+// Device :: ~Device
//
// Destructor, delete all inputs/outputs on device destruction
//
Device::~Device()
{
- {
// delete inputs
- std::vector<Device::Input*>::iterator
- i = m_inputs.begin(),
- e = m_inputs.end();
- for ( ;i!=e; ++i)
- delete *i;
- }
+ for (Device::Input* input : m_inputs)
+ delete input;
- {
// delete outputs
- std::vector<Device::Output*>::iterator
- o = m_outputs.begin(),
- e = m_outputs.end();
- for ( ;o!=e; ++o)
- delete *o;
- }
+ for (Device::Output* output: m_outputs)
+ delete output;
}
void Device::AddInput(Device::Input* const i)
@@ -47,30 +37,28 @@ void Device::AddOutput(Device::Output* const o)
Device::Input* Device::FindInput(const std::string &name) const
{
- std::vector<Input*>::const_iterator
- it = m_inputs.begin(),
- itend = m_inputs.end();
- for (; it != itend; ++it)
- if ((*it)->GetName() == name)
- return *it;
+ for (Input* input : m_inputs)
+ {
+ if (input->GetName() == name)
+ return input;
+ }
return NULL;
}
Device::Output* Device::FindOutput(const std::string &name) const
{
- std::vector<Output*>::const_iterator
- it = m_outputs.begin(),
- itend = m_outputs.end();
- for (; it != itend; ++it)
- if ((*it)->GetName() == name)
- return *it;
+ for (Output* output : m_outputs)
+ {
+ if (output->GetName() == name)
+ return output;
+ }
return NULL;
}
//
-// Device :: ClearInputState
+// Device :: ClearInputState
//
// Device classes should override this function
// ControllerInterface will call this when the device returns failure during UpdateInput
@@ -84,26 +72,28 @@ void Device::ClearInputState()
}
//
-// DeviceQualifier :: ToString
+// DeviceQualifier :: ToString
//
-// get string from a device qualifier / serialize
+// Get string from a device qualifier / serialize
//
std::string DeviceQualifier::ToString() const
{
if (source.empty() && (cid < 0) && name.empty())
return "";
+
std::ostringstream ss;
ss << source << '/';
- if ( cid > -1 )
+ if (cid > -1)
ss << cid;
ss << '/' << name;
+
return ss.str();
}
//
-// DeviceQualifier :: FromString
+// DeviceQualifier :: FromString
//
-// set a device qualifier from a string / unserialize
+// Set a device qualifier from a string / unserialize
//
void DeviceQualifier::FromString(const std::string& str)
{
@@ -119,9 +109,9 @@ void DeviceQualifier::FromString(const std::string& str)
}
//
-// DeviceQualifier :: FromDevice
+// DeviceQualifier :: FromDevice
//
-// set a device qualifier from a device
+// Set a device qualifier from a device
//
void DeviceQualifier::FromDevice(const Device* const dev)
{
@@ -136,6 +126,7 @@ bool DeviceQualifier::operator==(const Device* const dev) const
if (dev->GetName() == name)
if (dev->GetSource() == source)
return true;
+
return false;
}
@@ -151,12 +142,11 @@ bool DeviceQualifier::operator==(const DeviceQualifier& devq) const
Device* DeviceContainer::FindDevice(const DeviceQualifier& devq) const
{
- std::vector<Device*>::const_iterator
- di = m_devices.begin(),
- de = m_devices.end();
- for (; di!=de; ++di)
- if (devq == *di)
- return *di;
+ for (Device* d : m_devices)
+ {
+ if (devq == d)
+ return d;
+ }
return NULL;
}
@@ -170,12 +160,9 @@ Device::Input* DeviceContainer::FindInput(const std::string& name, const Device*
return inp;
}
- std::vector<Device*>::const_iterator
- di = m_devices.begin(),
- de = m_devices.end();
- for (; di != de; ++di)
+ for (Device* d : m_devices)
{
- Device::Input* const i = (*di)->FindInput(name);
+ Device::Input* const i = d->FindInput(name);
if (i)
return i;
diff --git a/Source/Core/InputCommon/ControllerInterface/Device.h b/Source/Core/InputCommon/ControllerInterface/Device.h
index a7c26b867d..a2cdc7cf01 100644
--- a/Source/Core/InputCommon/ControllerInterface/Device.h
+++ b/Source/Core/InputCommon/ControllerInterface/Device.h
@@ -19,9 +19,9 @@ namespace Core
class DeviceQualifier;
//
-// Device
+// Device
//
-// a device class
+// A device class
//
class Device
{
@@ -30,11 +30,11 @@ public:
class Output;
//
- // Control
+ // Control
//
- // control includes inputs and outputs
+ // Control includes inputs and outputs
//
- class Control // input or output
+ class Control // input or output
{
public:
virtual std::string GetName() const = 0;
@@ -45,9 +45,9 @@ public:
};
//
- // Input
+ // Input
//
- // an input on a device
+ // An input on a device
//
class Input : public Control
{
@@ -61,9 +61,9 @@ public:
};
//
- // Output
+ // Output
//
- // an output on a device
+ // An output on a device
//
class Output : public Control
{
@@ -126,15 +126,15 @@ protected:
}
private:
- std::vector<Input*> m_inputs;
- std::vector<Output*> m_outputs;
+ std::vector<Input*> m_inputs;
+ std::vector<Output*> m_outputs;
};
//
-// DeviceQualifier
+// DeviceQualifier
//
-// device qualifier used to match devices
-// currently has ( source, id, name ) properties which match a device
+// Device qualifier used to match devices.
+// Currently has ( source, id, name ) properties which match a device
//
class DeviceQualifier
{
@@ -148,9 +148,9 @@ public:
bool operator==(const DeviceQualifier& devq) const;
bool operator==(const Device* const dev) const;
- std::string source;
- int cid;
- std::string name;
+ std::string source;
+ int cid;
+ std::string name;
};
class DeviceContainer