cadMousePro-daemon/src/HID.h
author František Kučera <franta-hg@frantovo.cz>
Sat, 03 Apr 2021 17:39:35 +0200
branchv_0
changeset 33 0dc4e2942840
parent 26 fff8e9a86e85
permissions -rw-r--r--
support also the wired version of CadMouse Pro currently, there is a simple autodetection: we enumerate HID devices and look for the wireless version, if not found, we look for the wired version
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6
975f38eb1e12 license: GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
     1
/**
975f38eb1e12 license: GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
     2
 * cadMousePro
975f38eb1e12 license: GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
     3
 * Copyright © 2019 František Kučera (Frantovo.cz, GlobalCode.info)
975f38eb1e12 license: GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
     4
 *
975f38eb1e12 license: GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
     5
 * This program is free software: you can redistribute it and/or modify
975f38eb1e12 license: GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
26
fff8e9a86e85 fix license version: GNU GPLv3
František Kučera <franta-hg@frantovo.cz>
parents: 11
diff changeset
     7
 * the Free Software Foundation, version 3 of the License.
6
975f38eb1e12 license: GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
     8
 *
975f38eb1e12 license: GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
975f38eb1e12 license: GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
975f38eb1e12 license: GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
975f38eb1e12 license: GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
    12
 * GNU General Public License for more details.
975f38eb1e12 license: GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
    13
 *
975f38eb1e12 license: GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
    14
 * You should have received a copy of the GNU General Public License
975f38eb1e12 license: GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
    15
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
975f38eb1e12 license: GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
    16
 */
5
6799cec5c2f8 refactoring: separate into several files
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
    17
#pragma once
6799cec5c2f8 refactoring: separate into several files
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
    18
1
29cbe171cd43 first working version: disables „free wheel“ a.k.a. „smart scrolling“ feature
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    19
#include <array>
29cbe171cd43 first working version: disables „free wheel“ a.k.a. „smart scrolling“ feature
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    20
#include <vector>
4
405aa9de65d2 CadMouseConfig class, frequency, lift-off detection, smart scrolling
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
    21
#include <memory>
405aa9de65d2 CadMouseConfig class, frequency, lift-off detection, smart scrolling
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
    22
#include <unistd.h>
405aa9de65d2 CadMouseConfig class, frequency, lift-off detection, smart scrolling
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
    23
#include <cassert>
33
0dc4e2942840 support also the wired version of CadMouse Pro
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
    24
#include <string>
0dc4e2942840 support also the wired version of CadMouse Pro
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
    25
#include <vector>
0
6ff501639c23 project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    26
6ff501639c23 project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    27
#include <hidapi/hidapi.h>
4
405aa9de65d2 CadMouseConfig class, frequency, lift-off detection, smart scrolling
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
    28
405aa9de65d2 CadMouseConfig class, frequency, lift-off detection, smart scrolling
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
    29
using Packet = std::vector<uint8_t>;
405aa9de65d2 CadMouseConfig class, frequency, lift-off detection, smart scrolling
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
    30
