mf-hid.h
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2015 Intel Corporation. All Rights Reserved.
3 #pragma once
4 
5 #include "../backend.h"
6 #include "win/win-helpers.h"
7 
8 #include <Sensorsapi.h>
9 #include <atlcomcli.h>
10 
11 namespace librealsense
12 {
13  namespace platform
14  {
15 
17  public:
18  wmf_hid_sensor(const hid_device_info& device_info, CComPtr<ISensor> pISensor) :
19  _hid_device_info(device_info), _pISensor(pISensor)
20  {
21  BSTR fName{};
22 
23  auto res = pISensor->GetFriendlyName(&fName);
24  if (FAILED(res))
25  {
26  fName = L"Unidentified HID Sensor";
27  }
28 
29  _name = CW2A(fName);
30  SysFreeString(fName);
31  };
32 
33  const std::string& get_sensor_name() const { return _name; }
34  const CComPtr<ISensor>& get_sensor() const { return _pISensor; }
35 
36  HRESULT start_capture(ISensorEvents* sensorEvents)
37  {
38  return _pISensor->SetEventSink(sensorEvents);
39  }
40 
41  HRESULT stop_capture()
42  {
43  return _pISensor->SetEventSink(NULL);
44  }
45 
46  private:
47 
49  CComPtr<ISensor> _pISensor;
51  };
52 
53  class wmf_backend;
54 
55  class wmf_hid_device : public hid_device
56  {
57  public:
58  static void foreach_hid_device(std::function<void(hid_device_info, CComPtr<ISensor>)> action);
59  wmf_hid_device(const hid_device_info& info, std::shared_ptr<const wmf_backend> backend);
60 
61  void register_profiles(const std::vector<hid_profile>& hid_profiles) override { _hid_profiles = hid_profiles;}
62  void open(const std::vector<hid_profile>&iio_profiles) override;
63  void close() override;
64  void stop_capture() override;
65  void start_capture(hid_callback callback) override;
66  std::vector<hid_sensor> get_sensors() override; // Get opened sensors
67  std::vector<uint8_t> get_custom_report_data(const std::string& custom_sensor_name, const std::string& report_name, custom_sensor_report_field report_field) override;
68 
69  private:
70  // Don't move the position of wmf_backend member. This object must be destroyed only after COM objects.
71  std::shared_ptr<const wmf_backend> _backend;
72 
73  std::vector<std::shared_ptr<wmf_hid_sensor>> _connected_sensors; // Vector of all connected sensors of this device
74  std::vector<std::shared_ptr<wmf_hid_sensor>> _opened_sensors; // Vector of all opened sensors of this device (subclass of _connected_sensors)
75  std::vector<std::shared_ptr<wmf_hid_sensor>> _streaming_sensors; // Vector of all streaming sensors of this device (subclass of _connected_sensors)
76 
77  CComPtr<ISensorEvents> _cb;
78  std::vector<hid_profile> _hid_profiles;
79  };
80  }
81 }
CComPtr< ISensorEvents > _cb
Definition: mf-hid.h:77
std::vector< std::shared_ptr< wmf_hid_sensor > > _connected_sensors
Definition: mf-hid.h:73
std::vector< std::shared_ptr< wmf_hid_sensor > > _streaming_sensors
Definition: mf-hid.h:75
GLsizei const GLchar *const * string
const std::string & get_sensor_name() const
Definition: mf-hid.h:33
def info(name, value, persistent=False)
Definition: test.py:301
CComPtr< ISensor > _pISensor
Definition: mf-hid.h:49
def callback(frame)
Definition: t265_stereo.py:91
wmf_hid_sensor(const hid_device_info &device_info, CComPtr< ISensor > pISensor)
Definition: mf-hid.h:18
action
Definition: enums.py:62
const CComPtr< ISensor > & get_sensor() const
Definition: mf-hid.h:34
std::vector< hid_profile > _hid_profiles
Definition: mf-hid.h:78
HRESULT start_capture(ISensorEvents *sensorEvents)
Definition: mf-hid.h:36
std::shared_ptr< const wmf_backend > _backend
Definition: mf-hid.h:71
void register_profiles(const std::vector< hid_profile > &hid_profiles) override
Definition: mf-hid.h:61
#define NULL
Definition: tinycthread.c:47
GLuint res
Definition: glext.h:8856
std::function< void(const sensor_data &)> hid_callback
Definition: backend.h:327
std::vector< std::shared_ptr< wmf_hid_sensor > > _opened_sensors
Definition: mf-hid.h:74


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:47:21