mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-01-30 12:32:43 +00:00
HID: optimize get_next_button_press a bit
This commit is contained in:
parent
09875a5180
commit
bb03e17e2d
@ -327,8 +327,11 @@ void PadHandlerBase::get_next_button_press(const std::string& pad_id, const pad_
|
|||||||
fail_callback(pad_id);
|
fail_callback(pad_id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (status == connection::no_data)
|
|
||||||
|
if (status == connection::no_data)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Get the current button values
|
// Get the current button values
|
||||||
auto data = get_button_values(device);
|
auto data = get_button_values(device);
|
||||||
@ -337,10 +340,9 @@ void PadHandlerBase::get_next_button_press(const std::string& pad_id, const pad_
|
|||||||
// Return the new value if the button was pressed (aka. its value was bigger than 0 or the defined threshold)
|
// Return the new value if the button was pressed (aka. its value was bigger than 0 or the defined threshold)
|
||||||
// Use a pair to get all the legally pressed buttons and use the one with highest value (prioritize first)
|
// Use a pair to get all the legally pressed buttons and use the one with highest value (prioritize first)
|
||||||
std::pair<u16, std::string> pressed_button = { 0, "" };
|
std::pair<u16, std::string> pressed_button = { 0, "" };
|
||||||
for (const auto& button : button_list)
|
for (const auto& [keycode, name] : button_list)
|
||||||
{
|
{
|
||||||
const u32 keycode = button.first;
|
const u16& value = data[keycode];
|
||||||
const u16 value = data[keycode];
|
|
||||||
|
|
||||||
if (!get_blacklist && std::find(blacklist.begin(), blacklist.end(), keycode) != blacklist.end())
|
if (!get_blacklist && std::find(blacklist.begin(), blacklist.end(), keycode) != blacklist.end())
|
||||||
continue;
|
continue;
|
||||||
@ -354,10 +356,10 @@ void PadHandlerBase::get_next_button_press(const std::string& pad_id, const pad_
|
|||||||
if (get_blacklist)
|
if (get_blacklist)
|
||||||
{
|
{
|
||||||
blacklist.emplace_back(keycode);
|
blacklist.emplace_back(keycode);
|
||||||
input_log.error("%s Calibration: Added key [ %d = %s ] to blacklist. Value = %d", m_type, keycode, button.second, value);
|
input_log.error("%s Calibration: Added key [ %d = %s ] to blacklist. Value = %d", m_type, keycode, name, value);
|
||||||
}
|
}
|
||||||
else if (value > pressed_button.first)
|
else if (value > pressed_button.first)
|
||||||
pressed_button = { value, button.second };
|
pressed_button = { value, name };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -638,8 +640,8 @@ void PadHandlerBase::ThreadProc()
|
|||||||
{
|
{
|
||||||
for (usz i = 0; i < bindings.size(); ++i)
|
for (usz i = 0; i < bindings.size(); ++i)
|
||||||
{
|
{
|
||||||
auto device = bindings[i].first;
|
auto& device = bindings[i].first;
|
||||||
auto pad = bindings[i].second;
|
auto& pad = bindings[i].second;
|
||||||
|
|
||||||
if (!device || !pad)
|
if (!device || !pad)
|
||||||
continue;
|
continue;
|
||||||
|
@ -217,12 +217,9 @@ std::shared_ptr<Device> hid_pad_handler<Device>::get_hid_device(const std::strin
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
// Controllers 1-n in GUI
|
// Controllers 1-n in GUI
|
||||||
for (auto& cur_control : m_controllers)
|
if (auto it = m_controllers.find(padId); it != m_controllers.end())
|
||||||
{
|
{
|
||||||
if (padId == cur_control.first)
|
return it->second;
|
||||||
{
|
|
||||||
return cur_control.second;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user