Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do not allow using keyboards and mice as HID controllers #4243

Merged
merged 1 commit into from
Sep 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/controllers/hid/hidcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,8 @@ void HidController::guessDeviceCategory() {
if (hid_interface_number==-1) {
if (hid_usage_page==0x1) {
switch (hid_usage) {
case 0x2: info = tr("Generic HID Mouse"); break;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change seem to be unrelated.
Now it runs to the default branch which is less describtive.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These devices do not appear in the GUI because they are filtered out in HidEnumerator.

case 0x4: info = tr("Generic HID Joystick"); break;
case 0x5: info = tr("Generic HID Gamepad"); break;
case 0x6: info = tr("Generic HID Keyboard"); break;
case 0x8: info = tr("Generic HID Multiaxis Controller"); break;
default: info = tr("Unknown HID Desktop Device") +
QStringLiteral(" 0x") + QString::number(hid_usage_page, 16) +
Expand Down
5 changes: 5 additions & 0 deletions src/controllers/hid/hiddenylist.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,8 @@ hid_denylist_t hid_denylisted[] = {
{0x1157, 0x300, 0x1, 0x2, -1}, // EKS Otus mouse pad (OS/X,windows)
{0x1157, 0x300, 0x0, 0x0, 0x3}, // EKS Otus mouse pad (linux)
};

constexpr unsigned short kGenericDesktopUsagePage = 0x01;

constexpr unsigned short kGenericDesktopMouseUsage = 0x02;
constexpr unsigned short kGenericDesktopKeyboardUsage = 0x06;
10 changes: 10 additions & 0 deletions src/controllers/hid/hidenumerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@
namespace {

bool recognizeDevice(const hid_device_info& device_info) {
// Skip mice and keyboards. Users can accidentally disable their mouse
// and/or keyboard by enabling them as HID controllers in Mixxx.
// https://bugs.launchpad.net/mixxx/+bug/1940599
if (device_info.usage_page == kGenericDesktopUsagePage &&
(device_info.usage == kGenericDesktopMouseUsage ||
device_info.usage == kGenericDesktopKeyboardUsage)) {
return false;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move this to the default deny list instead?
That would be the natural place.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried that at first but the backwards logic made it really confusing. I think this implementation is more straightforward. First there is this check for all mice and keyboards, then the denlylist is used to filter specific device models.


// Exclude specific devices from the denylist.
bool interface_number_valid = device_info.interface_number != -1;
const int denylist_len = sizeof(hid_denylisted) / sizeof(hid_denylisted[0]);
for (int bl_index = 0; bl_index < denylist_len; bl_index++) {
Expand Down