From 662fe8cc957d8d4991bcb74f354b3b6dfab4ef4d Mon Sep 17 00:00:00 2001 From: Megamouse Date: Mon, 27 Nov 2017 22:31:15 +0100 Subject: [PATCH] [Qt/Input] Improve pad_settings_dialog a bit (#3611) * Input: further work on remapping Xinput and begin work on remapping DS4 * Input: Improve pad_settings_dialog a bit and begin Remapping for XInput * Input: begin evdev remapping and change all handlers to use cfg::string * Input: finish work on remapping evdev and some more crap * Input: finish work on remapping Xinput and DS4 * Input: add DS4 Colors to DS4 config * Input: Improve DS4 deadzone scaling Jarves made some mistakes, so I'll fix them in the follow up commit * Input: fix Jarves fixes on DS4 deadzone and remove unnecessary usage of toUtf8 * Input: add primitive batterychecks to XInput and DS4 * Input: add mmjoystick remapping * Input: Fix evdev and some Vibration issues * Input: adjust capabilities to fix stick input for games like LoS 2 also fix threshold slider minimum also add ps button to all the handlers * Input: Further evdev work based on danilaml code review and own debugging: Fixed path issue, <= 0 issue, some captures, const, axis with same codes. Adds a map to each device that differentiates negative and positive axis mappings. adjusted rest of the file to tabs (ListDevices and beginning of threadProc) * Input: use 20ms vibration update time for xbox one elite controllers. * Input: Fix return type of Clamp() * Input: Evdev Fix * Input: Evdev Optional GetNextButtonPress presumably better than the other * Input: review changes * Input: evdev: fix wrong index in axis handling move bindpadtodevice down to keep consistency between handlers and not get crazy * Input: evdev: fix expensive add_device in GetNextButtonPress * cleanup * Input: mmjoy: fix type * Input: evdev: final fixes * Input: evdev: exclude unnecessary buttons while mapping Xbox 360 or DS4 * Input: add deadzone preview by passing necessary values in callback use 0.5 of max value for threshold in pad dialog * Input: get rid of all-uppercase variables --- Utilities/Config.h | 16 +- rpcs3/Emu/Io/PadHandler.h | 269 ++++- rpcs3/ds4_pad_handler.cpp | 889 +++++++++------ rpcs3/ds4_pad_handler.h | 97 +- rpcs3/evdev_joystick_handler.cpp | 1151 +++++++++++--------- rpcs3/evdev_joystick_handler.h | 330 ++++-- rpcs3/keyboard_pad_handler.cpp | 182 +++- rpcs3/keyboard_pad_handler.h | 50 +- rpcs3/main.cpp | 2 +- rpcs3/mm_joystick_handler.cpp | 331 +++++- rpcs3/mm_joystick_handler.h | 133 ++- rpcs3/pad_thread.cpp | 20 +- rpcs3/rpcs3.vcxproj | 2 + rpcs3/rpcs3.vcxproj.filters | 9 + rpcs3/rpcs3qt/cg_disasm_window.cpp | 2 +- rpcs3/rpcs3qt/emu_settings.cpp | 2 +- rpcs3/rpcs3qt/game_list_frame.cpp | 2 +- rpcs3/rpcs3qt/game_list_frame.h | 2 +- rpcs3/rpcs3qt/gamepads_settings_dialog.cpp | 115 +- rpcs3/rpcs3qt/gamepads_settings_dialog.h | 1 - rpcs3/rpcs3qt/gui_settings.cpp | 2 +- rpcs3/rpcs3qt/main_window.cpp | 2 +- rpcs3/rpcs3qt/pad_settings_dialog.cpp | 589 ++++++---- rpcs3/rpcs3qt/pad_settings_dialog.h | 158 ++- rpcs3/rpcs3qt/pad_settings_dialog.ui | 356 +++--- rpcs3/rpcs3qt/register_editor_dialog.cpp | 2 +- rpcs3/rpcs3qt/save_manager_dialog.cpp | 2 +- rpcs3/rpcs3qt/settings_dialog.cpp | 2 +- rpcs3/rpcs3qt/settings_dialog.h | 4 +- rpcs3/rpcs3qt/vfs_dialog.cpp | 2 +- rpcs3/rpcs3qt/vfs_dialog_tab.cpp | 2 +- rpcs3/xinput_pad_handler.cpp | 510 ++++++--- rpcs3/xinput_pad_handler.h | 133 ++- 33 files changed, 3573 insertions(+), 1796 deletions(-) diff --git a/Utilities/Config.h b/Utilities/Config.h index 4cbc88a85f..be7c58d2dc 100644 --- a/Utilities/Config.h +++ b/Utilities/Config.h @@ -118,7 +118,7 @@ namespace cfg bool m_value; public: - const bool def; + bool def; _bool(node* owner, const std::string& name, bool def = false) : _base(type::_bool, owner, name) @@ -150,6 +150,11 @@ namespace cfg return true; } + + void set(const bool& value) + { + m_value = value; + } }; // Value node with fixed set of possible values, each maps to an enum value of type T. @@ -217,7 +222,7 @@ namespace cfg int_type m_value; public: - const int_type def; + int_type def; _int(node* owner, const std::string& name, int_type def = std::min(Max, std::max(Min, 0))) : _base(type::_int, owner, name) @@ -253,6 +258,11 @@ namespace cfg return false; } + void set(const s64& value) + { + m_value = static_cast(value); + } + std::vector to_list() const override { return make_int_range(Min, Max); @@ -271,7 +281,7 @@ namespace cfg std::string m_value; public: - const std::string def; + std::string def; string(node* owner, const std::string& name, const std::string& def = {}) : _base(type::string, owner, name) diff --git a/rpcs3/Emu/Io/PadHandler.h b/rpcs3/Emu/Io/PadHandler.h index 288665180a..fd49f87195 100644 --- a/rpcs3/Emu/Io/PadHandler.h +++ b/rpcs3/Emu/Io/PadHandler.h @@ -1,7 +1,10 @@ #pragma once +#include #include #include +#include "stdafx.h" +#include "../../Utilities/Config.h" #include "../../Utilities/types.h" // TODO: HLE info (constants, structs, etc.) should not be available here @@ -159,6 +162,13 @@ struct Pad u32 m_device_capability; u32 m_device_type; + // Cable State: 0 - 1 plugged in ? + u8 m_cable_state; + + // DS4: 0 - 9 while unplugged, 0 - 10 while plugged in, 11 charge complete + // XInput: 0 = Empty, 1 = Low, 2 = Medium, 3 = Full + u8 m_battery_level; + std::vector