From 814adbb8c45d8ac6c71c98a95b589ee48fdf57a3 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sat, 15 Oct 2022 12:10:40 +0200 Subject: [PATCH] Input: simplify InitPadConfig --- rpcs3/Emu/Io/PadHandler.cpp | 2 +- rpcs3/Input/evdev_joystick_handler.cpp | 2 +- rpcs3/Input/hid_pad_handler.h | 2 +- rpcs3/Input/mm_joystick_handler.cpp | 2 +- rpcs3/Input/mm_joystick_handler.h | 6 ++--- rpcs3/Input/pad_thread.cpp | 33 ++------------------------ 6 files changed, 9 insertions(+), 38 deletions(-) diff --git a/rpcs3/Emu/Io/PadHandler.cpp b/rpcs3/Emu/Io/PadHandler.cpp index 422c5b77a7..f92b723941 100644 --- a/rpcs3/Emu/Io/PadHandler.cpp +++ b/rpcs3/Emu/Io/PadHandler.cpp @@ -233,7 +233,7 @@ u16 PadHandlerBase::Clamp0To1023(f32 input) // input has to be [-1,1]. result will be [0,255] u16 PadHandlerBase::ConvertAxis(f32 value) { - return static_cast((value + 1.0)*(255.0 / 2.0)); + return static_cast((value + 1.0) * (255.0 / 2.0)); } // The DS3, (and i think xbox controllers) give a 'square-ish' type response, so that the corners will give (almost)max x/y instead of the ~30x30 from a perfect circle diff --git a/rpcs3/Input/evdev_joystick_handler.cpp b/rpcs3/Input/evdev_joystick_handler.cpp index 6de7eef892..b355439471 100644 --- a/rpcs3/Input/evdev_joystick_handler.cpp +++ b/rpcs3/Input/evdev_joystick_handler.cpp @@ -342,7 +342,7 @@ void evdev_joystick_handler::get_next_button_press(const std::string& padId, con return it != data.end() && dir == it->second.second ? it->second.first : 0; }; - pad_preview_values preview_values = { 0, 0, 0, 0, 0, 0 }; + pad_preview_values preview_values{}; if (buttons.size() == 10) { diff --git a/rpcs3/Input/hid_pad_handler.h b/rpcs3/Input/hid_pad_handler.h index 8235e85511..e207ad4bf6 100644 --- a/rpcs3/Input/hid_pad_handler.h +++ b/rpcs3/Input/hid_pad_handler.h @@ -33,7 +33,7 @@ class HidDevice : public PadDevice { public: hid_device* hidDevice{nullptr}; - std::string path{""}; + std::string path; std::array padData{}; bool new_output_data{true}; u8 large_motor{0}; diff --git a/rpcs3/Input/mm_joystick_handler.cpp b/rpcs3/Input/mm_joystick_handler.cpp index b5c71d2a01..d1a2344707 100644 --- a/rpcs3/Input/mm_joystick_handler.cpp +++ b/rpcs3/Input/mm_joystick_handler.cpp @@ -310,7 +310,7 @@ void mm_joystick_handler::get_next_button_press(const std::string& padId, const return; } - pad_preview_values preview_values = { 0, 0, 0, 0, 0, 0 }; + pad_preview_values preview_values{}; if (buttons.size() == 10) { preview_values[0] = data[find_key(buttons[0])]; diff --git a/rpcs3/Input/mm_joystick_handler.h b/rpcs3/Input/mm_joystick_handler.h index 2bd2945f6b..c8a4ceeb71 100644 --- a/rpcs3/Input/mm_joystick_handler.h +++ b/rpcs3/Input/mm_joystick_handler.h @@ -101,14 +101,14 @@ class mm_joystick_handler final : public PadHandlerBase struct MMJOYDevice : public PadDevice { u32 device_id{ 0 }; - std::string device_name{ "" }; + std::string device_name; JOYINFOEX device_info{}; JOYCAPS device_caps{}; MMRESULT device_status = JOYERR_UNPLUGGED; u64 trigger_left = 0; u64 trigger_right = 0; - std::vector axis_left = { 0,0,0,0 }; - std::vector axis_right = { 0,0,0,0 }; + std::vector axis_left{}; + std::vector axis_right{}; }; public: diff --git a/rpcs3/Input/pad_thread.cpp b/rpcs3/Input/pad_thread.cpp index b11367e732..75e6cc226f 100644 --- a/rpcs3/Input/pad_thread.cpp +++ b/rpcs3/Input/pad_thread.cpp @@ -469,35 +469,6 @@ void pad_thread::InitPadConfig(cfg_pad& cfg, pad_handler type, std::shared_ptr

m_type) - { - case pad_handler::null: - static_cast(handler.get())->init_config(&cfg); - break; - case pad_handler::keyboard: - static_cast(handler.get())->init_config(&cfg); - break; - case pad_handler::ds3: - static_cast(handler.get())->init_config(&cfg); - break; - case pad_handler::ds4: - static_cast(handler.get())->init_config(&cfg); - break; - case pad_handler::dualsense: - static_cast(handler.get())->init_config(&cfg); - break; -#ifdef _WIN32 - case pad_handler::xinput: - static_cast(handler.get())->init_config(&cfg); - break; - case pad_handler::mm: - static_cast(handler.get())->init_config(&cfg); - break; -#endif -#ifdef HAVE_LIBEVDEV - case pad_handler::evdev: - static_cast(handler.get())->init_config(&cfg); - break; -#endif - } + ensure(!!handler); + handler->init_config(&cfg); }