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

Method getRefreshedMouseDeviceList

QKeyMapper/interception_worker.cpp:686–778  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

684}
685
686QList<InputDevice> Interception_Worker::getRefreshedMouseDeviceList()
687{
688 QList<InputDevice> devicelist;
689 if (s_InterceptionContext == Q_NULLPTR) {
690 return devicelist;
691 }
692
693 WCHAR hardware_id[MAX_PATH];
694 for(InterceptionDevice device = INTERCEPTION_MOUSE(0); device <= INTERCEPTION_MOUSE(INTERCEPTION_MAX_MOUSE - 1); ++device)
695 {
696 InputDevice input_device = InputDevice();
697 size_t length = interception_get_hardware_id(s_InterceptionContext, device, hardware_id, sizeof(hardware_id));
698
699 input_device.device = device;
700 if(length > 0 && length < sizeof(hardware_id)) {
701 QString hardware_id_str = QString::fromWCharArray(hardware_id);
702 QString devicedesc = getDeviceDescriptionByHardwareID(hardware_id_str);
703 input_device.deviceinfo.hardwareid = hardware_id_str;
704 input_device.deviceinfo.devicedesc = devicedesc;
705
706 ushort vendorID = 0;
707 ushort productID = 0;
708 QString vendorIDStr;
709 QString productIDStr;
710 QString iManufacturerStr;
711 QString iProductStr;
712 static QRegularExpression regex(R"(VID_(\w+)&PID_(\w+))");
713 QRegularExpressionMatch match = regex.match(hardware_id_str);
714 if (match.hasMatch()) {
715 vendorIDStr = match.captured(1);
716 productIDStr = match.captured(2);
717 bool ok;
718 vendorID = vendorIDStr.toUShort(&ok, 16);
719 if (ok) {
720 input_device.deviceinfo.vendorid = vendorID;
721 }
722 productID = productIDStr.toUShort(&ok, 16);
723 if (ok) {
724 input_device.deviceinfo.productid = productID;
725 }
726 }
727
728 if (vendorID && productID) {
729 if (getUSBDeviceDescriptor(vendorID, productID, iManufacturerStr, iProductStr)) {
730 input_device.deviceinfo.ManufacturerStr = iManufacturerStr;
731 input_device.deviceinfo.ProductStr = iProductStr;
732 }
733
734 QString vendor_key = vendorIDStr.toLower() + QString("0000");
735 if (s_USBIDsMap.contains(vendor_key)) {
736 USBDeviceInfo deviceInfo = s_USBIDsMap.value(vendor_key);
737 input_device.deviceinfo.VendorStr = deviceInfo.vendorName;
738 }
739
740 QString product_key = vendorIDStr.toLower() + productIDStr.toLower();
741 if (s_USBIDsMap.contains(product_key)) {
742 USBDeviceInfo deviceInfo = s_USBIDsMap.value(product_key);
743 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