Onepad-legacy: Even if std is used all over the place, lets not put the entire project in std's namespace.

This commit is contained in:
Shanoah Alkire 2018-10-06 20:01:23 -07:00
parent e44fc33d48
commit f800ed9c2e
12 changed files with 27 additions and 28 deletions

View File

@ -3,7 +3,7 @@
#include "SDL/joystick.h"
#endif
vector<GamePad *> s_vgamePad;
std::vector<GamePad *> 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<GamePad *> &vgamePad)
void GamePad::EnumerateGamePads(std::vector<GamePad *> &vgamePad)
{
#ifdef SDL_BUILD
JoystickInfo::EnumerateJoysticks(vgamePad);

View File

@ -38,7 +38,7 @@ public:
/**
* Find every interesting devices and create right structure for them(depend on backend)
**/
static void EnumerateGamePads(vector<GamePad *> &vgamePad);
static void EnumerateGamePads(std::vector<GamePad *> &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<int> vbuttonstate, vaxisstate, vhatstate;
std::vector<int> vbuttonstate, vaxisstate, vhatstate;
};
extern vector<GamePad *> s_vgamePad;
extern std::vector<GamePad *> s_vgamePad;
extern bool GamePadIdWithinBounds(int joyid);

View File

@ -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<GamePad *>::iterator itjoy;
std::vector<GamePad *>::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<u32, u32>::iterator it;
std::map<u32, u32>::iterator it;
for (it = conf->keysym_map[gamepad_id].begin();
it != conf->keysym_map[gamepad_id].end(); ++it) {
int keysym = it->first;

View File

@ -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<u32, u32>::iterator it;
std::map<u32, u32>::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);

View File

@ -78,7 +78,7 @@ void _PADclose()
{
SetAutoRepeat(true);
vector<GamePad *>::iterator it = s_vgamePad.begin();
std::vector<GamePad *>::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);
}

View File

@ -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

View File

@ -30,7 +30,7 @@ static u32 s_bSDLInit = false;
void JoystickInfo::UpdateReleaseState()
{
vector<GamePad *>::iterator itjoy = s_vgamePad.begin();
std::vector<GamePad *>::iterator itjoy = s_vgamePad.begin();
SDL_JoystickUpdate();
@ -42,7 +42,7 @@ void JoystickInfo::UpdateReleaseState()
}
// opens handles to all possible joysticks
void JoystickInfo::EnumerateJoysticks(vector<GamePad *> &vjoysticks)
void JoystickInfo::EnumerateJoysticks(std::vector<GamePad *> &vjoysticks)
{
if (!s_bSDLInit) {
@ -64,7 +64,7 @@ void JoystickInfo::EnumerateJoysticks(vector<GamePad *> &vjoysticks)
s_bSDLInit = true;
}
vector<GamePad *>::iterator it = vjoysticks.begin();
std::vector<GamePad *>::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))

View File

@ -56,7 +56,7 @@ public:
void Destroy();
// opens handles to all possible joysticks
static void EnumerateJoysticks(vector<GamePad *> &vjoysticks);
static void EnumerateJoysticks(std::vector<GamePad *> &vjoysticks);
void Rumble(int type, int pad);

View File

@ -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<u32, u32>::iterator it = conf->keysym_map[pad].find(keysym);
std::map<u32, u32>::iterator it = conf->keysym_map[pad].find(keysym);
if (it != conf->keysym_map[pad].end())
return it->second;
else

View File

@ -76,7 +76,7 @@ public:
u32 keys[GAMEPAD_NUMBER][MAX_KEYS];
u32 log;
u32 joyid_map;
map<u32, u32> keysym_map[GAMEPAD_NUMBER];
std::map<u32, u32> keysym_map[GAMEPAD_NUMBER];
PADconf() { init(); }

View File

@ -57,7 +57,7 @@ pthread_spinlock_t mutex_KeyEvent;
bool mutex_WasInit = false;
KeyStatus *key_status = NULL;
queue<keyEvent> ev_fifo;
std::queue<keyEvent> ev_fifo;
static void InitLibraryName()
{

View File

@ -44,7 +44,6 @@
#include <map>
#include <string>
#include <pthread.h>
using namespace std;
#define PADdefs
#include "PS2Edefs.h"
@ -123,7 +122,7 @@ enum gamePadValues {
};
extern keyEvent event;
extern queue<keyEvent> ev_fifo;
extern std::queue<keyEvent> ev_fifo;
extern pthread_spinlock_t mutex_KeyEvent;
void clearPAD(int pad);