mirror of https://github.com/PCSX2/pcsx2.git
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:
parent
e44fc33d48
commit
f800ed9c2e
|
@ -3,7 +3,7 @@
|
||||||
#include "SDL/joystick.h"
|
#include "SDL/joystick.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
vector<GamePad *> s_vgamePad;
|
std::vector<GamePad *> s_vgamePad;
|
||||||
bool GamePadIdWithinBounds(int GamePadId)
|
bool GamePadIdWithinBounds(int GamePadId)
|
||||||
{
|
{
|
||||||
return ((GamePadId >= 0) && (GamePadId < (int)s_vgamePad.size()));
|
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)
|
* 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
|
#ifdef SDL_BUILD
|
||||||
JoystickInfo::EnumerateJoysticks(vgamePad);
|
JoystickInfo::EnumerateJoysticks(vgamePad);
|
||||||
|
|
|
@ -38,7 +38,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Find every interesting devices and create right structure for them(depend on backend)
|
* 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();
|
static void UpdateReleaseState();
|
||||||
/**
|
/**
|
||||||
* Update state of every attached devices
|
* Update state of every attached devices
|
||||||
|
@ -76,7 +76,7 @@ public:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const string &GetName()
|
const std::string &GetName()
|
||||||
{
|
{
|
||||||
return devname;
|
return devname;
|
||||||
}
|
}
|
||||||
|
@ -143,13 +143,13 @@ public:
|
||||||
virtual int GetAxisFromKey(int pad, int index) { return 0; }
|
virtual int GetAxisFromKey(int pad, int index) { return 0; }
|
||||||
// These fields need to be inherited by child classes
|
// These fields need to be inherited by child classes
|
||||||
protected:
|
protected:
|
||||||
string devname; // pretty device name
|
std::string devname; // pretty device name
|
||||||
int _id;
|
int _id;
|
||||||
int numbuttons, numaxes, numhats;
|
int numbuttons, numaxes, numhats;
|
||||||
int deadzone;
|
int deadzone;
|
||||||
int pad;
|
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);
|
extern bool GamePadIdWithinBounds(int joyid);
|
||||||
|
|
|
@ -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
|
// I don't have any guarantee that not-yet-pressed state is egual to released state
|
||||||
GamePad::UpdateReleaseState();
|
GamePad::UpdateReleaseState();
|
||||||
while (!captured) {
|
while (!captured) {
|
||||||
vector<GamePad *>::iterator itjoy;
|
std::vector<GamePad *>::iterator itjoy;
|
||||||
if (PollX11KeyboardMouseEvent(key_pressed)) {
|
if (PollX11KeyboardMouseEvent(key_pressed)) {
|
||||||
// special case for keyboard/mouse to handle multiple keys
|
// special case for keyboard/mouse to handle multiple keys
|
||||||
// Note: key_pressed == 0 when ESC is hit to abort the capture
|
// Note: key_pressed == 0 when ESC is hit to abort the capture
|
||||||
|
@ -615,7 +615,7 @@ void Dialog::repopulate()
|
||||||
}
|
}
|
||||||
|
|
||||||
// keyboard/mouse key
|
// keyboard/mouse key
|
||||||
map<u32, u32>::iterator it;
|
std::map<u32, u32>::iterator it;
|
||||||
for (it = conf->keysym_map[gamepad_id].begin();
|
for (it = conf->keysym_map[gamepad_id].begin();
|
||||||
it != conf->keysym_map[gamepad_id].end(); ++it) {
|
it != conf->keysym_map[gamepad_id].end(); ++it) {
|
||||||
int keysym = it->first;
|
int keysym = it->first;
|
||||||
|
|
|
@ -28,9 +28,9 @@
|
||||||
|
|
||||||
extern std::string s_strIniPath;
|
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);
|
tmp.resize(28);
|
||||||
|
|
||||||
if (keysym) {
|
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 (int pad = 0; pad < GAMEPAD_NUMBER; pad++)
|
||||||
for (it = conf->keysym_map[pad].begin(); it != conf->keysym_map[pad].end(); ++it)
|
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);
|
fprintf(f, "PAD %d:KEYSYM 0x%x = %d\n", pad, it->first, it->second);
|
||||||
|
|
|
@ -78,7 +78,7 @@ void _PADclose()
|
||||||
{
|
{
|
||||||
SetAutoRepeat(true);
|
SetAutoRepeat(true);
|
||||||
|
|
||||||
vector<GamePad *>::iterator it = s_vgamePad.begin();
|
std::vector<GamePad *>::iterator it = s_vgamePad.begin();
|
||||||
|
|
||||||
// Delete everything in the vector vjoysticks.
|
// Delete everything in the vector vjoysticks.
|
||||||
while (it != s_vgamePad.end()) {
|
while (it != s_vgamePad.end()) {
|
||||||
|
@ -138,15 +138,15 @@ void PollForJoystickInput(int cpad)
|
||||||
if (full_axis) {
|
if (full_axis) {
|
||||||
value += 0x8000;
|
value += 0x8000;
|
||||||
if (value > gamePad->GetDeadzone())
|
if (value > gamePad->GetDeadzone())
|
||||||
key_status->press(cpad, i, min(value / 256, 0xFF));
|
key_status->press(cpad, i, std::min(value / 256, 0xFF));
|
||||||
else
|
else
|
||||||
key_status->release(cpad, i);
|
key_status->release(cpad, i);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (sign && (-value > gamePad->GetDeadzone()))
|
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()))
|
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
|
else
|
||||||
key_status->release(cpad, i);
|
key_status->release(cpad, i);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,5 +22,5 @@
|
||||||
#ifndef __LINUX_H__
|
#ifndef __LINUX_H__
|
||||||
#define __LINUX_H__
|
#define __LINUX_H__
|
||||||
extern void DisplayDialog();
|
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
|
#endif
|
||||||
|
|
|
@ -30,7 +30,7 @@ static u32 s_bSDLInit = false;
|
||||||
|
|
||||||
void JoystickInfo::UpdateReleaseState()
|
void JoystickInfo::UpdateReleaseState()
|
||||||
{
|
{
|
||||||
vector<GamePad *>::iterator itjoy = s_vgamePad.begin();
|
std::vector<GamePad *>::iterator itjoy = s_vgamePad.begin();
|
||||||
|
|
||||||
SDL_JoystickUpdate();
|
SDL_JoystickUpdate();
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ void JoystickInfo::UpdateReleaseState()
|
||||||
}
|
}
|
||||||
|
|
||||||
// opens handles to all possible joysticks
|
// opens handles to all possible joysticks
|
||||||
void JoystickInfo::EnumerateJoysticks(vector<GamePad *> &vjoysticks)
|
void JoystickInfo::EnumerateJoysticks(std::vector<GamePad *> &vjoysticks)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!s_bSDLInit) {
|
if (!s_bSDLInit) {
|
||||||
|
@ -64,7 +64,7 @@ void JoystickInfo::EnumerateJoysticks(vector<GamePad *> &vjoysticks)
|
||||||
s_bSDLInit = true;
|
s_bSDLInit = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<GamePad *>::iterator it = vjoysticks.begin();
|
std::vector<GamePad *>::iterator it = vjoysticks.begin();
|
||||||
|
|
||||||
// Delete everything in the vector vjoysticks.
|
// Delete everything in the vector vjoysticks.
|
||||||
while (it != vjoysticks.end()) {
|
while (it != vjoysticks.end()) {
|
||||||
|
@ -201,7 +201,7 @@ bool JoystickInfo::Init(int id)
|
||||||
auto found_hack = devname.find("PLAYSTATION(R)3");
|
auto found_hack = devname.find("PLAYSTATION(R)3");
|
||||||
// FIXME: people need to restart the plugin to take the option into account.
|
// 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);
|
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)
|
numbuttons = 4; // (select, start, l3, r3)
|
||||||
// Enable this hack in bluetooth too. It avoid to restart the onepad gui
|
// Enable this hack in bluetooth too. It avoid to restart the onepad gui
|
||||||
numbuttons += 4; // the 4 hat buttons
|
numbuttons += 4; // the 4 hat buttons
|
||||||
|
@ -280,7 +280,7 @@ bool JoystickInfo::PollAxes(u32 &pkey)
|
||||||
|
|
||||||
for (int i = 0; i < GetNumAxes(); ++i) {
|
for (int i = 0; i < GetNumAxes(); ++i) {
|
||||||
// Sixaxis, dualshock3 hack
|
// 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
|
// 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
|
// or full axis... So better keep them as button for the moment -- gregory
|
||||||
if (i >= 8 && i <= 11 && (conf->pad_options[pad].sixaxis_usb))
|
if (i >= 8 && i <= 11 && (conf->pad_options[pad].sixaxis_usb))
|
||||||
|
|
|
@ -56,7 +56,7 @@ public:
|
||||||
|
|
||||||
void Destroy();
|
void Destroy();
|
||||||
// opens handles to all possible joysticks
|
// 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);
|
void Rumble(int type, int pad);
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ __forceinline int get_keyboard_key(int pad, int keysym)
|
||||||
{
|
{
|
||||||
// You must use find instead of []
|
// You must use find instead of []
|
||||||
// [] will create an element if the key does not exist and return 0
|
// [] 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())
|
if (it != conf->keysym_map[pad].end())
|
||||||
return it->second;
|
return it->second;
|
||||||
else
|
else
|
||||||
|
|
|
@ -76,7 +76,7 @@ public:
|
||||||
u32 keys[GAMEPAD_NUMBER][MAX_KEYS];
|
u32 keys[GAMEPAD_NUMBER][MAX_KEYS];
|
||||||
u32 log;
|
u32 log;
|
||||||
u32 joyid_map;
|
u32 joyid_map;
|
||||||
map<u32, u32> keysym_map[GAMEPAD_NUMBER];
|
std::map<u32, u32> keysym_map[GAMEPAD_NUMBER];
|
||||||
|
|
||||||
PADconf() { init(); }
|
PADconf() { init(); }
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ pthread_spinlock_t mutex_KeyEvent;
|
||||||
bool mutex_WasInit = false;
|
bool mutex_WasInit = false;
|
||||||
KeyStatus *key_status = NULL;
|
KeyStatus *key_status = NULL;
|
||||||
|
|
||||||
queue<keyEvent> ev_fifo;
|
std::queue<keyEvent> ev_fifo;
|
||||||
|
|
||||||
static void InitLibraryName()
|
static void InitLibraryName()
|
||||||
{
|
{
|
||||||
|
|
|
@ -44,7 +44,6 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
#define PADdefs
|
#define PADdefs
|
||||||
#include "PS2Edefs.h"
|
#include "PS2Edefs.h"
|
||||||
|
@ -123,7 +122,7 @@ enum gamePadValues {
|
||||||
};
|
};
|
||||||
|
|
||||||
extern keyEvent event;
|
extern keyEvent event;
|
||||||
extern queue<keyEvent> ev_fifo;
|
extern std::queue<keyEvent> ev_fifo;
|
||||||
extern pthread_spinlock_t mutex_KeyEvent;
|
extern pthread_spinlock_t mutex_KeyEvent;
|
||||||
|
|
||||||
void clearPAD(int pad);
|
void clearPAD(int pad);
|
||||||
|
|
Loading…
Reference in New Issue