1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-21 18:22:33 +01:00

Input: simplify InitPadConfig

This commit is contained in:
Megamouse 2022-10-15 12:10:40 +02:00
parent cf86b6c107
commit 814adbb8c4
6 changed files with 9 additions and 38 deletions

View File

@ -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<u16>((value + 1.0)*(255.0 / 2.0));
return static_cast<u16>((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

View File

@ -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)
{

View File

@ -33,7 +33,7 @@ class HidDevice : public PadDevice
{
public:
hid_device* hidDevice{nullptr};
std::string path{""};
std::string path;
std::array<u8, 64> padData{};
bool new_output_data{true};
u8 large_motor{0};

View File

@ -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])];

View File

@ -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<u64> axis_left = { 0,0,0,0 };
std::vector<u64> axis_right = { 0,0,0,0 };
std::vector<u64> axis_left{};
std::vector<u64> axis_right{};
};
public:

View File

@ -469,35 +469,6 @@ void pad_thread::InitPadConfig(cfg_pad& cfg, pad_handler type, std::shared_ptr<P
handler = GetHandler(type);
}
switch (handler->m_type)
{
case pad_handler::null:
static_cast<NullPadHandler*>(handler.get())->init_config(&cfg);
break;
case pad_handler::keyboard:
static_cast<keyboard_pad_handler*>(handler.get())->init_config(&cfg);
break;
case pad_handler::ds3:
static_cast<ds3_pad_handler*>(handler.get())->init_config(&cfg);
break;
case pad_handler::ds4:
static_cast<ds4_pad_handler*>(handler.get())->init_config(&cfg);
break;
case pad_handler::dualsense:
static_cast<dualsense_pad_handler*>(handler.get())->init_config(&cfg);
break;
#ifdef _WIN32
case pad_handler::xinput:
static_cast<xinput_pad_handler*>(handler.get())->init_config(&cfg);
break;
case pad_handler::mm:
static_cast<mm_joystick_handler*>(handler.get())->init_config(&cfg);
break;
#endif
#ifdef HAVE_LIBEVDEV
case pad_handler::evdev:
static_cast<evdev_joystick_handler*>(handler.get())->init_config(&cfg);
break;
#endif
}
ensure(!!handler);
handler->init_config(&cfg);
}