hid-device.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 
4 #pragma once
5 #include "../backend.h"
6 #include "hid-types.h"
7 #include "../usb/usb-messenger.h"
8 #include "../usb/usb-enumerator.h"
9 #include "../concurrency.h"
10 #include "stdio.h"
11 #include "stdlib.h"
12 
13 #include <cstring>
14 #include <string>
15 #include <chrono>
16 #include <thread>
17 #include "../types.h"
18 
19 #ifdef __APPLE__
20 #include <hidapi.h>
21 #endif
22 
23 namespace librealsense
24 {
25  namespace platform
26  {
27  std::vector<hid_device_info> query_hid_devices_info();
28  std::shared_ptr<hid_device> create_rshid_device(hid_device_info info);
29 
30  class rs_hid_device : public hid_device
31  {
32  public:
34  virtual ~rs_hid_device();
35 
36  void register_profiles(const std::vector<hid_profile>& hid_profiles) override { _hid_profiles = hid_profiles; }
37  void open(const std::vector<hid_profile>& hid_profiles) override;
38  void close() override;
39  void stop_capture() override;
40  void start_capture(hid_callback callback) override;
41  std::vector<hid_sensor> get_sensors() override;
42  virtual std::vector<uint8_t> get_custom_report_data(const std::string& custom_sensor_name,
43  const std::string& report_name,
44  custom_sensor_report_field report_field) override { return {}; }
45 
46  private:
47  void handle_interrupt();
50  usb_status set_feature_report(unsigned char power, int report_id, int fps = 0);
51 #ifdef __APPLE__
52  int hidapi_PowerDevice(unsigned char reportId);
53 #endif
54 
55  bool _running = false;
57 
60 #ifdef __APPLE__
61  hidapi_device* _hidapi_device = nullptr;
62 #else
64  std::vector<rs_usb_request> _requests;
65  std::shared_ptr<platform::usb_request_callback> _request_callback;
66 #endif
67 
68  std::vector<hid_profile> _hid_profiles;
69  std::map<int, std::string> _id_to_sensor;
70  std::map<std::string, int> _sensor_to_id;
71  std::vector<hid_profile> _configured_profiles;
73  std::shared_ptr<active_object<>> _handle_interrupts_thread;
74  };
75  }
76 }
std::map< std::string, int > _sensor_to_id
Definition: hid-device.h:70
virtual 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
Definition: hid-device.h:42
std::shared_ptr< active_object<> > _handle_interrupts_thread
Definition: hid-device.h:73
std::shared_ptr< usb_interface > rs_usb_interface
Definition: usb-interface.h:31
std::vector< hid_sensor > get_sensors() override
Definition: hid-device.cpp:84
void open(const std::vector< hid_profile > &hid_profiles) override
Definition: hid-device.cpp:94
std::shared_ptr< hid_device > create_rshid_device(hid_device_info info)
Definition: hid-device.cpp:38
GLsizei const GLchar *const * string
usb_status set_feature_report(unsigned char power, int report_id, int fps=0)
Definition: hid-device.cpp:236
enum librealsense::platform::_usb_status usb_status
def info(name, value, persistent=False)
Definition: test.py:301
void start_capture(hid_callback callback) override
Definition: hid-device.cpp:133
std::vector< hid_device_info > query_hid_devices_info()
Definition: hid-device.cpp:13
std::shared_ptr< usb_endpoint > rs_usb_endpoint
Definition: usb-endpoint.h:24
single_consumer_queue< REALSENSE_HID_REPORT > _queue
Definition: hid-device.h:72
std::shared_ptr< usb_messenger > rs_usb_messenger
Definition: usb-messenger.h:26
def callback(frame)
Definition: t265_stereo.py:91
std::shared_ptr< platform::usb_request_callback > _request_callback
Definition: hid-device.h:65
rs_hid_device(rs_usb_device usb_device)
Definition: hid-device.cpp:53
std::vector< hid_profile > _hid_profiles
Definition: hid-device.h:68
void register_profiles(const std::vector< hid_profile > &hid_profiles) override
Definition: hid-device.h:36
std::vector< rs_usb_request > _requests
Definition: hid-device.h:64
std::map< int, std::string > _id_to_sensor
Definition: hid-device.h:69
std::function< void(const sensor_data &)> hid_callback
Definition: backend.h:327
std::vector< hid_profile > _configured_profiles
Definition: hid-device.h:71
std::shared_ptr< usb_device > rs_usb_device
Definition: usb-device.h:29


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