--- a/cadMousePro-daemon/src/Daemon.h Tue Jun 09 22:13:44 2020 +0200
+++ b/cadMousePro-daemon/src/Daemon.h Sat Apr 03 17:39:35 2021 +0200
@@ -30,19 +30,28 @@
private:
- HIDDevice getMouse() {
- return HIDDevice(VENDOR_ID, PRODUCT_ID, nullptr);
- }
+ static unsigned short const VENDOR_ID = 0x256f;
+ static unsigned short const PRODUCT_ID_WIRELESS = 0xc652;
+ static unsigned short const PRODUCT_ID_WIRED = 0xc656;
void logException(const HIDException& e) {
std::wcout << L"HIDException: " << e.getMessage() << std::endl;
}
public:
- static unsigned short const VENDOR_ID = 0x256f;
- static unsigned short const PRODUCT_ID = 0xc652;
+ Daemon(QObject* parent = nullptr) : QObject(parent) {
+ }
- Daemon(QObject* parent = nullptr) : QObject(parent) {
+ static HIDDevice getMouse() {
+ // TODO: multiple mouse support, better mouse selection, specific settings for particular type…
+ // (probably after future redesign/rewrite – this is just a simple tool written for 3DConnexion CadMouse Pro)
+ std::vector<HIDDeviceInfo> devices = HIDDeviceInfo::enumerate();
+ for (auto pid :{PRODUCT_ID_WIRELESS, PRODUCT_ID_WIRED}) {
+ for (HIDDeviceInfo device : devices) {
+ if (device.matches(VENDOR_ID, pid)) return device.open();
+ }
+ }
+ throw HIDException(L"No suitable mouse found.");
}
Q_PROPERTY(bool devicePresent READ devicePresent)