Skip to content

Commit

Permalink
do not allow using keyboards and mice as HID controllers
Browse files Browse the repository at this point in the history
Enabling a keyboard or mouse as an HID controller makes it stop
working as a keyboard or mouse.
  • Loading branch information
Be-ing committed Aug 25, 2021
1 parent 3864fdc commit b4bfe76
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
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;
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;
}

// 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

0 comments on commit b4bfe76

Please sign in to comment.