Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DS4: log hardware and firmware versions #11008

Merged
merged 2 commits into from Oct 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 18 additions & 1 deletion rpcs3/Input/ds4_pad_handler.cpp
Expand Up @@ -18,6 +18,7 @@ namespace
constexpr u32 DS4_FEATURE_REPORT_0x05_SIZE = 41;
constexpr u32 DS4_FEATURE_REPORT_0x12_SIZE = 16;
constexpr u32 DS4_FEATURE_REPORT_0x81_SIZE = 7;
constexpr u32 DS4_FEATURE_REPORT_0xA3_SIZE = 49;
constexpr u32 DS4_INPUT_REPORT_0x11_SIZE = 78;
constexpr u32 DS4_OUTPUT_REPORT_0x05_SIZE = 32;
constexpr u32 DS4_OUTPUT_REPORT_0x11_SIZE = 78;
Expand Down Expand Up @@ -568,6 +569,22 @@ void ds4_pad_handler::check_add_device(hid_device* hidDevice, std::string_view p
return;
}

u32 hw_version{};
u32 fw_version{};

buf[0] = 0xA3;

res = hid_get_feature_report(hidDevice, buf.data(), DS4_FEATURE_REPORT_0xA3_SIZE);
if (res <= 0)
{
ds4_log.error("check_add_device: hid_get_feature_report 0xA3 failed! Could not retrieve firmware version! result=%d, error=%s", res, hid_error(hidDevice));
}
else
{
hw_version = read_u32(&buf[35]);
fw_version = read_u32(&buf[41]);
}

if (hid_set_nonblocking(hidDevice, 1) == -1)
{
ds4_log.error("check_add_device: hid_set_nonblocking failed! Reason: %s", hid_error(hidDevice));
Expand All @@ -581,7 +598,7 @@ void ds4_pad_handler::check_add_device(hid_device* hidDevice, std::string_view p

send_output_report(device);

ds4_log.notice("Added device: bluetooth=%d, serial='%s', path='%s'", device->bt_controller, serial, device->path);
ds4_log.notice("Added device: bluetooth=%d, serial='%s', hw_version: 0x%x, fw_version: 0x%x, path='%s'", device->bt_controller, serial, hw_version, fw_version, device->path);
}

ds4_pad_handler::~ds4_pad_handler()
Expand Down
3 changes: 2 additions & 1 deletion rpcs3/Input/dualsense_pad_handler.cpp
Expand Up @@ -24,6 +24,7 @@ namespace
constexpr u32 DUALSENSE_ACC_RES_PER_G = 8192;
constexpr u32 DUALSENSE_GYRO_RES_PER_DEG_S = 1024;
constexpr u32 DUALSENSE_CALIBRATION_REPORT_SIZE = 41;
constexpr u32 DUALSENSE_VERSION_REPORT_SIZE = 64;
constexpr u32 DUALSENSE_BLUETOOTH_REPORT_SIZE = 78;
constexpr u32 DUALSENSE_USB_REPORT_SIZE = 63;
constexpr u32 DUALSENSE_COMMON_REPORT_SIZE = 47;
Expand Down Expand Up @@ -219,7 +220,7 @@ void dualsense_pad_handler::check_add_device(hid_device* hidDevice, std::string_

buf[0] = 0x20;

res = hid_get_feature_report(hidDevice, buf.data(), 64);
res = hid_get_feature_report(hidDevice, buf.data(), DUALSENSE_VERSION_REPORT_SIZE);
if (res == 65)
{
hw_version = read_u32(&buf[24]);
Expand Down
16 changes: 8 additions & 8 deletions rpcs3/Input/mm_joystick_handler.cpp
Expand Up @@ -179,7 +179,7 @@ std::array<u32, PadHandlerBase::button::button_count> mm_joystick_handler::get_m
void mm_joystick_handler::get_next_button_press(const std::string& padId, const pad_callback& callback, const pad_fail_callback& fail_callback, bool get_blacklist, const std::vector<std::string>& buttons)
{
if (get_blacklist)
blacklist.clear();
m_blacklist.clear();

if (!Init())
{
Expand Down Expand Up @@ -234,14 +234,14 @@ void mm_joystick_handler::get_next_button_press(const std::string& padId, const
u64 keycode = button.first;
u16 value = data[keycode];

if (!get_blacklist && std::find(blacklist.begin(), blacklist.end(), keycode) != blacklist.end())
if (!get_blacklist && std::find(m_blacklist.begin(), m_blacklist.end(), keycode) != m_blacklist.end())
continue;

if (value > m_thumb_threshold)
{
if (get_blacklist)
{
blacklist.emplace_back(keycode);
m_blacklist.emplace_back(keycode);
input_log.error("MMJOY Calibration: Added axis [ %d = %s ] to blacklist. Value = %d", keycode, button.second, value);
}
else if (value > pressed_button.first)
Expand All @@ -254,14 +254,14 @@ void mm_joystick_handler::get_next_button_press(const std::string& padId, const
u64 keycode = button.first;
u16 value = data[keycode];

if (!get_blacklist && std::find(blacklist.begin(), blacklist.end(), keycode) != blacklist.end())
if (!get_blacklist && std::find(m_blacklist.begin(), m_blacklist.end(), keycode) != m_blacklist.end())
continue;

if (value > 0)
{
if (get_blacklist)
{
blacklist.emplace_back(keycode);
m_blacklist.emplace_back(keycode);
input_log.error("MMJOY Calibration: Added pov [ %d = %s ] to blacklist. Value = %d", keycode, button.second, value);
}
else if (value > pressed_button.first)
Expand All @@ -276,7 +276,7 @@ void mm_joystick_handler::get_next_button_press(const std::string& padId, const
if (keycode == NO_BUTTON)
continue;

if (!get_blacklist && std::find(blacklist.begin(), blacklist.end(), keycode) != blacklist.end())
if (!get_blacklist && std::find(m_blacklist.begin(), m_blacklist.end(), keycode) != m_blacklist.end())
continue;

const u16 value = data[keycode];
Expand All @@ -285,7 +285,7 @@ void mm_joystick_handler::get_next_button_press(const std::string& padId, const
{
if (get_blacklist)
{
blacklist.emplace_back(keycode);
m_blacklist.emplace_back(keycode);
input_log.error("MMJOY Calibration: Added button [ %d = %s ] to blacklist. Value = %d", keycode, button.second, value);
}
else if (value > pressed_button.first)
Expand All @@ -295,7 +295,7 @@ void mm_joystick_handler::get_next_button_press(const std::string& padId, const

if (get_blacklist)
{
if (blacklist.empty())
if (m_blacklist.empty())
input_log.success("MMJOY Calibration: Blacklist is clear. No input spam detected");
return;
}
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Input/mm_joystick_handler.h
Expand Up @@ -127,7 +127,7 @@ class mm_joystick_handler final : public PadHandlerBase

bool is_init = false;

std::vector<u64> blacklist;
std::vector<u64> m_blacklist;
std::shared_ptr<MMJOYDevice> m_dev;
std::unordered_map<int, MMJOYDevice> m_devices;

Expand Down