MCPcopy Create free account
hub / github.com/Zalafina/QKeyMapper / getRefreshedKeyboardDeviceList

Method getRefreshedKeyboardDeviceList

QKeyMapper/interception_worker.cpp:592–684  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

590}
591
592QList<InputDevice> Interception_Worker::getRefreshedKeyboardDeviceList()
593{
594 QList<InputDevice> devicelist;
595 if (s_InterceptionContext == Q_NULLPTR) {
596 return devicelist;
597 }
598
599 WCHAR hardware_id[MAX_PATH];
600 for(InterceptionDevice device = INTERCEPTION_KEYBOARD(0); device <= INTERCEPTION_KEYBOARD(INTERCEPTION_MAX_KEYBOARD - 1); ++device)
601 {
602 InputDevice input_device = InputDevice();
603 size_t length = interception_get_hardware_id(s_InterceptionContext, device, hardware_id, sizeof(hardware_id));
604
605 input_device.device = device;
606 if(length > 0 && length < sizeof(hardware_id)) {
607 QString hardware_id_str = QString::fromWCharArray(hardware_id);
608 QString devicedesc = getDeviceDescriptionByHardwareID(hardware_id_str);
609 input_device.deviceinfo.hardwareid = hardware_id_str;
610 input_device.deviceinfo.devicedesc = devicedesc;
611
612 ushort vendorID = 0;
613 ushort productID = 0;
614 QString vendorIDStr;
615 QString productIDStr;
616 QString iManufacturerStr;
617 QString iProductStr;
618 static QRegularExpression regex(R"(VID_(\w+)&PID_(\w+))");
619 QRegularExpressionMatch match = regex.match(hardware_id_str);
620 if (match.hasMatch()) {
621 vendorIDStr = match.captured(1);
622 productIDStr = match.captured(2);
623 bool ok;
624 vendorID = vendorIDStr.toUShort(&ok, 16);
625 if (ok) {
626 input_device.deviceinfo.vendorid = vendorID;
627 }
628 productID = productIDStr.toUShort(&ok, 16);
629 if (ok) {
630 input_device.deviceinfo.productid = productID;
631 }
632 }
633
634 if (vendorID && productID) {
635 if (getUSBDeviceDescriptor(vendorID, productID, iManufacturerStr, iProductStr)) {
636 input_device.deviceinfo.ManufacturerStr = iManufacturerStr;
637 input_device.deviceinfo.ProductStr = iProductStr;
638 }
639
640 QString vendor_key = vendorIDStr.toLower() + QString("0000");
641 if (s_USBIDsMap.contains(vendor_key)) {
642 USBDeviceInfo deviceInfo = s_USBIDsMap.value(vendor_key);
643 input_device.deviceinfo.VendorStr = deviceInfo.vendorName;
644 }
645
646 QString product_key = vendorIDStr.toLower() + productIDStr.toLower();
647 if (s_USBIDsMap.contains(product_key)) {
648 USBDeviceInfo deviceInfo = s_USBIDsMap.value(product_key);
649 if (input_device.deviceinfo.ManufacturerStr.isEmpty()) {

Callers

nothing calls this directly

Calls 4

InputDeviceClass · 0.85
containsMethod · 0.80
valueMethod · 0.80
isEmptyMethod · 0.80

Tested by

no test coverage detected