2019-09-13 14:21:26 +00:00
|
|
|
#pragma once
|
2019-07-17 05:53:51 +00:00
|
|
|
|
2019-07-28 06:08:18 +00:00
|
|
|
#include <hid/DeviceMonitor.h>
|
|
|
|
#include <hidpp/SimpleDispatcher.h>
|
|
|
|
#include <hidpp10/Device.h>
|
|
|
|
#include <hidpp10/IReceiver.h>
|
|
|
|
#include <hidpp20/IReprogControls.h>
|
2019-09-20 20:20:06 +00:00
|
|
|
#include <unordered_map>
|
|
|
|
#include <list>
|
2019-07-28 06:08:18 +00:00
|
|
|
#include <thread>
|
2019-09-13 14:21:26 +00:00
|
|
|
#include <mutex>
|
2019-07-17 05:53:51 +00:00
|
|
|
|
2019-09-20 20:20:06 +00:00
|
|
|
#include "Device.h"
|
|
|
|
|
2019-07-28 06:08:18 +00:00
|
|
|
class Device;
|
2019-07-17 05:53:51 +00:00
|
|
|
|
2019-09-20 20:20:06 +00:00
|
|
|
struct PairedDevice {
|
|
|
|
Device *device;
|
|
|
|
std::thread associatedThread;
|
|
|
|
};
|
|
|
|
|
2019-07-17 05:53:51 +00:00
|
|
|
class DeviceFinder : public HID::DeviceMonitor
|
|
|
|
{
|
2019-07-28 06:08:18 +00:00
|
|
|
public:
|
2019-09-20 20:20:06 +00:00
|
|
|
~DeviceFinder();
|
|
|
|
|
|
|
|
void insertNewDevice (const std::string &path, HIDPP::DeviceIndex index);
|
|
|
|
void stopAndDeleteAllDevicesIn (const std::string &path);
|
|
|
|
void stopAndDeleteDevice (const std::string &path, HIDPP::DeviceIndex index);
|
2019-07-17 05:53:51 +00:00
|
|
|
protected:
|
|
|
|
void addDevice(const char* path);
|
|
|
|
void removeDevice(const char* path);
|
2019-09-13 14:21:26 +00:00
|
|
|
private:
|
|
|
|
std::mutex devicesMutex;
|
2019-09-20 20:20:06 +00:00
|
|
|
std::map<std::string, std::map<HIDPP::DeviceIndex, PairedDevice>> devices;
|
2019-07-17 05:53:51 +00:00
|
|
|
};
|
|
|
|
|
2019-07-28 06:08:18 +00:00
|
|
|
extern DeviceFinder* finder;
|
2019-07-17 05:53:51 +00:00
|
|
|
|