mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-21 18:22:33 +01:00
Input: fix MMJOY axis identification
This commit is contained in:
parent
e362c2c078
commit
13b3c78c7f
@ -357,8 +357,8 @@ void PadHandlerBase::get_next_button_press(const std::string& pad_id, const pad_
|
||||
if (!get_blacklist && std::find(blacklist.begin(), blacklist.end(), keycode) != blacklist.end())
|
||||
continue;
|
||||
|
||||
const bool is_trigger = get_is_left_trigger(keycode) || get_is_right_trigger(keycode);
|
||||
const bool is_stick = !is_trigger && (get_is_left_stick(keycode) || get_is_right_stick(keycode));
|
||||
const bool is_trigger = get_is_left_trigger(device, keycode) || get_is_right_trigger(device, keycode);
|
||||
const bool is_stick = !is_trigger && (get_is_left_stick(device, keycode) || get_is_right_stick(device, keycode));
|
||||
const bool is_button = !is_trigger && !is_stick;
|
||||
|
||||
if ((is_trigger && (value > m_trigger_threshold)) || (is_stick && (value > m_thumb_threshold)) || (is_button && (value > 0)))
|
||||
@ -382,8 +382,8 @@ void PadHandlerBase::get_next_button_press(const std::string& pad_id, const pad_
|
||||
return;
|
||||
}
|
||||
|
||||
const auto preview_values = get_preview_values(data);
|
||||
const auto battery_level = get_battery_level(pad_id);
|
||||
const pad_preview_values preview_values = get_preview_values(data);
|
||||
const u32 battery_level = get_battery_level(pad_id);
|
||||
|
||||
if (callback)
|
||||
{
|
||||
@ -451,22 +451,22 @@ void PadHandlerBase::TranslateButtonPress(const std::shared_ptr<PadDevice>& devi
|
||||
return;
|
||||
}
|
||||
|
||||
if (get_is_left_trigger(keyCode))
|
||||
if (get_is_left_trigger(device, keyCode))
|
||||
{
|
||||
pressed = val > (ignore_trigger_threshold ? 0 : device->config->ltriggerthreshold);
|
||||
val = pressed ? NormalizeTriggerInput(val, device->config->ltriggerthreshold) : 0;
|
||||
}
|
||||
else if (get_is_right_trigger(keyCode))
|
||||
else if (get_is_right_trigger(device, keyCode))
|
||||
{
|
||||
pressed = val > (ignore_trigger_threshold ? 0 : device->config->rtriggerthreshold);
|
||||
val = pressed ? NormalizeTriggerInput(val, device->config->rtriggerthreshold) : 0;
|
||||
}
|
||||
else if (get_is_left_stick(keyCode))
|
||||
else if (get_is_left_stick(device, keyCode))
|
||||
{
|
||||
pressed = val > (ignore_stick_threshold ? 0 : device->config->lstickdeadzone);
|
||||
val = pressed ? NormalizeStickInput(val, device->config->lstickdeadzone, device->config->lstickmultiplier, ignore_stick_threshold) : 0;
|
||||
}
|
||||
else if (get_is_right_stick(keyCode))
|
||||
else if (get_is_right_stick(device, keyCode))
|
||||
{
|
||||
pressed = val > (ignore_stick_threshold ? 0 : device->config->rstickdeadzone);
|
||||
val = pressed ? NormalizeStickInput(val, device->config->rstickdeadzone, device->config->rstickmultiplier, ignore_stick_threshold) : 0;
|
||||
@ -571,12 +571,23 @@ bool PadHandlerBase::bindPadToDevice(std::shared_ptr<Pad> pad, u8 player_id)
|
||||
return true;
|
||||
}
|
||||
|
||||
std::array<u32, PadHandlerBase::button::button_count> PadHandlerBase::get_mapped_key_codes(const std::shared_ptr<PadDevice>& /*device*/, const cfg_pad* cfg)
|
||||
std::array<u32, PadHandlerBase::button::button_count> PadHandlerBase::get_mapped_key_codes(const std::shared_ptr<PadDevice>& device, const cfg_pad* cfg)
|
||||
{
|
||||
std::array<u32, button::button_count> mapping{};
|
||||
if (!cfg)
|
||||
if (!device || !cfg)
|
||||
return mapping;
|
||||
|
||||
device->trigger_code_left = FindKeyCode(button_list, cfg->l2);
|
||||
device->trigger_code_right = FindKeyCode(button_list, cfg->r2);
|
||||
device->axis_code_left[0] = FindKeyCode(button_list, cfg->ls_left);
|
||||
device->axis_code_left[1] = FindKeyCode(button_list, cfg->ls_right);
|
||||
device->axis_code_left[2] = FindKeyCode(button_list, cfg->ls_down);
|
||||
device->axis_code_left[3] = FindKeyCode(button_list, cfg->ls_up);
|
||||
device->axis_code_right[0] = FindKeyCode(button_list, cfg->rs_left);
|
||||
device->axis_code_right[1] = FindKeyCode(button_list, cfg->rs_right);
|
||||
device->axis_code_right[2] = FindKeyCode(button_list, cfg->rs_down);
|
||||
device->axis_code_right[3] = FindKeyCode(button_list, cfg->rs_up);
|
||||
|
||||
mapping[button::up] = FindKeyCode(button_list, cfg->up);
|
||||
mapping[button::down] = FindKeyCode(button_list, cfg->down);
|
||||
mapping[button::left] = FindKeyCode(button_list, cfg->left);
|
||||
@ -588,19 +599,19 @@ std::array<u32, PadHandlerBase::button::button_count> PadHandlerBase::get_mapped
|
||||
mapping[button::start] = FindKeyCode(button_list, cfg->start);
|
||||
mapping[button::select] = FindKeyCode(button_list, cfg->select);
|
||||
mapping[button::l1] = FindKeyCode(button_list, cfg->l1);
|
||||
mapping[button::l2] = FindKeyCode(button_list, cfg->l2);
|
||||
mapping[button::l2] = ::narrow<u32>(device->trigger_code_left);
|
||||
mapping[button::l3] = FindKeyCode(button_list, cfg->l3);
|
||||
mapping[button::r1] = FindKeyCode(button_list, cfg->r1);
|
||||
mapping[button::r2] = FindKeyCode(button_list, cfg->r2);
|
||||
mapping[button::r2] = ::narrow<u32>(device->trigger_code_right);
|
||||
mapping[button::r3] = FindKeyCode(button_list, cfg->r3);
|
||||
mapping[button::ls_left] = FindKeyCode(button_list, cfg->ls_left);
|
||||
mapping[button::ls_right] = FindKeyCode(button_list, cfg->ls_right);
|
||||
mapping[button::ls_down] = FindKeyCode(button_list, cfg->ls_down);
|
||||
mapping[button::ls_up] = FindKeyCode(button_list, cfg->ls_up);
|
||||
mapping[button::rs_left] = FindKeyCode(button_list, cfg->rs_left);
|
||||
mapping[button::rs_right] = FindKeyCode(button_list, cfg->rs_right);
|
||||
mapping[button::rs_down] = FindKeyCode(button_list, cfg->rs_down);
|
||||
mapping[button::rs_up] = FindKeyCode(button_list, cfg->rs_up);
|
||||
mapping[button::ls_left] = ::narrow<u32>(device->axis_code_left[0]);
|
||||
mapping[button::ls_right] = ::narrow<u32>(device->axis_code_left[1]);
|
||||
mapping[button::ls_down] = ::narrow<u32>(device->axis_code_left[2]);
|
||||
mapping[button::ls_up] = ::narrow<u32>(device->axis_code_left[3]);
|
||||
mapping[button::rs_left] = ::narrow<u32>(device->axis_code_right[0]);
|
||||
mapping[button::rs_right] = ::narrow<u32>(device->axis_code_right[1]);
|
||||
mapping[button::rs_down] = ::narrow<u32>(device->axis_code_right[2]);
|
||||
mapping[button::rs_up] = ::narrow<u32>(device->axis_code_right[3]);
|
||||
mapping[button::ps] = FindKeyCode(button_list, cfg->ps);
|
||||
|
||||
mapping[button::pressure_intensity_button] = FindKeyCode(button_list, cfg->pressure_intensity_button);
|
||||
|
@ -18,6 +18,10 @@ public:
|
||||
virtual ~PadDevice() = default;
|
||||
cfg_pad* config{ nullptr };
|
||||
u8 player_id{0};
|
||||
u64 trigger_code_left = 0;
|
||||
u64 trigger_code_right = 0;
|
||||
std::array<u64, 4> axis_code_left{};
|
||||
std::array<u64, 4> axis_code_right{};
|
||||
};
|
||||
|
||||
struct pad_ensemble
|
||||
@ -206,10 +210,10 @@ public:
|
||||
|
||||
private:
|
||||
virtual std::shared_ptr<PadDevice> get_device(const std::string& /*device*/) { return nullptr; }
|
||||
virtual bool get_is_left_trigger(u64 /*keyCode*/) { return false; }
|
||||
virtual bool get_is_right_trigger(u64 /*keyCode*/) { return false; }
|
||||
virtual bool get_is_left_stick(u64 /*keyCode*/) { return false; }
|
||||
virtual bool get_is_right_stick(u64 /*keyCode*/) { return false; }
|
||||
virtual bool get_is_left_trigger(const std::shared_ptr<PadDevice>& /*device*/, u64 /*keyCode*/) { return false; }
|
||||
virtual bool get_is_right_trigger(const std::shared_ptr<PadDevice>& /*device*/, u64 /*keyCode*/) { return false; }
|
||||
virtual bool get_is_left_stick(const std::shared_ptr<PadDevice>& /*device*/, u64 /*keyCode*/) { return false; }
|
||||
virtual bool get_is_right_stick(const std::shared_ptr<PadDevice>& /*device*/, u64 /*keyCode*/) { return false; }
|
||||
virtual PadHandlerBase::connection update_connection(const std::shared_ptr<PadDevice>& /*device*/) { return connection::disconnected; }
|
||||
virtual void get_extended_info(const pad_ensemble& /*binding*/) {}
|
||||
virtual void apply_pad_data(const pad_ensemble& /*binding*/) {}
|
||||
|
@ -492,17 +492,17 @@ void ds3_pad_handler::get_extended_info(const pad_ensemble& binding)
|
||||
//pad->m_sensors[3].m_value = polish_value(pad->m_sensors[3].m_value, 1, 1, 512, 512, 0, 1023);
|
||||
}
|
||||
|
||||
bool ds3_pad_handler::get_is_left_trigger(u64 keyCode)
|
||||
bool ds3_pad_handler::get_is_left_trigger(const std::shared_ptr<PadDevice>& /*device*/, u64 keyCode)
|
||||
{
|
||||
return keyCode == DS3KeyCodes::L2;
|
||||
}
|
||||
|
||||
bool ds3_pad_handler::get_is_right_trigger(u64 keyCode)
|
||||
bool ds3_pad_handler::get_is_right_trigger(const std::shared_ptr<PadDevice>& /*device*/, u64 keyCode)
|
||||
{
|
||||
return keyCode == DS3KeyCodes::R2;
|
||||
}
|
||||
|
||||
bool ds3_pad_handler::get_is_left_stick(u64 keyCode)
|
||||
bool ds3_pad_handler::get_is_left_stick(const std::shared_ptr<PadDevice>& /*device*/, u64 keyCode)
|
||||
{
|
||||
switch (keyCode)
|
||||
{
|
||||
@ -516,7 +516,7 @@ bool ds3_pad_handler::get_is_left_stick(u64 keyCode)
|
||||
}
|
||||
}
|
||||
|
||||
bool ds3_pad_handler::get_is_right_stick(u64 keyCode)
|
||||
bool ds3_pad_handler::get_is_right_stick(const std::shared_ptr<PadDevice>& /*device*/, u64 keyCode)
|
||||
{
|
||||
switch (keyCode)
|
||||
{
|
||||
|
@ -89,10 +89,10 @@ private:
|
||||
int send_output_report(ds3_device* ds3dev) override;
|
||||
void check_add_device(hid_device* hidDevice, std::string_view path, std::wstring_view serial) override;
|
||||
|
||||
bool get_is_left_trigger(u64 keyCode) override;
|
||||
bool get_is_right_trigger(u64 keyCode) override;
|
||||
bool get_is_left_stick(u64 keyCode) override;
|
||||
bool get_is_right_stick(u64 keyCode) override;
|
||||
bool get_is_left_trigger(const std::shared_ptr<PadDevice>& device, u64 keyCode) override;
|
||||
bool get_is_right_trigger(const std::shared_ptr<PadDevice>& device, u64 keyCode) override;
|
||||
bool get_is_left_stick(const std::shared_ptr<PadDevice>& device, u64 keyCode) override;
|
||||
bool get_is_right_stick(const std::shared_ptr<PadDevice>& device, u64 keyCode) override;
|
||||
PadHandlerBase::connection update_connection(const std::shared_ptr<PadDevice>& device) override;
|
||||
void get_extended_info(const pad_ensemble& binding) override;
|
||||
void apply_pad_data(const pad_ensemble& binding) override;
|
||||
|
@ -755,17 +755,17 @@ ds4_pad_handler::DataStatus ds4_pad_handler::get_data(DS4Device* device)
|
||||
return DataStatus::NewData;
|
||||
}
|
||||
|
||||
bool ds4_pad_handler::get_is_left_trigger(u64 keyCode)
|
||||
bool ds4_pad_handler::get_is_left_trigger(const std::shared_ptr<PadDevice>& /*device*/, u64 keyCode)
|
||||
{
|
||||
return keyCode == DS4KeyCodes::L2;
|
||||
}
|
||||
|
||||
bool ds4_pad_handler::get_is_right_trigger(u64 keyCode)
|
||||
bool ds4_pad_handler::get_is_right_trigger(const std::shared_ptr<PadDevice>& /*device*/, u64 keyCode)
|
||||
{
|
||||
return keyCode == DS4KeyCodes::R2;
|
||||
}
|
||||
|
||||
bool ds4_pad_handler::get_is_left_stick(u64 keyCode)
|
||||
bool ds4_pad_handler::get_is_left_stick(const std::shared_ptr<PadDevice>& /*device*/, u64 keyCode)
|
||||
{
|
||||
switch (keyCode)
|
||||
{
|
||||
@ -779,7 +779,7 @@ bool ds4_pad_handler::get_is_left_stick(u64 keyCode)
|
||||
}
|
||||
}
|
||||
|
||||
bool ds4_pad_handler::get_is_right_stick(u64 keyCode)
|
||||
bool ds4_pad_handler::get_is_right_stick(const std::shared_ptr<PadDevice>& /*device*/, u64 keyCode)
|
||||
{
|
||||
switch (keyCode)
|
||||
{
|
||||
|
@ -69,10 +69,10 @@ private:
|
||||
int send_output_report(DS4Device* device) override;
|
||||
void check_add_device(hid_device* hidDevice, std::string_view path, std::wstring_view serial) override;
|
||||
|
||||
bool get_is_left_trigger(u64 keyCode) override;
|
||||
bool get_is_right_trigger(u64 keyCode) override;
|
||||
bool get_is_left_stick(u64 keyCode) override;
|
||||
bool get_is_right_stick(u64 keyCode) override;
|
||||
bool get_is_left_trigger(const std::shared_ptr<PadDevice>& device, u64 keyCode) override;
|
||||
bool get_is_right_trigger(const std::shared_ptr<PadDevice>& device, u64 keyCode) override;
|
||||
bool get_is_left_stick(const std::shared_ptr<PadDevice>& device, u64 keyCode) override;
|
||||
bool get_is_right_stick(const std::shared_ptr<PadDevice>& device, u64 keyCode) override;
|
||||
PadHandlerBase::connection update_connection(const std::shared_ptr<PadDevice>& device) override;
|
||||
void get_extended_info(const pad_ensemble& binding) override;
|
||||
void apply_pad_data(const pad_ensemble& binding) override;
|
||||
|
@ -549,17 +549,17 @@ bool dualsense_pad_handler::get_calibration_data(DualSenseDevice* dualsense_devi
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dualsense_pad_handler::get_is_left_trigger(u64 keyCode)
|
||||
bool dualsense_pad_handler::get_is_left_trigger(const std::shared_ptr<PadDevice>& /*device*/, u64 keyCode)
|
||||
{
|
||||
return keyCode == DualSenseKeyCodes::L2;
|
||||
}
|
||||
|
||||
bool dualsense_pad_handler::get_is_right_trigger(u64 keyCode)
|
||||
bool dualsense_pad_handler::get_is_right_trigger(const std::shared_ptr<PadDevice>& /*device*/, u64 keyCode)
|
||||
{
|
||||
return keyCode == DualSenseKeyCodes::R2;
|
||||
}
|
||||
|
||||
bool dualsense_pad_handler::get_is_left_stick(u64 keyCode)
|
||||
bool dualsense_pad_handler::get_is_left_stick(const std::shared_ptr<PadDevice>& /*device*/, u64 keyCode)
|
||||
{
|
||||
switch (keyCode)
|
||||
{
|
||||
@ -573,7 +573,7 @@ bool dualsense_pad_handler::get_is_left_stick(u64 keyCode)
|
||||
}
|
||||
}
|
||||
|
||||
bool dualsense_pad_handler::get_is_right_stick(u64 keyCode)
|
||||
bool dualsense_pad_handler::get_is_right_stick(const std::shared_ptr<PadDevice>& /*device*/, u64 keyCode)
|
||||
{
|
||||
switch (keyCode)
|
||||
{
|
||||
|
@ -80,10 +80,10 @@ private:
|
||||
void check_add_device(hid_device* hidDevice, std::string_view path, std::wstring_view wide_serial) override;
|
||||
int send_output_report(DualSenseDevice* device) override;
|
||||
|
||||
bool get_is_left_trigger(u64 keyCode) override;
|
||||
bool get_is_right_trigger(u64 keyCode) override;
|
||||
bool get_is_left_stick(u64 keyCode) override;
|
||||
bool get_is_right_stick(u64 keyCode) override;
|
||||
bool get_is_left_trigger(const std::shared_ptr<PadDevice>& device, u64 keyCode) override;
|
||||
bool get_is_right_trigger(const std::shared_ptr<PadDevice>& device, u64 keyCode) override;
|
||||
bool get_is_left_stick(const std::shared_ptr<PadDevice>& device, u64 keyCode) override;
|
||||
bool get_is_right_stick(const std::shared_ptr<PadDevice>& device, u64 keyCode) override;
|
||||
PadHandlerBase::connection update_connection(const std::shared_ptr<PadDevice>& device) override;
|
||||
std::unordered_map<u64, u16> get_button_values(const std::shared_ptr<PadDevice>& device) override;
|
||||
pad_preview_values get_preview_values(const std::unordered_map<u64, u16>& data) override;
|
||||
|
@ -1349,22 +1349,22 @@ bool evdev_joystick_handler::check_buttons(const std::array<EvdevButton, 4>& b,
|
||||
return std::any_of(b.begin(), b.end(), [this, code](const EvdevButton& b) { return check_button(b, code); });
|
||||
};
|
||||
|
||||
bool evdev_joystick_handler::get_is_left_trigger(u64 keyCode)
|
||||
bool evdev_joystick_handler::get_is_left_trigger(const std::shared_ptr<PadDevice>& /*device*/, u64 keyCode)
|
||||
{
|
||||
return check_button(m_dev->trigger_left, static_cast<u32>(keyCode));
|
||||
}
|
||||
|
||||
bool evdev_joystick_handler::get_is_right_trigger(u64 keyCode)
|
||||
bool evdev_joystick_handler::get_is_right_trigger(const std::shared_ptr<PadDevice>& /*device*/, u64 keyCode)
|
||||
{
|
||||
return check_button(m_dev->trigger_right, static_cast<u32>(keyCode));
|
||||
}
|
||||
|
||||
bool evdev_joystick_handler::get_is_left_stick(u64 keyCode)
|
||||
bool evdev_joystick_handler::get_is_left_stick(const std::shared_ptr<PadDevice>& /*device*/, u64 keyCode)
|
||||
{
|
||||
return check_buttons(m_dev->axis_left, static_cast<u32>(keyCode));
|
||||
}
|
||||
|
||||
bool evdev_joystick_handler::get_is_right_stick(u64 keyCode)
|
||||
bool evdev_joystick_handler::get_is_right_stick(const std::shared_ptr<PadDevice>& /*device*/, u64 keyCode)
|
||||
{
|
||||
return check_buttons(m_dev->axis_right, static_cast<u32>(keyCode));
|
||||
}
|
||||
|
@ -424,10 +424,10 @@ protected:
|
||||
void get_mapping(const pad_ensemble& binding) override;
|
||||
void get_extended_info(const pad_ensemble& binding) override;
|
||||
void apply_pad_data(const pad_ensemble& binding) override;
|
||||
bool get_is_left_trigger(u64 keyCode) override;
|
||||
bool get_is_right_trigger(u64 keyCode) override;
|
||||
bool get_is_left_stick(u64 keyCode) override;
|
||||
bool get_is_right_stick(u64 keyCode) override;
|
||||
bool get_is_left_trigger(const std::shared_ptr<PadDevice>& device, u64 keyCode) override;
|
||||
bool get_is_right_trigger(const std::shared_ptr<PadDevice>& device, u64 keyCode) override;
|
||||
bool get_is_left_stick(const std::shared_ptr<PadDevice>& device, u64 keyCode) override;
|
||||
bool get_is_right_stick(const std::shared_ptr<PadDevice>& device, u64 keyCode) override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -134,16 +134,16 @@ std::array<u32, PadHandlerBase::button::button_count> mm_joystick_handler::get_m
|
||||
if (!joy_device || !cfg)
|
||||
return mapping;
|
||||
|
||||
joy_device->trigger_left = find_key(cfg->l2);
|
||||
joy_device->trigger_right = find_key(cfg->r2);
|
||||
joy_device->axis_left[0] = find_key(cfg->ls_left);
|
||||
joy_device->axis_left[1] = find_key(cfg->ls_right);
|
||||
joy_device->axis_left[2] = find_key(cfg->ls_down);
|
||||
joy_device->axis_left[3] = find_key(cfg->ls_up);
|
||||
joy_device->axis_right[0] = find_key(cfg->rs_left);
|
||||
joy_device->axis_right[1] = find_key(cfg->rs_right);
|
||||
joy_device->axis_right[2] = find_key(cfg->rs_down);
|
||||
joy_device->axis_right[3] = find_key(cfg->rs_up);
|
||||
joy_device->trigger_code_left = find_key(cfg->l2);
|
||||
joy_device->trigger_code_right = find_key(cfg->r2);
|
||||
joy_device->axis_code_left[0] = find_key(cfg->ls_left);
|
||||
joy_device->axis_code_left[1] = find_key(cfg->ls_right);
|
||||
joy_device->axis_code_left[2] = find_key(cfg->ls_down);
|
||||
joy_device->axis_code_left[3] = find_key(cfg->ls_up);
|
||||
joy_device->axis_code_right[0] = find_key(cfg->rs_left);
|
||||
joy_device->axis_code_right[1] = find_key(cfg->rs_right);
|
||||
joy_device->axis_code_right[2] = find_key(cfg->rs_down);
|
||||
joy_device->axis_code_right[3] = find_key(cfg->rs_up);
|
||||
|
||||
mapping[button::up] = static_cast<u32>(find_key(cfg->up));
|
||||
mapping[button::down] = static_cast<u32>(find_key(cfg->down));
|
||||
@ -154,22 +154,22 @@ std::array<u32, PadHandlerBase::button::button_count> mm_joystick_handler::get_m
|
||||
mapping[button::circle] = static_cast<u32>(find_key(cfg->circle));
|
||||
mapping[button::triangle] = static_cast<u32>(find_key(cfg->triangle));
|
||||
mapping[button::l1] = static_cast<u32>(find_key(cfg->l1));
|
||||
mapping[button::l2] = static_cast<u32>(joy_device->trigger_left);
|
||||
mapping[button::l2] = static_cast<u32>(joy_device->trigger_code_left);
|
||||
mapping[button::l3] = static_cast<u32>(find_key(cfg->l3));
|
||||
mapping[button::r1] = static_cast<u32>(find_key(cfg->r1));
|
||||
mapping[button::r2] = static_cast<u32>(joy_device->trigger_right);
|
||||
mapping[button::r2] = static_cast<u32>(joy_device->trigger_code_right);
|
||||
mapping[button::r3] = static_cast<u32>(find_key(cfg->r3));
|
||||
mapping[button::start] = static_cast<u32>(find_key(cfg->start));
|
||||
mapping[button::select] = static_cast<u32>(find_key(cfg->select));
|
||||
mapping[button::ps] = static_cast<u32>(find_key(cfg->ps));
|
||||
mapping[button::ls_left] = static_cast<u32>(joy_device->axis_left[0]);
|
||||
mapping[button::ls_right] = static_cast<u32>(joy_device->axis_left[1]);
|
||||
mapping[button::ls_down] = static_cast<u32>(joy_device->axis_left[2]);
|
||||
mapping[button::ls_up] = static_cast<u32>(joy_device->axis_left[3]);
|
||||
mapping[button::rs_left] = static_cast<u32>(joy_device->axis_right[0]);
|
||||
mapping[button::rs_right] = static_cast<u32>(joy_device->axis_right[1]);
|
||||
mapping[button::rs_down] = static_cast<u32>(joy_device->axis_right[2]);
|
||||
mapping[button::rs_up] = static_cast<u32>(joy_device->axis_right[3]);
|
||||
mapping[button::ls_left] = static_cast<u32>(joy_device->axis_code_left[0]);
|
||||
mapping[button::ls_right] = static_cast<u32>(joy_device->axis_code_left[1]);
|
||||
mapping[button::ls_down] = static_cast<u32>(joy_device->axis_code_left[2]);
|
||||
mapping[button::ls_up] = static_cast<u32>(joy_device->axis_code_left[3]);
|
||||
mapping[button::rs_left] = static_cast<u32>(joy_device->axis_code_right[0]);
|
||||
mapping[button::rs_right] = static_cast<u32>(joy_device->axis_code_right[1]);
|
||||
mapping[button::rs_down] = static_cast<u32>(joy_device->axis_code_right[2]);
|
||||
mapping[button::rs_up] = static_cast<u32>(joy_device->axis_code_right[3]);
|
||||
|
||||
mapping[button::pressure_intensity_button] = static_cast<u32>(find_key(cfg->pressure_intensity_button));
|
||||
|
||||
@ -238,7 +238,7 @@ 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(m_blacklist.begin(), m_blacklist.end(), keycode) != m_blacklist.end())
|
||||
if (!get_blacklist && std::find(m_blacklist.cbegin(), m_blacklist.cend(), keycode) != m_blacklist.cend())
|
||||
continue;
|
||||
|
||||
if (value > m_thumb_threshold)
|
||||
@ -260,7 +260,7 @@ 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(m_blacklist.begin(), m_blacklist.end(), keycode) != m_blacklist.end())
|
||||
if (!get_blacklist && std::find(m_blacklist.cbegin(), m_blacklist.cend(), keycode) != m_blacklist.cend())
|
||||
continue;
|
||||
|
||||
if (value > 0)
|
||||
@ -284,7 +284,7 @@ void mm_joystick_handler::get_next_button_press(const std::string& padId, const
|
||||
if (keycode == NO_BUTTON)
|
||||
continue;
|
||||
|
||||
if (!get_blacklist && std::find(m_blacklist.begin(), m_blacklist.end(), keycode) != m_blacklist.end())
|
||||
if (!get_blacklist && std::find(m_blacklist.cbegin(), m_blacklist.cend(), keycode) != m_blacklist.cend())
|
||||
continue;
|
||||
|
||||
const u16 value = data[keycode];
|
||||
@ -490,24 +490,28 @@ std::shared_ptr<PadDevice> mm_joystick_handler::get_device(const std::string& de
|
||||
return joy_device;
|
||||
}
|
||||
|
||||
bool mm_joystick_handler::get_is_left_trigger(u64 keyCode)
|
||||
bool mm_joystick_handler::get_is_left_trigger(const std::shared_ptr<PadDevice>& device, u64 keyCode)
|
||||
{
|
||||
return m_dev && m_dev->trigger_left == keyCode;
|
||||
const MMJOYDevice* dev = static_cast<MMJOYDevice*>(device.get());
|
||||
return dev && dev->trigger_code_left == keyCode;
|
||||
}
|
||||
|
||||
bool mm_joystick_handler::get_is_right_trigger(u64 keyCode)
|
||||
bool mm_joystick_handler::get_is_right_trigger(const std::shared_ptr<PadDevice>& device, u64 keyCode)
|
||||
{
|
||||
return m_dev && m_dev->trigger_right == keyCode;
|
||||
const MMJOYDevice* dev = static_cast<MMJOYDevice*>(device.get());
|
||||
return dev && dev->trigger_code_right == keyCode;
|
||||
}
|
||||
|
||||
bool mm_joystick_handler::get_is_left_stick(u64 keyCode)
|
||||
bool mm_joystick_handler::get_is_left_stick(const std::shared_ptr<PadDevice>& device, u64 keyCode)
|
||||
{
|
||||
return m_dev && std::find(m_dev->axis_left.begin(), m_dev->axis_left.end(), keyCode) != m_dev->axis_left.end();
|
||||
const MMJOYDevice* dev = static_cast<MMJOYDevice*>(device.get());
|
||||
return dev && std::find(dev->axis_code_left.cbegin(), dev->axis_code_left.cend(), keyCode) != dev->axis_code_left.cend();
|
||||
}
|
||||
|
||||
bool mm_joystick_handler::get_is_right_stick(u64 keyCode)
|
||||
bool mm_joystick_handler::get_is_right_stick(const std::shared_ptr<PadDevice>& device, u64 keyCode)
|
||||
{
|
||||
return m_dev && std::find(m_dev->axis_right.begin(), m_dev->axis_right.end(), keyCode) != m_dev->axis_right.end();
|
||||
const MMJOYDevice* dev = static_cast<MMJOYDevice*>(device.get());
|
||||
return dev && std::find(dev->axis_code_right.cbegin(), dev->axis_code_right.cend(), keyCode) != dev->axis_code_right.cend();
|
||||
}
|
||||
|
||||
PadHandlerBase::connection mm_joystick_handler::update_connection(const std::shared_ptr<PadDevice>& device)
|
||||
|
@ -105,10 +105,6 @@ class mm_joystick_handler final : public PadHandlerBase
|
||||
JOYINFOEX device_info{};
|
||||
JOYCAPS device_caps{};
|
||||
MMRESULT device_status = JOYERR_UNPLUGGED;
|
||||
u64 trigger_left = 0;
|
||||
u64 trigger_right = 0;
|
||||
std::vector<u64> axis_left{};
|
||||
std::vector<u64> axis_right{};
|
||||
};
|
||||
|
||||
public:
|
||||
@ -128,17 +124,16 @@ private:
|
||||
bool is_init = false;
|
||||
|
||||
std::vector<u64> m_blacklist;
|
||||
std::shared_ptr<MMJOYDevice> m_dev;
|
||||
std::unordered_map<int, MMJOYDevice> m_devices;
|
||||
|
||||
u64 find_key(const std::string& name) const;
|
||||
|
||||
std::array<u32, PadHandlerBase::button::button_count> get_mapped_key_codes(const std::shared_ptr<PadDevice>& device, const cfg_pad* cfg) override;
|
||||
std::shared_ptr<PadDevice> get_device(const std::string& device) override;
|
||||
bool get_is_left_trigger(u64 keyCode) override;
|
||||
bool get_is_right_trigger(u64 keyCode) override;
|
||||
bool get_is_left_stick(u64 keyCode) override;
|
||||
bool get_is_right_stick(u64 keyCode) override;
|
||||
bool get_is_left_trigger(const std::shared_ptr<PadDevice>& device, u64 keyCode) override;
|
||||
bool get_is_right_trigger(const std::shared_ptr<PadDevice>& device, u64 keyCode) override;
|
||||
bool get_is_left_stick(const std::shared_ptr<PadDevice>& device, u64 keyCode) override;
|
||||
bool get_is_right_stick(const std::shared_ptr<PadDevice>& device, u64 keyCode) override;
|
||||
PadHandlerBase::connection update_connection(const std::shared_ptr<PadDevice>& device) override;
|
||||
std::unordered_map<u64, u16> get_button_values(const std::shared_ptr<PadDevice>& device) override;
|
||||
};
|
||||
|
@ -422,17 +422,17 @@ std::shared_ptr<PadDevice> xinput_pad_handler::get_device(const std::string& dev
|
||||
return x_device;
|
||||
}
|
||||
|
||||
bool xinput_pad_handler::get_is_left_trigger(u64 keyCode)
|
||||
bool xinput_pad_handler::get_is_left_trigger(const std::shared_ptr<PadDevice>& /*device*/, u64 keyCode)
|
||||
{
|
||||
return keyCode == XInputKeyCodes::LT;
|
||||
}
|
||||
|
||||
bool xinput_pad_handler::get_is_right_trigger(u64 keyCode)
|
||||
bool xinput_pad_handler::get_is_right_trigger(const std::shared_ptr<PadDevice>& /*device*/, u64 keyCode)
|
||||
{
|
||||
return keyCode == XInputKeyCodes::RT;
|
||||
}
|
||||
|
||||
bool xinput_pad_handler::get_is_left_stick(u64 keyCode)
|
||||
bool xinput_pad_handler::get_is_left_stick(const std::shared_ptr<PadDevice>& /*device*/, u64 keyCode)
|
||||
{
|
||||
switch (keyCode)
|
||||
{
|
||||
@ -446,7 +446,7 @@ bool xinput_pad_handler::get_is_left_stick(u64 keyCode)
|
||||
}
|
||||
}
|
||||
|
||||
bool xinput_pad_handler::get_is_right_stick(u64 keyCode)
|
||||
bool xinput_pad_handler::get_is_right_stick(const std::shared_ptr<PadDevice>& /*device*/, u64 keyCode)
|
||||
{
|
||||
switch (keyCode)
|
||||
{
|
||||
|
@ -135,10 +135,10 @@ private:
|
||||
PFN_XINPUTGETBATTERYINFORMATION xinputGetBatteryInformation{ nullptr };
|
||||
|
||||
std::shared_ptr<PadDevice> get_device(const std::string& device) override;
|
||||
bool get_is_left_trigger(u64 keyCode) override;
|
||||
bool get_is_right_trigger(u64 keyCode) override;
|
||||
bool get_is_left_stick(u64 keyCode) override;
|
||||
bool get_is_right_stick(u64 keyCode) override;
|
||||
bool get_is_left_trigger(const std::shared_ptr<PadDevice>& device, u64 keyCode) override;
|
||||
bool get_is_right_trigger(const std::shared_ptr<PadDevice>& device, u64 keyCode) override;
|
||||
bool get_is_left_stick(const std::shared_ptr<PadDevice>& device, u64 keyCode) override;
|
||||
bool get_is_right_stick(const std::shared_ptr<PadDevice>& device, u64 keyCode) override;
|
||||
PadHandlerBase::connection update_connection(const std::shared_ptr<PadDevice>& device) override;
|
||||
void get_extended_info(const pad_ensemble& binding) override;
|
||||
void apply_pad_data(const pad_ensemble& binding) override;
|
||||
|
Loading…
Reference in New Issue
Block a user