mirror of https://github.com/PCSX2/pcsx2.git
onepad: plug uid instead of the index
ini must be recreated
This commit is contained in:
parent
3cff588eff
commit
31d8142a0d
|
@ -5,11 +5,6 @@
|
||||||
|
|
||||||
std::vector<std::unique_ptr<GamePad>> s_vgamePad;
|
std::vector<std::unique_ptr<GamePad>> s_vgamePad;
|
||||||
|
|
||||||
bool GamePadIdWithinBounds(int GamePadId)
|
|
||||||
{
|
|
||||||
return ((GamePadId >= 0) && (GamePadId < (int)s_vgamePad.size()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Following static methods are just forwarders to their backend
|
* Following static methods are just forwarders to their backend
|
||||||
* This is where link between agnostic and specific code is done
|
* This is where link between agnostic and specific code is done
|
||||||
|
@ -30,10 +25,9 @@ void GamePad::EnumerateGamePads(std::vector<std::unique_ptr<GamePad>> &vgamePad)
|
||||||
**/
|
**/
|
||||||
void GamePad::DoRumble(unsigned type, unsigned pad)
|
void GamePad::DoRumble(unsigned type, unsigned pad)
|
||||||
{
|
{
|
||||||
u32 id = conf->get_joyid(pad);
|
int index = uid_to_index(conf->get_joy_uid(pad));
|
||||||
if (GamePadIdWithinBounds(id)) {
|
if (index >= 0)
|
||||||
s_vgamePad[id]->Rumble(type, pad);
|
s_vgamePad[index]->Rumble(type, pad);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t GamePad::index_to_uid(int index)
|
size_t GamePad::index_to_uid(int index)
|
||||||
|
|
|
@ -73,4 +73,3 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
extern std::vector<std::unique_ptr<GamePad>> s_vgamePad;
|
extern std::vector<std::unique_ptr<GamePad>> s_vgamePad;
|
||||||
extern bool GamePadIdWithinBounds(int joyid);
|
|
||||||
|
|
|
@ -92,8 +92,9 @@ void SaveConfig()
|
||||||
fprintf(f, "log = %d\n", conf->log);
|
fprintf(f, "log = %d\n", conf->log);
|
||||||
fprintf(f, "options = %d\n", conf->packed_options);
|
fprintf(f, "options = %d\n", conf->packed_options);
|
||||||
fprintf(f, "mouse_sensibility = %d\n", conf->get_sensibility());
|
fprintf(f, "mouse_sensibility = %d\n", conf->get_sensibility());
|
||||||
fprintf(f, "joy_pad_map = %d\n", conf->joyid_map);
|
|
||||||
fprintf(f, "ff_intensity = %d\n", conf->get_ff_intensity());
|
fprintf(f, "ff_intensity = %d\n", conf->get_ff_intensity());
|
||||||
|
fprintf(f, "uid[0] = %zu\n", conf->get_joy_uid(0));
|
||||||
|
fprintf(f, "uid[1] = %zu\n", conf->get_joy_uid(1));
|
||||||
|
|
||||||
for (int pad = 0; pad < GAMEPAD_NUMBER; pad++)
|
for (int pad = 0; pad < GAMEPAD_NUMBER; pad++)
|
||||||
for (auto const &it : conf->keysym_map[pad])
|
for (auto const &it : conf->keysym_map[pad])
|
||||||
|
@ -130,15 +131,15 @@ void LoadConfig()
|
||||||
if (fscanf(f, "mouse_sensibility = %u\n", &value) == 0)
|
if (fscanf(f, "mouse_sensibility = %u\n", &value) == 0)
|
||||||
goto error;
|
goto error;
|
||||||
conf->set_sensibility(value);
|
conf->set_sensibility(value);
|
||||||
if (fscanf(f, "joy_pad_map = %u\n", &value) == 0)
|
|
||||||
goto error;
|
|
||||||
// Value is now hardcoded in controller.h avoid to reload a bad
|
|
||||||
// value from an old ini file.
|
|
||||||
//conf->joyid_map = value;
|
|
||||||
if (fscanf(f, "ff_intensity = %u\n", &value) == 0)
|
if (fscanf(f, "ff_intensity = %u\n", &value) == 0)
|
||||||
goto error;
|
goto error;
|
||||||
conf->set_ff_intensity(value);
|
conf->set_ff_intensity(value);
|
||||||
|
|
||||||
|
size_t uid;
|
||||||
|
if (fscanf(f, "uid[0] = %zu\n", &uid) == 1)
|
||||||
|
conf->set_joy_uid(0, uid);
|
||||||
|
if (fscanf(f, "uid[1] = %zu\n", &uid) == 1)
|
||||||
|
conf->set_joy_uid(1, uid);
|
||||||
|
|
||||||
u32 pad;
|
u32 pad;
|
||||||
u32 keysym;
|
u32 keysym;
|
||||||
|
|
|
@ -83,11 +83,11 @@ void _PADclose()
|
||||||
|
|
||||||
void PollForJoystickInput(int cpad)
|
void PollForJoystickInput(int cpad)
|
||||||
{
|
{
|
||||||
int joyid = conf->get_joyid(cpad);
|
int index = GamePad::uid_to_index(conf->get_joy_uid(cpad));
|
||||||
if (!GamePadIdWithinBounds(joyid))
|
if (index < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto &gamePad = s_vgamePad[joyid];
|
auto &gamePad = s_vgamePad[index];
|
||||||
|
|
||||||
gamePad->UpdateGamePadState();
|
gamePad->UpdateGamePadState();
|
||||||
|
|
||||||
|
|
|
@ -50,33 +50,34 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
u32 log;
|
u32 log;
|
||||||
u32 joyid_map;
|
|
||||||
map<u32, u32> keysym_map[GAMEPAD_NUMBER];
|
map<u32, u32> keysym_map[GAMEPAD_NUMBER];
|
||||||
|
std::array<size_t, GAMEPAD_NUMBER> unique_id;
|
||||||
|
|
||||||
PADconf() { init(); }
|
PADconf() { init(); }
|
||||||
|
|
||||||
void init()
|
void init()
|
||||||
{
|
{
|
||||||
log = packed_options = joyid_map = 0;
|
log = packed_options = 0;
|
||||||
ff_intensity = 0x7FFF; // set it at max value by default
|
ff_intensity = 0x7FFF; // set it at max value by default
|
||||||
sensibility = 500;
|
sensibility = 500;
|
||||||
for (int pad = 0; pad < GAMEPAD_NUMBER; pad++) {
|
for (int pad = 0; pad < GAMEPAD_NUMBER; pad++) {
|
||||||
keysym_map[pad].clear();
|
keysym_map[pad].clear();
|
||||||
set_joyid((u32)pad, (u32)pad); // define id mapping for each gamepad
|
|
||||||
}
|
}
|
||||||
|
unique_id.fill(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_joyid(u32 pad, u32 joy_id)
|
void set_joy_uid(u32 pad, size_t uid)
|
||||||
{
|
{
|
||||||
int shift = 8 * pad;
|
if (pad < GAMEPAD_NUMBER)
|
||||||
joyid_map &= ~(0xFF << shift); // clear
|
unique_id[pad] = uid;
|
||||||
joyid_map |= (joy_id & 0xFF) << shift; // set
|
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 get_joyid(u32 pad)
|
size_t get_joy_uid(u32 pad)
|
||||||
{
|
{
|
||||||
int shift = 8 * pad;
|
if (pad < GAMEPAD_NUMBER)
|
||||||
return ((joyid_map >> shift) & 0xFF);
|
return unique_id[pad];
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue