input: fix mouse+kb combos
This commit is contained in:
@@ -201,8 +201,11 @@ basic_mouse_handler::mouse_button basic_mouse_handler::get_mouse_button(const cf
|
|||||||
|
|
||||||
if (it != mouse_list.cend())
|
if (it != mouse_list.cend())
|
||||||
{
|
{
|
||||||
|
u32 btn = it->first;
|
||||||
|
if (btn >= mouse::button) btn -= mouse::button;
|
||||||
|
|
||||||
return mouse_button{
|
return mouse_button{
|
||||||
.code = static_cast<int>(it->first),
|
.code = static_cast<int>(btn),
|
||||||
.is_key = false
|
.is_key = false
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -572,7 +572,7 @@ void keyboard_pad_handler::mousePressEvent(QMouseEvent* event)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Key(event->button(), true);
|
Key(mouse::button + static_cast<u32>(event->button()), true);
|
||||||
event->ignore();
|
event->ignore();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -583,7 +583,7 @@ void keyboard_pad_handler::mouseReleaseEvent(QMouseEvent* event)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Key(event->button(), false, 0);
|
Key(mouse::button + static_cast<u32>(event->button()), false, 0);
|
||||||
event->ignore();
|
event->ignore();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -902,13 +902,13 @@ std::string keyboard_pad_handler::GetKeyName(const u32& keyCode)
|
|||||||
return QKeySequence(keyCode).toString(QKeySequence::NativeText).toStdString();
|
return QKeySequence(keyCode).toString(QKeySequence::NativeText).toStdString();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::set<u32>> keyboard_pad_handler::GetKeyCombos(const cfg::string& cfg_string)
|
std::vector<std::set<u32>> keyboard_pad_handler::GetKeyCombos(const std::string& cfg_string)
|
||||||
{
|
{
|
||||||
std::vector<std::set<u32>> res;
|
std::vector<std::set<u32>> res;
|
||||||
|
|
||||||
for (const pad::combo& combo : cfg_pad::get_combos(cfg_string.to_string()))
|
for (const pad::combo& combo : cfg_pad::get_combos(cfg_string))
|
||||||
{
|
{
|
||||||
std::set<u32> key_codes;
|
std::set<u32> key_codes = find_key_codes(mouse_list, combo);
|
||||||
|
|
||||||
for (const std::string& button : combo.buttons())
|
for (const std::string& button : combo.buttons())
|
||||||
{
|
{
|
||||||
@@ -1062,8 +1062,7 @@ bool keyboard_pad_handler::bindPadToDevice(std::shared_ptr<Pad> pad)
|
|||||||
|
|
||||||
const auto find_combos = [this](const cfg::string& name)
|
const auto find_combos = [this](const cfg::string& name)
|
||||||
{
|
{
|
||||||
std::vector<std::set<u32>> combos = find_key_combos(mouse_list, name);
|
const std::vector<std::set<u32>> combos = GetKeyCombos(name.to_string());
|
||||||
for (const std::set<u32>& combo : GetKeyCombos(name)) combos.push_back(combo);
|
|
||||||
|
|
||||||
if (!combos.empty())
|
if (!combos.empty())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
enum mouse
|
enum mouse : u32
|
||||||
{
|
{
|
||||||
move_left = 0x05555550,
|
move_left = 0x05555550,
|
||||||
move_right = 0x05555551,
|
move_right = 0x05555551,
|
||||||
@@ -18,40 +18,41 @@ enum mouse
|
|||||||
wheel_up = 0x05555554,
|
wheel_up = 0x05555554,
|
||||||
wheel_down = 0x05555555,
|
wheel_down = 0x05555555,
|
||||||
wheel_left = 0x05555556,
|
wheel_left = 0x05555556,
|
||||||
wheel_right = 0x05555557
|
wheel_right = 0x05555557,
|
||||||
|
button = 0x80000000
|
||||||
};
|
};
|
||||||
|
|
||||||
// Unique button names for the config files and our pad settings dialog
|
// Unique button names for the config files and our pad settings dialog
|
||||||
const std::unordered_map<u32, std::string> mouse_list =
|
const std::unordered_map<u32, std::string> mouse_list =
|
||||||
{
|
{
|
||||||
{ Qt::NoButton , "" },
|
{ Qt::NoButton , "" },
|
||||||
{ Qt::LeftButton , "Mouse Left" },
|
{ mouse::button + static_cast<u32>(Qt::LeftButton) , "Mouse Left" },
|
||||||
{ Qt::RightButton , "Mouse Right" },
|
{ mouse::button + static_cast<u32>(Qt::RightButton) , "Mouse Right" },
|
||||||
{ Qt::MiddleButton , "Mouse Middle" },
|
{ mouse::button + static_cast<u32>(Qt::MiddleButton) , "Mouse Middle" },
|
||||||
{ Qt::BackButton , "Mouse Back" },
|
{ mouse::button + static_cast<u32>(Qt::BackButton) , "Mouse Back" },
|
||||||
{ Qt::ForwardButton , "Mouse Fwd" },
|
{ mouse::button + static_cast<u32>(Qt::ForwardButton) , "Mouse Fwd" },
|
||||||
{ Qt::TaskButton , "Mouse Task" },
|
{ mouse::button + static_cast<u32>(Qt::TaskButton) , "Mouse Task" },
|
||||||
{ Qt::ExtraButton4 , "Mouse 4" },
|
{ mouse::button + static_cast<u32>(Qt::ExtraButton4) , "Mouse 4" },
|
||||||
{ Qt::ExtraButton5 , "Mouse 5" },
|
{ mouse::button + static_cast<u32>(Qt::ExtraButton5) , "Mouse 5" },
|
||||||
{ Qt::ExtraButton6 , "Mouse 6" },
|
{ mouse::button + static_cast<u32>(Qt::ExtraButton6) , "Mouse 6" },
|
||||||
{ Qt::ExtraButton7 , "Mouse 7" },
|
{ mouse::button + static_cast<u32>(Qt::ExtraButton7) , "Mouse 7" },
|
||||||
{ Qt::ExtraButton8 , "Mouse 8" },
|
{ mouse::button + static_cast<u32>(Qt::ExtraButton8) , "Mouse 8" },
|
||||||
{ Qt::ExtraButton9 , "Mouse 9" },
|
{ mouse::button + static_cast<u32>(Qt::ExtraButton9) , "Mouse 9" },
|
||||||
{ Qt::ExtraButton10 , "Mouse 10" },
|
{ mouse::button + static_cast<u32>(Qt::ExtraButton10) , "Mouse 10" },
|
||||||
{ Qt::ExtraButton11 , "Mouse 11" },
|
{ mouse::button + static_cast<u32>(Qt::ExtraButton11) , "Mouse 11" },
|
||||||
{ Qt::ExtraButton12 , "Mouse 12" },
|
{ mouse::button + static_cast<u32>(Qt::ExtraButton12) , "Mouse 12" },
|
||||||
{ Qt::ExtraButton13 , "Mouse 13" },
|
{ mouse::button + static_cast<u32>(Qt::ExtraButton13) , "Mouse 13" },
|
||||||
{ Qt::ExtraButton14 , "Mouse 14" },
|
{ mouse::button + static_cast<u32>(Qt::ExtraButton14) , "Mouse 14" },
|
||||||
{ Qt::ExtraButton15 , "Mouse 15" },
|
{ mouse::button + static_cast<u32>(Qt::ExtraButton15) , "Mouse 15" },
|
||||||
{ Qt::ExtraButton16 , "Mouse 16" },
|
{ mouse::button + static_cast<u32>(Qt::ExtraButton16) , "Mouse 16" },
|
||||||
{ Qt::ExtraButton17 , "Mouse 17" },
|
{ mouse::button + static_cast<u32>(Qt::ExtraButton17) , "Mouse 17" },
|
||||||
{ Qt::ExtraButton18 , "Mouse 18" },
|
{ mouse::button + static_cast<u32>(Qt::ExtraButton18) , "Mouse 18" },
|
||||||
{ Qt::ExtraButton19 , "Mouse 19" },
|
{ mouse::button + static_cast<u32>(Qt::ExtraButton19) , "Mouse 19" },
|
||||||
{ Qt::ExtraButton20 , "Mouse 20" },
|
{ mouse::button + static_cast<u32>(Qt::ExtraButton20) , "Mouse 20" },
|
||||||
{ Qt::ExtraButton21 , "Mouse 21" },
|
{ mouse::button + static_cast<u32>(Qt::ExtraButton21) , "Mouse 21" },
|
||||||
{ Qt::ExtraButton22 , "Mouse 22" },
|
{ mouse::button + static_cast<u32>(Qt::ExtraButton22) , "Mouse 22" },
|
||||||
{ Qt::ExtraButton23 , "Mouse 23" },
|
{ mouse::button + static_cast<u32>(Qt::ExtraButton23) , "Mouse 23" },
|
||||||
{ Qt::ExtraButton24 , "Mouse 24" },
|
{ mouse::button + static_cast<u32>(Qt::ExtraButton24) , "Mouse 24" },
|
||||||
|
|
||||||
{ mouse::move_left , "Mouse MLeft" },
|
{ mouse::move_left , "Mouse MLeft" },
|
||||||
{ mouse::move_right , "Mouse MRight" },
|
{ mouse::move_right , "Mouse MRight" },
|
||||||
@@ -93,7 +94,7 @@ public:
|
|||||||
static QStringList GetKeyNames(const QKeyEvent* keyEvent);
|
static QStringList GetKeyNames(const QKeyEvent* keyEvent);
|
||||||
static std::string GetKeyName(const QKeyEvent* keyEvent, bool with_modifiers);
|
static std::string GetKeyName(const QKeyEvent* keyEvent, bool with_modifiers);
|
||||||
static std::string GetKeyName(const u32& keyCode);
|
static std::string GetKeyName(const u32& keyCode);
|
||||||
static std::vector<std::set<u32>> GetKeyCombos(const cfg::string& cfg_string);
|
static std::vector<std::set<u32>> GetKeyCombos(const std::string& cfg_string);
|
||||||
static u32 GetKeyCode(const QString& keyName);
|
static u32 GetKeyCode(const QString& keyName);
|
||||||
|
|
||||||
static int native_scan_code_from_string(const std::string& key);
|
static int native_scan_code_from_string(const std::string& key);
|
||||||
|
|||||||
Reference in New Issue
Block a user