Remove using namespace from headers.

This commit is contained in:
SpinDizzy 2020-09-16 07:03:03 +00:00
parent c0729c1048
commit ca57659fcb
3 changed files with 34 additions and 36 deletions

View file

@ -34,7 +34,6 @@
#include "SDLIncludes.h" #include "SDLIncludes.h"
#include <vector> #include <vector>
using namespace std;
#define NUM_SDL_KEYS (sizeof(s_keyMap) / sizeof(SDLKeyMapStruct)) #define NUM_SDL_KEYS (sizeof(s_keyMap) / sizeof(SDLKeyMapStruct))
@ -54,10 +53,10 @@ private:
static SDLKeyMapStruct s_keyMap[]; static SDLKeyMapStruct s_keyMap[];
// Vector to keep track of attached joysticks // Vector to keep track of attached joysticks
vector<SDL_Joystick*> m_joysticks; std::vector<SDL_Joystick*> m_joysticks;
// Vector of joystick details // Vector of joystick details
vector<JoyDetails> m_joyDetails; std::vector<JoyDetails> m_joyDetails;
// Current key state obtained from SDL // Current key state obtained from SDL
const Uint8 *m_keyState; const Uint8 *m_keyState;

View file

@ -300,7 +300,7 @@ Finish:
struct DIEnumDevsContext struct DIEnumDevsContext
{ {
vector<DIJoyInfo> *infos; std::vector<DIJoyInfo> *infos;
bool useXInput; bool useXInput;
}; };
@ -456,7 +456,7 @@ CDirectInputSystem::~CDirectInputSystem()
} }
} }
bool CDirectInputSystem::GetRegString(HKEY regKey, const char *regPath, string &str) bool CDirectInputSystem::GetRegString(HKEY regKey, const char *regPath, std::string &str)
{ {
// Query to get the length // Query to get the length
DWORD dataLen; DWORD dataLen;
@ -480,14 +480,14 @@ bool CDirectInputSystem::GetRegDeviceName(const char *rawDevName, char *name)
// Check raw device string is in form that can be handled and remove initial 4-char sequence // Check raw device string is in form that can be handled and remove initial 4-char sequence
// For XP this is: \??\TypeID#HardwareID#InstanceID#{DevicesClasses-id} // For XP this is: \??\TypeID#HardwareID#InstanceID#{DevicesClasses-id}
// For Vista/Win7 64bit this is: \\?\TypeID#HardwareID#InstanceID#{DevicesClasses-id} // For Vista/Win7 64bit this is: \\?\TypeID#HardwareID#InstanceID#{DevicesClasses-id}
string devNameStr(rawDevName); std::string devNameStr(rawDevName);
if (devNameStr.find("\\??\\") != string::npos || devNameStr.find("\\\\?\\") != string::npos) if (devNameStr.find("\\??\\") != std::string::npos || devNameStr.find("\\\\?\\") != std::string::npos)
devNameStr.erase(0, 4); devNameStr.erase(0, 4);
else else
return false; return false;
// Append raw device string to base registry path and convert all #'s to \ in the process // Append raw device string to base registry path and convert all #'s to \ in the process
string regPath = "SYSTEM\\CurrentControlSet\\Enum\\" + devNameStr; std::string regPath = "SYSTEM\\CurrentControlSet\\Enum\\" + devNameStr;
for (size_t i = 0; i < regPath.size(); i++) for (size_t i = 0; i < regPath.size(); i++)
{ {
if (regPath[i] == '#') if (regPath[i] == '#')
@ -496,7 +496,7 @@ bool CDirectInputSystem::GetRegDeviceName(const char *rawDevName, char *name)
// Remove part after last \ in path // Remove part after last \ in path
size_t last = regPath.rfind('\\'); size_t last = regPath.rfind('\\');
if (last != string::npos) if (last != std::string::npos)
regPath = regPath.erase(last); regPath = regPath.erase(last);
// Try and open registry key with this path // Try and open registry key with this path
@ -505,10 +505,10 @@ bool CDirectInputSystem::GetRegDeviceName(const char *rawDevName, char *name)
if (result != ERROR_SUCCESS) if (result != ERROR_SUCCESS)
return false; return false;
string parentIdStr; std::string parentIdStr;
// Fetch device description from registry, if it exists, and use that for name // Fetch device description from registry, if it exists, and use that for name
string regStr; std::string regStr;
if (GetRegString(regKey, "DeviceDesc", regStr)) if (GetRegString(regKey, "DeviceDesc", regStr))
goto Found; goto Found;
@ -516,12 +516,12 @@ bool CDirectInputSystem::GetRegDeviceName(const char *rawDevName, char *name)
RegCloseKey(regKey); RegCloseKey(regKey);
// Check it is HID device // Check it is HID device
if (devNameStr.find("HID") == string::npos) if (devNameStr.find("HID") == std::string::npos)
return false; return false;
// Get parent id, from after last \ in name // Get parent id, from after last \ in name
last = regPath.rfind('\\'); last = regPath.rfind('\\');
if (last == regPath.size() - 1 || last == string::npos) if (last == regPath.size() - 1 || last == std::string::npos)
return false; return false;
parentIdStr = regPath.substr(last + 1); parentIdStr = regPath.substr(last + 1);
@ -560,7 +560,7 @@ bool CDirectInputSystem::GetRegDeviceName(const char *rawDevName, char *name)
continue; continue;
// Get parent id prefix and see if it matches // Get parent id prefix and see if it matches
string finalParentIdStr; std::string finalParentIdStr;
if (GetRegString(finalRegKey, "ParentIdPrefix", finalParentIdStr) && parentIdStr.compare(0, finalParentIdStr.size(), finalParentIdStr) == 0) if (GetRegString(finalRegKey, "ParentIdPrefix", finalParentIdStr) && parentIdStr.compare(0, finalParentIdStr.size(), finalParentIdStr) == 0)
{ {
// Get device description, if it exists, and use that for name // Get device description, if it exists, and use that for name
@ -588,7 +588,7 @@ bool CDirectInputSystem::GetRegDeviceName(const char *rawDevName, char *name)
Found: Found:
// If found device description, name will be from final colon // If found device description, name will be from final colon
last = regStr.rfind(';'); last = regStr.rfind(';');
if (last == regStr.size() - 1 || last == string::npos) if (last == regStr.size() - 1 || last == std::string::npos)
last = 0; last = 0;
else else
last++; last++;
@ -781,7 +781,7 @@ void CDirectInputSystem::PollKeyboardsAndMice()
if (m_useRawInput) if (m_useRawInput)
{ {
// For RawInput, only thing to do is update wheelDir from wheelData for each mouse state. Everything else is updated via WM events. // For RawInput, only thing to do is update wheelDir from wheelData for each mouse state. Everything else is updated via WM events.
for (vector<RawMseState>::iterator it = m_rawMseStates.begin(); it != m_rawMseStates.end(); it++) for (std::vector<RawMseState>::iterator it = m_rawMseStates.begin(); it != m_rawMseStates.end(); it++)
{ {
if (it->wheelDelta != 0) if (it->wheelDelta != 0)
{ {
@ -875,7 +875,7 @@ void CDirectInputSystem::CloseKeyboardsAndMice()
} }
// Delete storage for keyboards // Delete storage for keyboards
for (vector<bool*>::iterator it = m_rawKeyStates.begin(); it != m_rawKeyStates.end(); it++) for (std::vector<bool*>::iterator it = m_rawKeyStates.begin(); it != m_rawKeyStates.end(); it++)
delete[] *it; delete[] *it;
m_keyDetails.clear(); m_keyDetails.clear();
m_rawKeyboards.clear(); m_rawKeyboards.clear();
@ -915,7 +915,7 @@ void CDirectInputSystem::ResetMice()
m_combRawMseState.x = p.x; m_combRawMseState.x = p.x;
m_combRawMseState.y = p.y; m_combRawMseState.y = p.y;
m_combRawMseState.z = 0; m_combRawMseState.z = 0;
for (vector<RawMseState>::iterator it = m_rawMseStates.begin(); it != m_rawMseStates.end(); it++) for (std::vector<RawMseState>::iterator it = m_rawMseStates.begin(); it != m_rawMseStates.end(); it++)
{ {
it->x = p.x; it->x = p.x;
it->y = p.y; it->y = p.y;
@ -1057,7 +1057,7 @@ void CDirectInputSystem::ProcessRawInput(HRAWINPUT hInput)
} }
m_combRawMseState.buttons = 0; m_combRawMseState.buttons = 0;
for (vector<RawMseState>::iterator it = m_rawMseStates.begin(); it != m_rawMseStates.end(); it++) for (std::vector<RawMseState>::iterator it = m_rawMseStates.begin(); it != m_rawMseStates.end(); it++)
m_combRawMseState.buttons |= it->buttons; m_combRawMseState.buttons |= it->buttons;
} }
} }
@ -1080,7 +1080,7 @@ void CDirectInputSystem::OpenJoysticks()
// Loop through those found // Loop through those found
int joyNum = 0; int joyNum = 0;
int xNum = 0; int xNum = 0;
for (vector<DIJoyInfo>::iterator it = m_diJoyInfos.begin(); it != m_diJoyInfos.end(); it++) for (std::vector<DIJoyInfo>::iterator it = m_diJoyInfos.begin(); it != m_diJoyInfos.end(); it++)
{ {
joyNum++; joyNum++;
@ -1293,7 +1293,7 @@ void CDirectInputSystem::ActivateJoysticks()
{ {
// Set DirectInput cooperative level of joysticks // Set DirectInput cooperative level of joysticks
unsigned joyNum = 0; unsigned joyNum = 0;
for (vector<DIJoyInfo>::iterator it = m_diJoyInfos.begin(); it != m_diJoyInfos.end(); it++) for (std::vector<DIJoyInfo>::iterator it = m_diJoyInfos.begin(); it != m_diJoyInfos.end(); it++)
{ {
if (!it->isXInput) if (!it->isXInput)
{ {
@ -1313,7 +1313,7 @@ void CDirectInputSystem::PollJoysticks()
{ {
// Get current joystick states from XInput and DirectInput // Get current joystick states from XInput and DirectInput
int i = 0; int i = 0;
for (vector<DIJoyInfo>::iterator it = m_diJoyInfos.begin(); it != m_diJoyInfos.end(); it++) for (std::vector<DIJoyInfo>::iterator it = m_diJoyInfos.begin(); it != m_diJoyInfos.end(); it++)
{ {
LPDIJOYSTATE2 pJoyState = &m_diJoyStates[i++]; LPDIJOYSTATE2 pJoyState = &m_diJoyStates[i++];
@ -1394,7 +1394,7 @@ void CDirectInputSystem::PollJoysticks()
void CDirectInputSystem::CloseJoysticks() void CDirectInputSystem::CloseJoysticks()
{ {
// Release any DirectInput force feedback effects that were created // Release any DirectInput force feedback effects that were created
for (vector<DIJoyInfo>::iterator it = m_diJoyInfos.begin(); it != m_diJoyInfos.end(); it++) for (std::vector<DIJoyInfo>::iterator it = m_diJoyInfos.begin(); it != m_diJoyInfos.end(); it++)
{ {
for (unsigned axisNum = 0; axisNum < NUM_JOY_AXES; axisNum++) for (unsigned axisNum = 0; axisNum < NUM_JOY_AXES; axisNum++)
{ {
@ -1410,7 +1410,7 @@ void CDirectInputSystem::CloseJoysticks()
} }
// Release each DirectInput joystick // Release each DirectInput joystick
for (vector<LPDIRECTINPUTDEVICE8>::iterator it = m_di8Joysticks.begin(); it != m_di8Joysticks.end(); it++) for (std::vector<LPDIRECTINPUTDEVICE8>::iterator it = m_di8Joysticks.begin(); it != m_di8Joysticks.end(); it++)
{ {
(*it)->Unacquire(); (*it)->Unacquire();
(*it)->Release(); (*it)->Release();

View file

@ -42,7 +42,6 @@
#include <functional> #include <functional>
#include <vector> #include <vector>
using namespace std;
#define NUM_DI_KEYS (sizeof(s_keyMap) / sizeof(DIKeyMapStruct)) #define NUM_DI_KEYS (sizeof(s_keyMap) / sizeof(DIKeyMapStruct))
@ -137,16 +136,16 @@ private:
GetRawInputDataPtr m_getRIDataPtr; GetRawInputDataPtr m_getRIDataPtr;
// Keyboard, mouse and joystick details // Keyboard, mouse and joystick details
vector<KeyDetails> m_keyDetails; std::vector<KeyDetails> m_keyDetails;
vector<MouseDetails> m_mseDetails; std::vector<MouseDetails> m_mseDetails;
vector<JoyDetails> m_joyDetails; std::vector<JoyDetails> m_joyDetails;
// RawInput keyboard and mice handles and states // RawInput keyboard and mice handles and states
vector<HANDLE> m_rawKeyboards; std::vector<HANDLE> m_rawKeyboards;
vector<bool*> m_rawKeyStates; std::vector<bool*> m_rawKeyStates;
vector<HANDLE> m_rawMice; std::vector<HANDLE> m_rawMice;
RawMseState m_combRawMseState; RawMseState m_combRawMseState;
vector<RawMseState> m_rawMseStates; std::vector<RawMseState> m_rawMseStates;
// Function pointers for XInput API // Function pointers for XInput API
XInputGetCapabilitiesPtr m_xiGetCapabilitiesPtr; XInputGetCapabilitiesPtr m_xiGetCapabilitiesPtr;
@ -157,17 +156,17 @@ private:
LPDIRECTINPUT8 m_di8; LPDIRECTINPUT8 m_di8;
LPDIRECTINPUTDEVICE8 m_di8Keyboard; LPDIRECTINPUTDEVICE8 m_di8Keyboard;
LPDIRECTINPUTDEVICE8 m_di8Mouse; LPDIRECTINPUTDEVICE8 m_di8Mouse;
vector<LPDIRECTINPUTDEVICE8> m_di8Joysticks; std::vector<LPDIRECTINPUTDEVICE8> m_di8Joysticks;
// DirectInput keyboard and mouse states // DirectInput keyboard and mouse states
BYTE m_diKeyState[256]; BYTE m_diKeyState[256];
DIMseState m_diMseState; DIMseState m_diMseState;
// DirectInput joystick infos and states // DirectInput joystick infos and states
vector<DIJoyInfo> m_diJoyInfos; std::vector<DIJoyInfo> m_diJoyInfos;
vector<DIJOYSTATE2> m_diJoyStates; std::vector<DIJOYSTATE2> m_diJoyStates;
bool GetRegString(HKEY regKey, const char *regPath, string &str); bool GetRegString(HKEY regKey, const char *regPath, std::string &str);
bool GetRegDeviceName(const char *rawDevName, char *name); bool GetRegDeviceName(const char *rawDevName, char *name);