From f800ed9c2e984ed34fd681bb472f56759eb24579 Mon Sep 17 00:00:00 2001 From: Shanoah Alkire Date: Sat, 6 Oct 2018 20:01:23 -0700 Subject: [PATCH] Onepad-legacy: Even if std is used all over the place, lets not put the entire project in std's namespace. --- plugins/onepad_legacy/GamePad.cpp | 4 ++-- plugins/onepad_legacy/GamePad.h | 10 +++++----- plugins/onepad_legacy/Linux/dialog.cpp | 4 ++-- plugins/onepad_legacy/Linux/ini.cpp | 6 +++--- plugins/onepad_legacy/Linux/linux.cpp | 8 ++++---- plugins/onepad_legacy/Linux/linux.h | 2 +- plugins/onepad_legacy/SDL/joystick.cpp | 10 +++++----- plugins/onepad_legacy/SDL/joystick.h | 2 +- plugins/onepad_legacy/controller.cpp | 2 +- plugins/onepad_legacy/controller.h | 2 +- plugins/onepad_legacy/onepad.cpp | 2 +- plugins/onepad_legacy/onepad.h | 3 +-- 12 files changed, 27 insertions(+), 28 deletions(-) diff --git a/plugins/onepad_legacy/GamePad.cpp b/plugins/onepad_legacy/GamePad.cpp index 0d0b8158dc..3f27aadc1f 100644 --- a/plugins/onepad_legacy/GamePad.cpp +++ b/plugins/onepad_legacy/GamePad.cpp @@ -3,7 +3,7 @@ #include "SDL/joystick.h" #endif -vector s_vgamePad; +std::vector s_vgamePad; bool GamePadIdWithinBounds(int GamePadId) { return ((GamePadId >= 0) && (GamePadId < (int)s_vgamePad.size())); @@ -17,7 +17,7 @@ bool GamePadIdWithinBounds(int GamePadId) /** * Find every interesting devices and create right structure for them(depend on backend) **/ -void GamePad::EnumerateGamePads(vector &vgamePad) +void GamePad::EnumerateGamePads(std::vector &vgamePad) { #ifdef SDL_BUILD JoystickInfo::EnumerateJoysticks(vgamePad); diff --git a/plugins/onepad_legacy/GamePad.h b/plugins/onepad_legacy/GamePad.h index 030b66a0b3..56d7a03bc8 100644 --- a/plugins/onepad_legacy/GamePad.h +++ b/plugins/onepad_legacy/GamePad.h @@ -38,7 +38,7 @@ public: /** * Find every interesting devices and create right structure for them(depend on backend) **/ - static void EnumerateGamePads(vector &vgamePad); + static void EnumerateGamePads(std::vector &vgamePad); static void UpdateReleaseState(); /** * Update state of every attached devices @@ -76,7 +76,7 @@ public: return 0; } - const string &GetName() + const std::string &GetName() { return devname; } @@ -143,13 +143,13 @@ public: virtual int GetAxisFromKey(int pad, int index) { return 0; } // These fields need to be inherited by child classes protected: - string devname; // pretty device name + std::string devname; // pretty device name int _id; int numbuttons, numaxes, numhats; int deadzone; int pad; - vector vbuttonstate, vaxisstate, vhatstate; + std::vector vbuttonstate, vaxisstate, vhatstate; }; -extern vector s_vgamePad; +extern std::vector s_vgamePad; extern bool GamePadIdWithinBounds(int joyid); diff --git a/plugins/onepad_legacy/Linux/dialog.cpp b/plugins/onepad_legacy/Linux/dialog.cpp index 7dc220ddb8..ecb3482cd8 100644 --- a/plugins/onepad_legacy/Linux/dialog.cpp +++ b/plugins/onepad_legacy/Linux/dialog.cpp @@ -534,7 +534,7 @@ void Dialog::config_key(int pad, int key) // I don't have any guarantee that not-yet-pressed state is egual to released state GamePad::UpdateReleaseState(); while (!captured) { - vector::iterator itjoy; + std::vector::iterator itjoy; if (PollX11KeyboardMouseEvent(key_pressed)) { // special case for keyboard/mouse to handle multiple keys // Note: key_pressed == 0 when ESC is hit to abort the capture @@ -615,7 +615,7 @@ void Dialog::repopulate() } // keyboard/mouse key - map::iterator it; + std::map::iterator it; for (it = conf->keysym_map[gamepad_id].begin(); it != conf->keysym_map[gamepad_id].end(); ++it) { int keysym = it->first; diff --git a/plugins/onepad_legacy/Linux/ini.cpp b/plugins/onepad_legacy/Linux/ini.cpp index 3431abfc0f..23d0546169 100644 --- a/plugins/onepad_legacy/Linux/ini.cpp +++ b/plugins/onepad_legacy/Linux/ini.cpp @@ -28,9 +28,9 @@ extern std::string s_strIniPath; -string KeyName(int pad, int key, int keysym) +std::string KeyName(int pad, int key, int keysym) { - string tmp; + std::string tmp; tmp.resize(28); if (keysym) { @@ -141,7 +141,7 @@ void SaveConfig() } } - map::iterator it; + std::map::iterator it; for (int pad = 0; pad < GAMEPAD_NUMBER; pad++) for (it = conf->keysym_map[pad].begin(); it != conf->keysym_map[pad].end(); ++it) fprintf(f, "PAD %d:KEYSYM 0x%x = %d\n", pad, it->first, it->second); diff --git a/plugins/onepad_legacy/Linux/linux.cpp b/plugins/onepad_legacy/Linux/linux.cpp index 43f6b27820..0e7bbf4416 100644 --- a/plugins/onepad_legacy/Linux/linux.cpp +++ b/plugins/onepad_legacy/Linux/linux.cpp @@ -78,7 +78,7 @@ void _PADclose() { SetAutoRepeat(true); - vector::iterator it = s_vgamePad.begin(); + std::vector::iterator it = s_vgamePad.begin(); // Delete everything in the vector vjoysticks. while (it != s_vgamePad.end()) { @@ -138,15 +138,15 @@ void PollForJoystickInput(int cpad) if (full_axis) { value += 0x8000; if (value > gamePad->GetDeadzone()) - key_status->press(cpad, i, min(value / 256, 0xFF)); + key_status->press(cpad, i, std::min(value / 256, 0xFF)); else key_status->release(cpad, i); } else { if (sign && (-value > gamePad->GetDeadzone())) - key_status->press(cpad, i, min(-value / 128, 0xFF)); + key_status->press(cpad, i, std::min(-value / 128, 0xFF)); else if (!sign && (value > gamePad->GetDeadzone())) - key_status->press(cpad, i, min(value / 128, 0xFF)); + key_status->press(cpad, i, std::min(value / 128, 0xFF)); else key_status->release(cpad, i); } diff --git a/plugins/onepad_legacy/Linux/linux.h b/plugins/onepad_legacy/Linux/linux.h index 4671aff0ea..99be035bb5 100644 --- a/plugins/onepad_legacy/Linux/linux.h +++ b/plugins/onepad_legacy/Linux/linux.h @@ -22,5 +22,5 @@ #ifndef __LINUX_H__ #define __LINUX_H__ extern void DisplayDialog(); -extern string KeyName(int pad, int key, int keysym = 0); +extern std::string KeyName(int pad, int key, int keysym = 0); #endif diff --git a/plugins/onepad_legacy/SDL/joystick.cpp b/plugins/onepad_legacy/SDL/joystick.cpp index 12d9cbae25..96fce469bd 100644 --- a/plugins/onepad_legacy/SDL/joystick.cpp +++ b/plugins/onepad_legacy/SDL/joystick.cpp @@ -30,7 +30,7 @@ static u32 s_bSDLInit = false; void JoystickInfo::UpdateReleaseState() { - vector::iterator itjoy = s_vgamePad.begin(); + std::vector::iterator itjoy = s_vgamePad.begin(); SDL_JoystickUpdate(); @@ -42,7 +42,7 @@ void JoystickInfo::UpdateReleaseState() } // opens handles to all possible joysticks -void JoystickInfo::EnumerateJoysticks(vector &vjoysticks) +void JoystickInfo::EnumerateJoysticks(std::vector &vjoysticks) { if (!s_bSDLInit) { @@ -64,7 +64,7 @@ void JoystickInfo::EnumerateJoysticks(vector &vjoysticks) s_bSDLInit = true; } - vector::iterator it = vjoysticks.begin(); + std::vector::iterator it = vjoysticks.begin(); // Delete everything in the vector vjoysticks. while (it != vjoysticks.end()) { @@ -201,7 +201,7 @@ bool JoystickInfo::Init(int id) auto found_hack = devname.find("PLAYSTATION(R)3"); // FIXME: people need to restart the plugin to take the option into account. bool hack_enabled = (conf->pad_options[0].sixaxis_pressure) || (conf->pad_options[1].sixaxis_pressure); - if (found_hack != string::npos && numaxes > 4 && hack_enabled) { + if (found_hack != std::string::npos && numaxes > 4 && hack_enabled) { numbuttons = 4; // (select, start, l3, r3) // Enable this hack in bluetooth too. It avoid to restart the onepad gui numbuttons += 4; // the 4 hat buttons @@ -280,7 +280,7 @@ bool JoystickInfo::PollAxes(u32 &pkey) for (int i = 0; i < GetNumAxes(); ++i) { // Sixaxis, dualshock3 hack - if (found_hack != string::npos) { + if (found_hack != std::string::npos) { // The analog mode of the hat button is quite erratic. Values can be in half- axis // or full axis... So better keep them as button for the moment -- gregory if (i >= 8 && i <= 11 && (conf->pad_options[pad].sixaxis_usb)) diff --git a/plugins/onepad_legacy/SDL/joystick.h b/plugins/onepad_legacy/SDL/joystick.h index fe76c38a3e..e16a547201 100644 --- a/plugins/onepad_legacy/SDL/joystick.h +++ b/plugins/onepad_legacy/SDL/joystick.h @@ -56,7 +56,7 @@ public: void Destroy(); // opens handles to all possible joysticks - static void EnumerateJoysticks(vector &vjoysticks); + static void EnumerateJoysticks(std::vector &vjoysticks); void Rumble(int type, int pad); diff --git a/plugins/onepad_legacy/controller.cpp b/plugins/onepad_legacy/controller.cpp index 09badfb5ed..c1703830c6 100644 --- a/plugins/onepad_legacy/controller.cpp +++ b/plugins/onepad_legacy/controller.cpp @@ -31,7 +31,7 @@ __forceinline int get_keyboard_key(int pad, int keysym) { // You must use find instead of [] // [] will create an element if the key does not exist and return 0 - map::iterator it = conf->keysym_map[pad].find(keysym); + std::map::iterator it = conf->keysym_map[pad].find(keysym); if (it != conf->keysym_map[pad].end()) return it->second; else diff --git a/plugins/onepad_legacy/controller.h b/plugins/onepad_legacy/controller.h index 4c35a29533..b470fdd532 100644 --- a/plugins/onepad_legacy/controller.h +++ b/plugins/onepad_legacy/controller.h @@ -76,7 +76,7 @@ public: u32 keys[GAMEPAD_NUMBER][MAX_KEYS]; u32 log; u32 joyid_map; - map keysym_map[GAMEPAD_NUMBER]; + std::map keysym_map[GAMEPAD_NUMBER]; PADconf() { init(); } diff --git a/plugins/onepad_legacy/onepad.cpp b/plugins/onepad_legacy/onepad.cpp index add8c38f0d..944abef7fc 100644 --- a/plugins/onepad_legacy/onepad.cpp +++ b/plugins/onepad_legacy/onepad.cpp @@ -57,7 +57,7 @@ pthread_spinlock_t mutex_KeyEvent; bool mutex_WasInit = false; KeyStatus *key_status = NULL; -queue ev_fifo; +std::queue ev_fifo; static void InitLibraryName() { diff --git a/plugins/onepad_legacy/onepad.h b/plugins/onepad_legacy/onepad.h index d4840e0512..ae55e82ec2 100644 --- a/plugins/onepad_legacy/onepad.h +++ b/plugins/onepad_legacy/onepad.h @@ -44,7 +44,6 @@ #include #include #include -using namespace std; #define PADdefs #include "PS2Edefs.h" @@ -123,7 +122,7 @@ enum gamePadValues { }; extern keyEvent event; -extern queue ev_fifo; +extern std::queue ev_fifo; extern pthread_spinlock_t mutex_KeyEvent; void clearPAD(int pad);