[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
This commit is contained in:
Megamouse 2017-11-27 22:31:15 +01:00 committed by Ivan
parent 695b4c1f06
commit 662fe8cc95
33 changed files with 3573 additions and 1796 deletions

View file

@ -8,51 +8,6 @@
#include <QWindow>
#include <QKeyEvent>
struct keyboard_pad_config final : cfg::node
{
const std::string cfg_name = fs::get_config_dir() + "/config_kbpad_qt.yml";
cfg::int32 left_stick_left{ this, "Left Analog Stick Left", Qt::Key_A };
cfg::int32 left_stick_down{ this, "Left Analog Stick Down", Qt::Key_S };
cfg::int32 left_stick_right{ this, "Left Analog Stick Right", Qt::Key_D };
cfg::int32 left_stick_up{ this, "Left Analog Stick Up", Qt::Key_W };
cfg::int32 right_stick_left{ this, "Right Analog Stick Left", Qt::Key_Home };
cfg::int32 right_stick_down{ this, "Right Analog Stick Down", Qt::Key_PageDown };
cfg::int32 right_stick_right{ this, "Right Analog Stick Right", Qt::Key_End };
cfg::int32 right_stick_up{ this, "Right Analog Stick Up", Qt::Key_PageUp };
cfg::int32 start{ this, "Start", Qt::Key_Return };
cfg::int32 select{ this, "Select", Qt::Key_Space };
cfg::int32 square{ this, "Square", Qt::Key_Z };
cfg::int32 cross{ this, "Cross", Qt::Key_X };
cfg::int32 circle{ this, "Circle", Qt::Key_C };
cfg::int32 triangle{ this, "Triangle", Qt::Key_V };
cfg::int32 left{ this, "Left", Qt::Key_Left };
cfg::int32 down{ this, "Down", Qt::Key_Down };
cfg::int32 right{ this, "Right", Qt::Key_Right };
cfg::int32 up{ this, "Up", Qt::Key_Up };
cfg::int32 r1{ this, "R1", Qt::Key_E };
cfg::int32 r2{ this, "R2", Qt::Key_T };
cfg::int32 r3{ this, "R3", Qt::Key_G };
cfg::int32 l1{ this, "L1", Qt::Key_Q };
cfg::int32 l2{ this, "L2", Qt::Key_R };
cfg::int32 l3{ this, "L3", Qt::Key_F };
bool load()
{
if (fs::file cfg_file{ cfg_name, fs::read })
{
return from_string(cfg_file.to_string());
}
return false;
}
void save()
{
fs::file(cfg_name, fs::rewrite).write(to_string());
}
};
class keyboard_pad_handler final : public QObject, public PadHandlerBase
{
public:
@ -69,7 +24,10 @@ public:
std::vector<std::string> ListDevices() override;
bool bindPadToDevice(std::shared_ptr<Pad> pad, const std::string& device) override;
void ThreadProc() override;
void ConfigController(std::string device) override;
std::string GetKeyName(const QKeyEvent* keyEvent);
std::string GetKeyName(const u32& keyCode);
u32 GetKeyCode(const std::string& keyName);
protected:
void Key(const u32 code, bool pressed, u16 value = 255);