static_assert(sizeof (uint8_t) == sizeof (unsigned char)); // unsigned char is used in the HID API library
0
6ff501639c23 project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    31
6ff501639c23 project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    32
class HIDException {
6ff501639c23 project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    33
private:
6ff501639c23 project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    34
	std::wstring message;
6ff501639c23 project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    35
public:
6ff501639c23 project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    36
6ff501639c23 project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    37
	HIDException(std::wstring message) : message(message) {
6ff501639c23 project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    38
	}
6ff501639c23 project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    39
6ff501639c23 project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    40
	virtual ~HIDException() {
6ff501639c23 project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    41
	}
1
29cbe171cd43 first working version: disables „free wheel“ a.k.a. „smart scrolling“ feature
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    42
0
6ff501639c23 project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    43
	const std::wstring getMessage() const {
6ff501639c23 project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    44
		return message;
6ff501639c23 project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    45
	}
6ff501639c23 project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    46
6ff501639c23 project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    47
};
6ff501639c23 project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    48
6ff501639c23 project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    49
class HIDDevice {
6ff501639c23 project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    50
private:
3
1197b42e8b2e use a smart pointer with custom deleter inside HIDDevice, so instances can be copied
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
    51
	std::shared_ptr<hid_device> handle;
2
abeba77ec581 private copy constructor (to avoid unwanted close() in copie's destructor)
František Kučera <franta-hg@frantovo.cz>
parents: 1
diff changeset
    52
0
6ff501639c23 project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    53
public:
6ff501639c23 project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    54
6ff501639c23 project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    55
	HIDDevice(unsigned short vendorId, unsigned short productId, const wchar_t *serialNumber) {
1
29cbe171cd43 first working version: disables „free wheel“ a.k.a. „smart scrolling“ feature
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    56
		int initError = hid_init(); // TODO: move to HIDContext class?
29cbe171cd43 first working version: disables „free wheel“ a.k.a. „smart scrolling“ feature
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    57
		if (initError) throw HIDException(L"Unable to init HID API.");
3
1197b42e8b2e use a smart pointer with custom deleter inside HIDDevice, so instances can be copied
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
    58
		handle.reset(hid_open(vendorId, productId, serialNumber), hid_close);
5
6799cec5c2f8 refactoring: separate into several files
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
    59
		if (handle == nullptr) throw HIDException(L"Unable to open HID device. Are you root? Is the device present?");
0
6ff501639c23 project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    60
	}
6ff501639c23 project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    61
6ff501639c23 project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    62
	virtual ~HIDDevice() {
1
29cbe171cd43 first working version: disables „free wheel“ a.k.a. „smart scrolling“ feature
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    63
		hid_exit(); // TODO: move to HIDContext class?
29cbe171cd43 first working version: disables „free wheel“ a.k.a. „smart scrolling“ feature
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    64
	}
29cbe171cd43 first working version: disables „free wheel“ a.k.a. „smart scrolling“ feature
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    65
29cbe171cd43 first working version: disables „free wheel“ a.k.a. „smart scrolling“ feature
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    66
	const std::wstring getManufacturerName() const {
29cbe171cd43 first working version: disables „free wheel“ a.k.a. „smart scrolling“ feature
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    67
		std::array<wchar_t, 200 > buffer;
3
1197b42e8b2e use a smart pointer with custom deleter inside HIDDevice, so instances can be copied
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
    68
		int error = hid_get_manufacturer_string(handle.get(), buffer.data(), buffer.size());
1
29cbe171cd43 first working version: disables „free wheel“ a.k.a. „smart scrolling“ feature
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    69
		if (error) throw HIDException(L"Unable to get manufacturer name.");
29cbe171cd43 first working version: disables „free wheel“ a.k.a. „smart scrolling“ feature
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    70
		return buffer.data();
0
6ff501639c23 project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    71
	}
6ff501639c23 project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    72
1
29cbe171cd43 first working version: disables „free wheel“ a.k.a. „smart scrolling“ feature
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    73
	const std::wstring getProductName() const {
29cbe171cd43 first working version: disables „free wheel“ a.k.a. „smart scrolling“ feature
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    74
		std::array<wchar_t, 200 > buffer;
3
1197b42e8b2e use a smart pointer with custom deleter inside HIDDevice, so instances can be copied
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
    75
		int error = hid_get_product_string(handle.get(), buffer.data(), buffer.size());
1
29cbe171cd43 first working version: disables „free wheel“ a.k.a. „smart scrolling“ feature
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    76
		if (error) throw HIDException(L"Unable to get product name.");
29cbe171cd43 first working version: disables „free wheel“ a.k.a. „smart scrolling“ feature
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    77
		return buffer.data();
29cbe171cd43 first working version: disables „free wheel“ a.k.a. „smart scrolling“ feature
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    78
	}
29cbe171cd43 first working version: disables „free wheel“ a.k.a. „smart scrolling“ feature
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    79
29cbe171cd43 first working version: disables „free wheel“ a.k.a. „smart scrolling“ feature
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    80
	const std::wstring getSerialNumber() const {
29cbe171cd43 first working version: disables „free wheel“ a.k.a. „smart scrolling“ feature
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    81
		std::array<wchar_t, 200 > buffer;
3
1197b42e8b2e use a smart pointer with custom deleter inside HIDDevice, so instances can be copied
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
    82
		int error = hid_get_serial_number_string(handle.get(), buffer.data(), buffer.size());
1
29cbe171cd43 first working version: disables „free wheel“ a.k.a. „smart scrolling“ feature
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    83
		if (error) throw HIDException(L"Unable to get serial number.");
29cbe171cd43 first working version: disables „free wheel“ a.k.a. „smart scrolling“ feature
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    84
		return buffer.data();
29cbe171cd43 first working version: disables „free wheel“ a.k.a. „smart scrolling“ feature
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    85
	}
29cbe171cd43 first working version: disables „free wheel“ a.k.a. „smart scrolling“ feature
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    86
11
bb42abd9f510 const reference → avoid copy
František Kučera <franta-hg@frantovo.cz>
parents: 8
diff changeset
    87
	void sendFeatureReport(const Packet& data) {
3
1197b42e8b2e use a smart pointer with custom deleter inside HIDDevice, so instances can be copied
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
    88
		int written = hid_send_feature_report(handle.get(), data.data(), data.size());
1
29cbe171cd43 first working version: disables „free wheel“ a.k.a. „smart scrolling“ feature
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    89
		if (written < 0) throw HIDException(L"Unable to send feature report.");
29cbe171cd43 first working version: disables „free wheel“ a.k.a. „smart scrolling“ feature
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    90
	}
0
6ff501639c23 project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    91
6ff501639c23 project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    92
};
33
0dc4e2942840 support also the wired version of CadMouse Pro
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
    93
0dc4e2942840 support also the wired version of CadMouse Pro
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
    94
class HIDDeviceInfo {
0dc4e2942840 support also the wired version of CadMouse Pro
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
    95
private:
0dc4e2942840 support also the wired version of CadMouse Pro
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
    96
	unsigned short vendorId;
0dc4e2942840 support also the wired version of CadMouse Pro
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
    97
	unsigned short productId;
0dc4e2942840 support also the wired version of CadMouse Pro
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
    98
	std::wstring serialNumber;
0dc4e2942840 support also the wired version of CadMouse Pro
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
    99
public:
0dc4e2942840 support also the wired version of CadMouse Pro
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   100
0dc4e2942840 support also the wired version of CadMouse Pro
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   101
	HIDDeviceInfo(unsigned short vendorId, unsigned short productId, std::wstring serialNumber) : vendorId(vendorId), productId(productId), serialNumber(serialNumber) {
0dc4e2942840 support also the wired version of CadMouse Pro
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   102
	}
0dc4e2942840 support also the wired version of CadMouse Pro
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   103
0dc4e2942840 support also the wired version of CadMouse Pro
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   104
	virtual ~HIDDeviceInfo() {
0dc4e2942840 support also the wired version of CadMouse Pro
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   105
	}
0dc4e2942840 support also the wired version of CadMouse Pro
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   106
0dc4e2942840 support also the wired version of CadMouse Pro
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   107
	HIDDevice open() {
0dc4e2942840 support also the wired version of CadMouse Pro
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   108
		return HIDDevice(vendorId, productId, serialNumber.size() ? serialNumber.c_str() : nullptr);
0dc4e2942840 support also the wired version of CadMouse Pro
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   109
	}
0dc4e2942840 support also the wired version of CadMouse Pro
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   110
0dc4e2942840 support also the wired version of CadMouse Pro
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   111
	bool matches(unsigned short vendorId, unsigned short productId) {
0dc4e2942840 support also the wired version of CadMouse Pro
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   112
		return vendorId == this->vendorId && productId == this->productId;
0dc4e2942840 support also the wired version of CadMouse Pro
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   113
	}
0dc4e2942840 support also the wired version of CadMouse Pro
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   114
0dc4e2942840 support also the wired version of CadMouse Pro
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   115
	bool matches(unsigned short vendorId, unsigned short productId, std::wstring serialNumber) {
0dc4e2942840 support also the wired version of CadMouse Pro
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   116
		return matches(vendorId, productId) && serialNumber == this->serialNumber;
0dc4e2942840 support also the wired version of CadMouse Pro
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   117
	}
0dc4e2942840 support also the wired version of CadMouse Pro
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   118
0dc4e2942840 support also the wired version of CadMouse Pro
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   119
	unsigned short getProductId() const {
0dc4e2942840 support also the wired version of CadMouse Pro
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   120
		return productId;
0dc4e2942840 support also the wired version of CadMouse Pro
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   121
	}
0dc4e2942840 support also the wired version of CadMouse Pro
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   122
0dc4e2942840 support also the wired version of CadMouse Pro
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   123
	std::wstring getSerialNumber() const {
0dc4e2942840 support also the wired version of CadMouse Pro
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   124
		return serialNumber;
0dc4e2942840 support also the wired version of CadMouse Pro
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   125
	}
0dc4e2942840 support also the wired version of CadMouse Pro
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   126
0dc4e2942840 support also the wired version of CadMouse Pro
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   127
	unsigned short getVendorId() const {
0dc4e2942840 support also the wired version of CadMouse Pro
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   128
		return vendorId;
0dc4e2942840 support also the wired version of CadMouse Pro
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   129
	}
0dc4e2942840 support also the wired version of CadMouse Pro
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   130
0dc4e2942840 support also the wired version of CadMouse Pro
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   131
	static std::vector<HIDDeviceInfo> enumerate(unsigned short vendorId = 0, unsigned short productId = 0) {
0dc4e2942840 support also the wired version of CadMouse Pro
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   132
		std::vector<HIDDeviceInfo> result;
0dc4e2942840 support also the wired version of CadMouse Pro
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   133
		std::shared_ptr<hid_device_info> rawList(hid_enumerate(vendorId, productId), hid_free_enumeration);
0dc4e2942840 support also the wired version of CadMouse Pro
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   134
		// n.b. for single USB device there might be multiple HID devices different just in di->path
0dc4e2942840 support also the wired version of CadMouse Pro
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   135
		for (hid_device_info* di = rawList.get(); di; di = di->next) result.push_back({di->vendor_id, di->product_id, di->serial_number});
0dc4e2942840 support also the wired version of CadMouse Pro
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   136
		return result;
0dc4e2942840 support also the wired version of CadMouse Pro
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   137
	}
0dc4e2942840 support also the wired version of CadMouse Pro
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   138
};