1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 10:42:36 +01:00

Fixes evdev settings & multiple pads handling

This commit is contained in:
RipleyTom 2019-11-05 17:34:04 +01:00 committed by Ivan
parent af0bd7136d
commit 4ff6acf6ba
2 changed files with 14 additions and 6 deletions

View File

@ -256,11 +256,11 @@ std::unordered_map<u64, std::pair<u16, bool>> evdev_joystick_handler::GetButtonV
std::shared_ptr<evdev_joystick_handler::EvdevDevice> evdev_joystick_handler::get_evdev_device(const std::string& device)
{
// Add device if not yet present
m_pad_index = add_device(device, nullptr, true);
if (m_pad_index < 0)
int pad_index = add_device(device, nullptr, true);
if (pad_index < 0)
return nullptr;
auto dev = bindings[m_pad_index];
auto dev = bindings[pad_index];
// Check if our device is connected
if (!update_device(dev.first))
@ -611,8 +611,8 @@ std::vector<std::string> evdev_joystick_handler::ListDevices()
int evdev_joystick_handler::add_device(const std::string& device, const std::shared_ptr<Pad>& pad, bool in_settings)
{
if (in_settings && m_pad_index >= 0)
return m_pad_index;
if (in_settings && settings_added.count(device))
return settings_added.at(device);
// Now we need to find the device with the same name, and make sure not to grab any duplicates.
std::unordered_map<std::string, u32> unique_names;
@ -662,6 +662,12 @@ int evdev_joystick_handler::add_device(const std::string& device, const std::sha
continue;
}
if (in_settings)
{
m_dev = std::make_shared<EvdevDevice>();
settings_added[device] = bindings.size();
}
// Alright, now that we've confirmed we haven't added this joystick yet, les do dis.
m_dev->device = dev;
m_dev->path = path;
@ -881,6 +887,8 @@ bool evdev_joystick_handler::bindPadToDevice(std::shared_ptr<Pad> pad, const std
int i = 0; // increment to know the axis location (17-24). Be careful if you ever add more find_key() calls in here (BUTTON_COUNT = 17)
int last_type = EV_ABS;
m_dev = std::make_shared<EvdevDevice>();
int index = static_cast<int>(bindings.size());
m_pad_configs[index].load();
m_dev->config = &m_pad_configs[index];

View File

@ -355,7 +355,7 @@ private:
positive_axis m_pos_axis_config;
std::vector<u32> m_positive_axis;
std::vector<std::string> blacklist;
int m_pad_index = -1;
std::unordered_map<std::string, int> settings_added;
std::shared_ptr<EvdevDevice> m_dev;
bool m_is_button_or_trigger;
bool m_is_negative;