From 9b4868f0170f1628fb7b1158d4ab4173e8093004 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sat, 13 Jan 2018 00:55:51 +0100 Subject: [PATCH] Input: init pads as disconnected inlcudes simpsons "hack" as comment --- rpcs3/ds4_pad_handler.cpp | 7 ++++--- rpcs3/evdev_joystick_handler.cpp | 31 +++++++++++-------------------- rpcs3/evdev_joystick_handler.h | 4 ++-- rpcs3/keyboard_pad_handler.cpp | 15 +++++++++++++-- rpcs3/mm_joystick_handler.cpp | 2 +- rpcs3/xinput_pad_handler.cpp | 2 +- 6 files changed, 32 insertions(+), 29 deletions(-) diff --git a/rpcs3/ds4_pad_handler.cpp b/rpcs3/ds4_pad_handler.cpp index 97ef7e84f7..8504977e56 100644 --- a/rpcs3/ds4_pad_handler.cpp +++ b/rpcs3/ds4_pad_handler.cpp @@ -789,7 +789,7 @@ bool ds4_pad_handler::bindPadToDevice(std::shared_ptr pad, const std::strin pad->Init ( - CELL_PAD_STATUS_CONNECTED | CELL_PAD_STATUS_ASSIGN_CHANGES, + CELL_PAD_STATUS_DISCONNECTED, CELL_PAD_SETTING_PRESS_OFF | CELL_PAD_SETTING_SENSOR_OFF, CELL_PAD_CAPABILITY_PS3_CONFORMITY | CELL_PAD_CAPABILITY_PRESS_MODE | CELL_PAD_CAPABILITY_HP_ANALOG_STICK | CELL_PAD_CAPABILITY_ACTUATOR | CELL_PAD_CAPABILITY_SENSOR_MODE, CELL_PAD_DEV_TYPE_STANDARD @@ -855,7 +855,7 @@ void ds4_pad_handler::ThreadProc() } hid_set_nonblocking(dev, 1); m_dev->hidDevice = dev; - thepad->m_port_status = CELL_PAD_STATUS_CONNECTED|CELL_PAD_STATUS_ASSIGN_CHANGES; + thepad->m_port_status = CELL_PAD_STATUS_CONNECTED | CELL_PAD_STATUS_ASSIGN_CHANGES; if (!m_dev->hasCalibData) m_dev->hasCalibData = GetCalibrationData(m_dev); } @@ -868,13 +868,14 @@ void ds4_pad_handler::ThreadProc() last_connection_status[i] = false; connected--; } - thepad->m_port_status = CELL_PAD_STATUS_DISCONNECTED|CELL_PAD_STATUS_ASSIGN_CHANGES; + thepad->m_port_status = CELL_PAD_STATUS_DISCONNECTED | CELL_PAD_STATUS_ASSIGN_CHANGES; continue; } } else if (last_connection_status[i] == false) { LOG_NOTICE(HLE, "DS4 device %d connected", i); + thepad->m_port_status = CELL_PAD_STATUS_CONNECTED | CELL_PAD_STATUS_ASSIGN_CHANGES; last_connection_status[i] = true; connected++; } diff --git a/rpcs3/evdev_joystick_handler.cpp b/rpcs3/evdev_joystick_handler.cpp index 242423a5af..e3541ac4fb 100644 --- a/rpcs3/evdev_joystick_handler.cpp +++ b/rpcs3/evdev_joystick_handler.cpp @@ -113,7 +113,7 @@ bool evdev_joystick_handler::Init() return true; } -bool evdev_joystick_handler::update_device(EvdevDevice& device, bool use_cell) +bool evdev_joystick_handler::update_device(EvdevDevice& device) { std::shared_ptr pad = device.pad; const auto& path = device.path; @@ -125,19 +125,12 @@ bool evdev_joystick_handler::update_device(EvdevDevice& device, bool use_cell) { if (was_connected) { - // It was disconnected. - if (use_cell) - pad->m_port_status |= CELL_PAD_STATUS_ASSIGN_CHANGES; - int fd = libevdev_get_fd(dev); libevdev_free(dev); close(fd); dev = nullptr; } - if (use_cell) - pad->m_port_status &= ~CELL_PAD_STATUS_CONNECTED; - LOG_ERROR(GENERAL, "Joystick %s is not present or accessible [previous status: %d]", path.c_str(), was_connected ? 1 : 0); return false; } @@ -161,22 +154,14 @@ bool evdev_joystick_handler::update_device(EvdevDevice& device, bool use_cell) } LOG_NOTICE(GENERAL, "Opened joystick: '%s' at %s (fd %d)", libevdev_get_name(dev), path, fd); - - if (use_cell) - { - // Connection status changed from disconnected to connected. - pad->m_port_status |= CELL_PAD_STATUS_ASSIGN_CHANGES; - pad->m_port_status |= CELL_PAD_STATUS_CONNECTED; - } - return true; } -void evdev_joystick_handler::update_devs(bool use_cell) +void evdev_joystick_handler::update_devs() { for (auto& device : devices) { - update_device(device, use_cell); + update_device(device); } } @@ -252,7 +237,7 @@ evdev_joystick_handler::EvdevDevice* evdev_joystick_handler::get_device(const st EvdevDevice& dev = devices[m_pad_index]; // Check if our device is connected - if (!update_device(dev, false)) + if (!update_device(dev)) return nullptr; return &dev; @@ -692,7 +677,10 @@ void evdev_joystick_handler::ThreadProc() { if (last_connection_status[padnum] == true) { + // It was disconnected. LOG_ERROR(HLE, "evdev device %d disconnected", padnum); + pad->m_port_status &= ~CELL_PAD_STATUS_CONNECTED; + pad->m_port_status |= CELL_PAD_STATUS_ASSIGN_CHANGES; last_connection_status[padnum] = false; connected--; } @@ -702,7 +690,10 @@ void evdev_joystick_handler::ThreadProc() if (last_connection_status[padnum] == false) { + // Connection status changed from disconnected to connected. LOG_ERROR(HLE, "evdev device %d reconnected", padnum); + pad->m_port_status |= CELL_PAD_STATUS_CONNECTED; + pad->m_port_status |= CELL_PAD_STATUS_ASSIGN_CHANGES; last_connection_status[padnum] = true; connected++; } @@ -915,7 +906,7 @@ bool evdev_joystick_handler::bindPadToDevice(std::shared_ptr pad, const std pad->Init ( - CELL_PAD_STATUS_CONNECTED | CELL_PAD_STATUS_ASSIGN_CHANGES, + CELL_PAD_STATUS_DISCONNECTED, CELL_PAD_SETTING_PRESS_OFF | CELL_PAD_SETTING_SENSOR_OFF, CELL_PAD_CAPABILITY_PS3_CONFORMITY | CELL_PAD_CAPABILITY_PRESS_MODE | CELL_PAD_CAPABILITY_HP_ANALOG_STICK | CELL_PAD_CAPABILITY_ACTUATOR | CELL_PAD_CAPABILITY_SENSOR_MODE, CELL_PAD_DEV_TYPE_STANDARD diff --git a/rpcs3/evdev_joystick_handler.h b/rpcs3/evdev_joystick_handler.h index 02515d35e4..1ec6ce20aa 100644 --- a/rpcs3/evdev_joystick_handler.h +++ b/rpcs3/evdev_joystick_handler.h @@ -341,8 +341,8 @@ public: private: void TranslateButtonPress(u64 keyCode, bool& pressed, u16& value, bool ignore_threshold = false) override; EvdevDevice* get_device(const std::string& device); - bool update_device(EvdevDevice& device, bool use_cell = true); - void update_devs(bool use_cell = true); + bool update_device(EvdevDevice& device); + void update_devs(); int add_device(const std::string& device, bool in_settings = false); int GetButtonInfo(const input_event& evt, const EvdevDevice& device, int& button_code); std::unordered_map> GetButtonValues(const EvdevDevice& device); diff --git a/rpcs3/keyboard_pad_handler.cpp b/rpcs3/keyboard_pad_handler.cpp index 954aaf6fea..6f8e9ddf13 100644 --- a/rpcs3/keyboard_pad_handler.cpp +++ b/rpcs3/keyboard_pad_handler.cpp @@ -1,6 +1,7 @@ #include "keyboard_pad_handler.h" #include +#include inline std::string sstr(const QString& _in) { return _in.toStdString(); } constexpr auto qstr = QString::fromStdString; @@ -398,7 +399,7 @@ bool keyboard_pad_handler::bindPadToDevice(std::shared_ptr pad, const std:: //Fixed assign change, default is both sensor and press off pad->Init ( - CELL_PAD_STATUS_CONNECTED | CELL_PAD_STATUS_ASSIGN_CHANGES, + CELL_PAD_STATUS_DISCONNECTED, CELL_PAD_SETTING_PRESS_OFF | CELL_PAD_SETTING_SENSOR_OFF, CELL_PAD_CAPABILITY_PS3_CONFORMITY | CELL_PAD_CAPABILITY_PRESS_MODE | CELL_PAD_CAPABILITY_HP_ANALOG_STICK | CELL_PAD_CAPABILITY_ACTUATOR | CELL_PAD_CAPABILITY_SENSOR_MODE, CELL_PAD_DEV_TYPE_STANDARD @@ -437,11 +438,21 @@ bool keyboard_pad_handler::bindPadToDevice(std::shared_ptr pad, const std:: pad->m_vibrateMotors.emplace_back(false, 0); bindings.push_back(pad); - connected++; return true; } void keyboard_pad_handler::ThreadProc() { + for (int i = 0; i < bindings.size(); i++) + { + if (last_connection_status[i] == false) + { + //QThread::msleep(100); // Hack Simpsons. It calls a seemingly useless cellPadGetInfo at boot that would swallow the first CELL_PAD_STATUS_ASSIGN_CHANGES otherwise + bindings[i]->m_port_status |= CELL_PAD_STATUS_CONNECTED; + bindings[i]->m_port_status |= CELL_PAD_STATUS_ASSIGN_CHANGES; + last_connection_status[i] = true; + connected++; + } + } } diff --git a/rpcs3/mm_joystick_handler.cpp b/rpcs3/mm_joystick_handler.cpp index 9f74a4c9ce..fcbc25dcba 100644 --- a/rpcs3/mm_joystick_handler.cpp +++ b/rpcs3/mm_joystick_handler.cpp @@ -144,7 +144,7 @@ bool mm_joystick_handler::bindPadToDevice(std::shared_ptr pad, const std::s pad->Init ( - CELL_PAD_STATUS_CONNECTED | CELL_PAD_STATUS_ASSIGN_CHANGES, + CELL_PAD_STATUS_DISCONNECTED, CELL_PAD_SETTING_PRESS_OFF | CELL_PAD_SETTING_SENSOR_OFF, CELL_PAD_CAPABILITY_PS3_CONFORMITY | CELL_PAD_CAPABILITY_PRESS_MODE | CELL_PAD_CAPABILITY_HP_ANALOG_STICK | CELL_PAD_CAPABILITY_ACTUATOR | CELL_PAD_CAPABILITY_SENSOR_MODE, CELL_PAD_DEV_TYPE_STANDARD diff --git a/rpcs3/xinput_pad_handler.cpp b/rpcs3/xinput_pad_handler.cpp index 9eaf37ce72..08267c2cdb 100644 --- a/rpcs3/xinput_pad_handler.cpp +++ b/rpcs3/xinput_pad_handler.cpp @@ -475,7 +475,7 @@ bool xinput_pad_handler::bindPadToDevice(std::shared_ptr pad, const std::st pad->Init ( - CELL_PAD_STATUS_CONNECTED | CELL_PAD_STATUS_ASSIGN_CHANGES, + CELL_PAD_STATUS_DISCONNECTED, CELL_PAD_SETTING_PRESS_OFF | CELL_PAD_SETTING_SENSOR_OFF, CELL_PAD_CAPABILITY_PS3_CONFORMITY | CELL_PAD_CAPABILITY_PRESS_MODE | CELL_PAD_CAPABILITY_HP_ANALOG_STICK | CELL_PAD_CAPABILITY_ACTUATOR | CELL_PAD_CAPABILITY_SENSOR_MODE, CELL_PAD_DEV_TYPE_STANDARD