From 3e31cb1a0b33acbc6e2be9d993fc884ed0c6dd97 Mon Sep 17 00:00:00 2001 From: noacoohen Date: Sun, 14 Apr 2024 13:36:35 +0300 Subject: [PATCH 01/15] add rsusb support for imu sensitivity --- src/hid/hid-device.cpp | 63 ++++++++++++++++++++++++++++++++++++++---- src/hid/hid-device.h | 6 ++-- src/hid/hid-types.h | 12 ++++---- 3 files changed, 68 insertions(+), 13 deletions(-) diff --git a/src/hid/hid-device.cpp b/src/hid/hid-device.cpp index 41d44bdc17..f370855811 100644 --- a/src/hid/hid-device.cpp +++ b/src/hid/hid-device.cpp @@ -100,7 +100,7 @@ namespace librealsense { for(auto&& p : hid_profiles) { - set_feature_report(DEVICE_POWER_D0, _sensor_to_id[p.sensor_name], p.frequency); + set_feature_report( DEVICE_POWER_D0, _sensor_to_id[p.sensor_name], p.frequency, p.sensitivity ); } _configured_profiles = hid_profiles; } @@ -161,10 +161,30 @@ namespace librealsense { if(!_running) return; - if(r->get_actual_length() == sizeof(REALSENSE_HID_REPORT)) + + if( r->get_actual_length() == _realsense_hid_report_actual_size ) { REALSENSE_HID_REPORT report; - memcpy(&report, r->get_buffer().data(), r->get_actual_length()); + if( _realsense_hid_report_actual_size != sizeof( REALSENSE_HID_REPORT ) ) + { + //for FX version<5.16 the actual struct is 32 bit, so we can not use memcpy for the whole struct + //for FX version<5.16 x,y,x are all short with the x variable located at offset 10, y at offset 12, and z at offset 14 within the structure. + memcpy( &report, r->get_buffer().data(), 10 ); + const int16_t * x + = reinterpret_cast< const int16_t * >( r->get_buffer().data() + 10 ); + const int16_t * y + = reinterpret_cast< const int16_t * >( r->get_buffer().data() + 12 ); + const int16_t * z + = reinterpret_cast< const int16_t * >( r->get_buffer().data() + 14 ); + report.x = *x; + report.y = *y; + report.z = *z; + memcpy( &report + 22, r->get_buffer().data() + 16, 16 ); + } + else + { + memcpy( &report, r->get_buffer().data(), r->get_actual_length() ); + } _queue.enqueue(std::move(report)); } auto sts = _messenger->submit_request(r); @@ -195,7 +215,27 @@ namespace librealsense { REALSENSE_HID_REPORT report; #ifdef __APPLE__ - hid_read(_hidapi_device, reinterpret_cast(&report), sizeof(REALSENSE_HID_REPORT)); + unsigned char tmp_buffer[100] = { 0 }; + hid_read( _hidapi_device, &tmp_buffer, _realsense_hid_report_actual_size ); + if( _realsense_hid_report_actual_size != sizeof( REALSENSE_HID_REPORT ) ) + { + // for FX version<5.16 the actual struct is 32 bit, so we can not use memcpy for the whole struct + // for FX version<5.16 x,y,x are all short with the x variable located at offset 10, y at offset 12, and + // z at offset 14 within the structure. + memcpy( &report, tmp_buffer, 10 ); + const int16_t * x = reinterpret_cast< const int16_t * >( tmp_buffer + 10 ); + const int16_t * y = reinterpret_cast< const int16_t * >( tmp_buffer + 12 ); + const int16_t * z = reinterpret_cast< const int16_t * >( tmp_buffer + 14 ); + report.x = *x; + report.y = *y; + report.z = *z; + memcpy( &report + 22, tmp_buffer + 16, 16 ); + } + else + { + memcpy( &report, tmp_buffer, sizeof( REALSENSE_HID_REPORT ) ); + } + sensor_data data{}; data.sensor = { _id_to_sensor[report.reportId] }; @@ -238,7 +278,7 @@ namespace librealsense #endif } - usb_status rs_hid_device::set_feature_report(unsigned char power, int report_id, int fps) + usb_status rs_hid_device::set_feature_report( unsigned char power, int report_id, int fps, double sensitivity) { uint32_t transferred; @@ -273,6 +313,12 @@ namespace librealsense if(fps > 0) featureReport.report = (1000 / fps); + //we want to change the sensitivity values only in gyro, for FW version>=5.16 + if( (int)featureReport.reportId == REPORT_ID_GYROMETER_3D + && _realsense_hid_report_actual_size == sizeof( FEATURE_REPORT ) ) + featureReport.sensitivity = sensitivity; + + res = dev->control_transfer(USB_REQUEST_CODE_SET, HID_REQUEST_SET_REPORT, value, @@ -384,5 +430,12 @@ namespace librealsense return ep; } + + void rs_hid_device::set_gyro_scale_factor(double scale_factor) + { + _gyro_scale_factor = scale_factor; + if( scale_factor == 10000.0 ) + _realsense_hid_report_actual_size = 38; + } } } diff --git a/src/hid/hid-device.h b/src/hid/hid-device.h index 630c645c7a..c302f58d7d 100644 --- a/src/hid/hid-device.h +++ b/src/hid/hid-device.h @@ -43,13 +43,13 @@ namespace librealsense virtual std::vector get_custom_report_data(const std::string& custom_sensor_name, const std::string& report_name, custom_sensor_report_field report_field) override { return {}; } - void set_gyro_scale_factor( double scale_factor ) override{}; + void set_gyro_scale_factor( double scale_factor ) override; private: void handle_interrupt(); rs_usb_endpoint get_hid_endpoint(); rs_usb_interface get_hid_interface(); - usb_status set_feature_report(unsigned char power, int report_id, int fps = 0); + usb_status set_feature_report( unsigned char power, int report_id, int fps = 0, double sensitivity = 1 ); #ifdef __APPLE__ int hidapi_PowerDevice(unsigned char reportId); #endif @@ -73,6 +73,8 @@ namespace librealsense std::vector _configured_profiles; single_consumer_queue _queue; std::shared_ptr> _handle_interrupts_thread; + int _realsense_hid_report_actual_size = 32; // for FW version >=5.16 the struct changed to 38 bit + double _gyro_scale_factor = 10.0; }; } } diff --git a/src/hid/hid-types.h b/src/hid/hid-types.h index 797d7a89df..6f46903369 100644 --- a/src/hid/hid-types.h +++ b/src/hid/hid-types.h @@ -50,16 +50,16 @@ namespace librealsense unsigned char power; unsigned char minReport; unsigned short report; - unsigned short unknown; + unsigned short sensitivity; }; struct REALSENSE_HID_REPORT { unsigned char reportId; unsigned char unknown; unsigned long long timeStamp; - short x; - short y; - short z; + int32_t x; + int32_t y; + int32_t z; unsigned int customValue1; unsigned int customValue2; unsigned short customValue3; @@ -70,7 +70,7 @@ namespace librealsense }; #pragma pack(pop) - static_assert(sizeof(REALSENSE_HID_REPORT) == SIZE_OF_HID_IMU_FRAME, "HID IMU Frame struct expected size is 32 bytes"); + //static_assert(sizeof(REALSENSE_HID_REPORT) == SIZE_OF_HID_IMU_FRAME, "HID IMU Frame struct expected size is 32 bytes"); #pragma pack(push, 1) struct FEATURE_REPORT @@ -81,7 +81,7 @@ namespace librealsense unsigned char power; unsigned char minReport; unsigned short report; - unsigned short unknown; + unsigned short sensitivity; }; #pragma pack(pop) } From 817e87bd31d87295a83a3e841404b781b90630ea Mon Sep 17 00:00:00 2001 From: noacoohen Date: Tue, 16 Apr 2024 14:05:44 +0300 Subject: [PATCH 02/15] remove assert --- src/hid/hid-types.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/hid/hid-types.h b/src/hid/hid-types.h index 6f46903369..df861914a9 100644 --- a/src/hid/hid-types.h +++ b/src/hid/hid-types.h @@ -18,7 +18,6 @@ #define REPORT_ID_GYROMETER_3D 2 #define REPORT_ID_CUSTOM 3 -const size_t SIZE_OF_HID_IMU_FRAME = 32; static std::string gyro = "gyro_3d"; static std::string accel = "accel_3d"; @@ -70,7 +69,6 @@ namespace librealsense }; #pragma pack(pop) - //static_assert(sizeof(REALSENSE_HID_REPORT) == SIZE_OF_HID_IMU_FRAME, "HID IMU Frame struct expected size is 32 bytes"); #pragma pack(push, 1) struct FEATURE_REPORT From 77977b26dfd388585dc2acce0ace8a3621b6bf54 Mon Sep 17 00:00:00 2001 From: noacoohen Date: Tue, 16 Apr 2024 14:13:58 +0300 Subject: [PATCH 03/15] remove & --- src/hid/hid-device.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hid/hid-device.cpp b/src/hid/hid-device.cpp index f370855811..12e03dd946 100644 --- a/src/hid/hid-device.cpp +++ b/src/hid/hid-device.cpp @@ -216,7 +216,7 @@ namespace librealsense REALSENSE_HID_REPORT report; #ifdef __APPLE__ unsigned char tmp_buffer[100] = { 0 }; - hid_read( _hidapi_device, &tmp_buffer, _realsense_hid_report_actual_size ); + hid_read( _hidapi_device, tmp_buffer, _realsense_hid_report_actual_size ); if( _realsense_hid_report_actual_size != sizeof( REALSENSE_HID_REPORT ) ) { // for FX version<5.16 the actual struct is 32 bit, so we can not use memcpy for the whole struct From c61887746754dc4c309183da1a1082b2a70c4b62 Mon Sep 17 00:00:00 2001 From: noacoohen Date: Tue, 16 Apr 2024 14:31:10 +0300 Subject: [PATCH 04/15] fix PR comments --- src/hid/hid-device.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hid/hid-device.cpp b/src/hid/hid-device.cpp index 12e03dd946..adb3695ad6 100644 --- a/src/hid/hid-device.cpp +++ b/src/hid/hid-device.cpp @@ -167,8 +167,8 @@ namespace librealsense REALSENSE_HID_REPORT report; if( _realsense_hid_report_actual_size != sizeof( REALSENSE_HID_REPORT ) ) { - //for FX version<5.16 the actual struct is 32 bit, so we can not use memcpy for the whole struct - //for FX version<5.16 x,y,x are all short with the x variable located at offset 10, y at offset 12, and z at offset 14 within the structure. + //for FX version < 5.16 the actual struct is 32 bit, so we can not use memcpy for the whole struct + //for FW version < 5.16 x,y,x are all short with the x variable located at offset 10, y at offset 12, and z at offset 14 within the structure. memcpy( &report, r->get_buffer().data(), 10 ); const int16_t * x = reinterpret_cast< const int16_t * >( r->get_buffer().data() + 10 ); @@ -315,7 +315,7 @@ namespace librealsense //we want to change the sensitivity values only in gyro, for FW version>=5.16 if( (int)featureReport.reportId == REPORT_ID_GYROMETER_3D - && _realsense_hid_report_actual_size == sizeof( FEATURE_REPORT ) ) + && _realsense_hid_report_actual_size == sizeof( REALSENSE_HID_REPORT ) ) featureReport.sensitivity = sensitivity; From 1d571a60e1ea00144b5f6a5c8618e8b5334095e9 Mon Sep 17 00:00:00 2001 From: noacoohen Date: Tue, 16 Apr 2024 14:57:26 +0300 Subject: [PATCH 05/15] fix PR comments --- src/ds/d400/d400-motion.cpp | 2 +- src/hid/hid-device.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ds/d400/d400-motion.cpp b/src/ds/d400/d400-motion.cpp index 760f6008f9..d6f3772a2b 100644 --- a/src/ds/d400/d400-motion.cpp +++ b/src/ds/d400/d400-motion.cpp @@ -134,7 +134,7 @@ namespace librealsense hid_ep->get_raw_sensor()->register_metadata(RS2_FRAME_METADATA_FRAME_TIMESTAMP, make_hid_header_parser(&hid_header::timestamp)); } //for FW >=5.16 the scale factor changes to 1000.0 since FW sends 32bit - if (_fw_version >= firmware_version( 5, 15, 1, 224)) + if (_fw_version >= firmware_version( 5, 16, 0, 0)) get_raw_motion_sensor()->set_gyro_scale_factor( 10000.0 ); } diff --git a/src/hid/hid-device.cpp b/src/hid/hid-device.cpp index adb3695ad6..42b3bdc094 100644 --- a/src/hid/hid-device.cpp +++ b/src/hid/hid-device.cpp @@ -167,7 +167,7 @@ namespace librealsense REALSENSE_HID_REPORT report; if( _realsense_hid_report_actual_size != sizeof( REALSENSE_HID_REPORT ) ) { - //for FX version < 5.16 the actual struct is 32 bit, so we can not use memcpy for the whole struct + //for FW version < 5.16 the actual struct is 32 bit, so we can not use memcpy for the whole struct //for FW version < 5.16 x,y,x are all short with the x variable located at offset 10, y at offset 12, and z at offset 14 within the structure. memcpy( &report, r->get_buffer().data(), 10 ); const int16_t * x @@ -219,8 +219,8 @@ namespace librealsense hid_read( _hidapi_device, tmp_buffer, _realsense_hid_report_actual_size ); if( _realsense_hid_report_actual_size != sizeof( REALSENSE_HID_REPORT ) ) { - // for FX version<5.16 the actual struct is 32 bit, so we can not use memcpy for the whole struct - // for FX version<5.16 x,y,x are all short with the x variable located at offset 10, y at offset 12, and + // for FW version<5.16 the actual struct is 32 bit, so we can not use memcpy for the whole struct + // for FW version<5.16 x,y,x are all short with the x variable located at offset 10, y at offset 12, and // z at offset 14 within the structure. memcpy( &report, tmp_buffer, 10 ); const int16_t * x = reinterpret_cast< const int16_t * >( tmp_buffer + 10 ); From 8e001ebabb4bd7a11b5ca7b594858f21f1bfc151 Mon Sep 17 00:00:00 2001 From: noacoohen Date: Tue, 16 Apr 2024 15:00:42 +0300 Subject: [PATCH 06/15] add comment --- src/hid/hid-device.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/hid/hid-device.cpp b/src/hid/hid-device.cpp index 42b3bdc094..69f85111c7 100644 --- a/src/hid/hid-device.cpp +++ b/src/hid/hid-device.cpp @@ -434,6 +434,7 @@ namespace librealsense void rs_hid_device::set_gyro_scale_factor(double scale_factor) { _gyro_scale_factor = scale_factor; + // for FW >=5.16 the scale factor changes to 1000.0 since FW sends 32bit if( scale_factor == 10000.0 ) _realsense_hid_report_actual_size = 38; } From 6fc96dabb2e579dfe75c6f6fe9279d8c646a8a74 Mon Sep 17 00:00:00 2001 From: noacoohen Date: Tue, 16 Apr 2024 15:15:54 +0300 Subject: [PATCH 07/15] fix comment --- src/hid/hid-device.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hid/hid-device.cpp b/src/hid/hid-device.cpp index 69f85111c7..71c2448ddc 100644 --- a/src/hid/hid-device.cpp +++ b/src/hid/hid-device.cpp @@ -168,7 +168,7 @@ namespace librealsense if( _realsense_hid_report_actual_size != sizeof( REALSENSE_HID_REPORT ) ) { //for FW version < 5.16 the actual struct is 32 bit, so we can not use memcpy for the whole struct - //for FW version < 5.16 x,y,x are all short with the x variable located at offset 10, y at offset 12, and z at offset 14 within the structure. + //x,y,x are all short with the x variable located at offset 10, y at offset 12, and z at offset 14 within the structure. memcpy( &report, r->get_buffer().data(), 10 ); const int16_t * x = reinterpret_cast< const int16_t * >( r->get_buffer().data() + 10 ); @@ -220,7 +220,7 @@ namespace librealsense if( _realsense_hid_report_actual_size != sizeof( REALSENSE_HID_REPORT ) ) { // for FW version<5.16 the actual struct is 32 bit, so we can not use memcpy for the whole struct - // for FW version<5.16 x,y,x are all short with the x variable located at offset 10, y at offset 12, and + // x,y,x are all short with the x variable located at offset 10, y at offset 12, and // z at offset 14 within the structure. memcpy( &report, tmp_buffer, 10 ); const int16_t * x = reinterpret_cast< const int16_t * >( tmp_buffer + 10 ); From 346809376de9165feb04de12783aae9c06cc1d30 Mon Sep 17 00:00:00 2001 From: noacoohen Date: Tue, 16 Apr 2024 16:13:30 +0300 Subject: [PATCH 08/15] fix typo --- src/hid/hid-device.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hid/hid-device.cpp b/src/hid/hid-device.cpp index 71c2448ddc..3ef62c1c96 100644 --- a/src/hid/hid-device.cpp +++ b/src/hid/hid-device.cpp @@ -434,7 +434,7 @@ namespace librealsense void rs_hid_device::set_gyro_scale_factor(double scale_factor) { _gyro_scale_factor = scale_factor; - // for FW >=5.16 the scale factor changes to 1000.0 since FW sends 32bit + // for FW >=5.16 the scale factor changes to 10000.0 since FW sends 32bit if( scale_factor == 10000.0 ) _realsense_hid_report_actual_size = 38; } From da6da84237e5b028a560e45fa051cde7908b1b13 Mon Sep 17 00:00:00 2001 From: noacoohen Date: Wed, 17 Apr 2024 10:49:14 +0300 Subject: [PATCH 09/15] edit comments and use offsetof --- src/hid/hid-device.cpp | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/src/hid/hid-device.cpp b/src/hid/hid-device.cpp index 3ef62c1c96..32e3f5072d 100644 --- a/src/hid/hid-device.cpp +++ b/src/hid/hid-device.cpp @@ -164,11 +164,17 @@ namespace librealsense if( r->get_actual_length() == _realsense_hid_report_actual_size ) { + // for FW version < 5.16 the actual struct is 32 bytes (each IMU axis is 16 bit), so we + // can not use memcpy for + // the whole struct as the new struct (size 38) expect 32 bits for each. + // For FW >= 5.16 we can just use memcpy as the structs size match REALSENSE_HID_REPORT report; if( _realsense_hid_report_actual_size != sizeof( REALSENSE_HID_REPORT ) ) { - //for FW version < 5.16 the actual struct is 32 bit, so we can not use memcpy for the whole struct - //x,y,x are all short with the x variable located at offset 10, y at offset 12, and z at offset 14 within the structure. + + // x,y,z are all short with: x at offset 10 + // y at offset 12 + // z at offset 14 memcpy( &report, r->get_buffer().data(), 10 ); const int16_t * x = reinterpret_cast< const int16_t * >( r->get_buffer().data() + 10 ); @@ -179,10 +185,14 @@ namespace librealsense report.x = *x; report.y = *y; report.z = *z; - memcpy( &report + 22, r->get_buffer().data() + 16, 16 ); + memcpy( &report + offsetof( REALSENSE_HID_REPORT, customValue1 ), + r->get_buffer().data() + 16, + 16 ); } else { + // the rest of the data in the old struct size (after z element) starts from offset + // 16 and has 16 bytes till end memcpy( &report, r->get_buffer().data(), r->get_actual_length() ); } _queue.enqueue(std::move(report)); @@ -214,14 +224,21 @@ namespace librealsense void rs_hid_device::handle_interrupt() { REALSENSE_HID_REPORT report; + + // for FW version < 5.16 the actual struct is 32 bytes (each IMU axis is 16 bit), so we can not use memcpy for + // the whole struct as the new struct (size 38) expect 32 bits for each. + // For FW >= 5.16 we can just use memcpy as the structs size match + + #ifdef __APPLE__ unsigned char tmp_buffer[100] = { 0 }; hid_read( _hidapi_device, tmp_buffer, _realsense_hid_report_actual_size ); if( _realsense_hid_report_actual_size != sizeof( REALSENSE_HID_REPORT ) ) { - // for FW version<5.16 the actual struct is 32 bit, so we can not use memcpy for the whole struct - // x,y,x are all short with the x variable located at offset 10, y at offset 12, and - // z at offset 14 within the structure. + + // x,y,z are all short with: x at offset 10 + // y at offset 12 + // z at offset 14 memcpy( &report, tmp_buffer, 10 ); const int16_t * x = reinterpret_cast< const int16_t * >( tmp_buffer + 10 ); const int16_t * y = reinterpret_cast< const int16_t * >( tmp_buffer + 12 ); @@ -229,7 +246,9 @@ namespace librealsense report.x = *x; report.y = *y; report.z = *z; - memcpy( &report + 22, tmp_buffer + 16, 16 ); + + // the rest of the data in the old struct size (after z element) starts from offset 16 and has 16 bytes till end + memcpy( &report + offsetof( REALSENSE_HID_REPORT, customValue1 ), tmp_buffer + 16, 16 ); } else { @@ -313,7 +332,7 @@ namespace librealsense if(fps > 0) featureReport.report = (1000 / fps); - //we want to change the sensitivity values only in gyro, for FW version>=5.16 + //we want to change the sensitivity values only in gyro, for FW version >= 5.16 if( (int)featureReport.reportId == REPORT_ID_GYROMETER_3D && _realsense_hid_report_actual_size == sizeof( REALSENSE_HID_REPORT ) ) featureReport.sensitivity = sensitivity; From be10503a1c0054d506ab1310a8e0e9b6f4cd023a Mon Sep 17 00:00:00 2001 From: noacoohen Date: Wed, 17 Apr 2024 12:17:30 +0300 Subject: [PATCH 10/15] fix PR comments --- src/hid/hid-device.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/hid/hid-device.cpp b/src/hid/hid-device.cpp index 32e3f5072d..3d471069c9 100644 --- a/src/hid/hid-device.cpp +++ b/src/hid/hid-device.cpp @@ -185,9 +185,8 @@ namespace librealsense report.x = *x; report.y = *y; report.z = *z; - memcpy( &report + offsetof( REALSENSE_HID_REPORT, customValue1 ), - r->get_buffer().data() + 16, - 16 ); + memcpy( &report.customValue1, r->get_buffer().data() + 16, 16 ); + } else { @@ -248,7 +247,7 @@ namespace librealsense report.z = *z; // the rest of the data in the old struct size (after z element) starts from offset 16 and has 16 bytes till end - memcpy( &report + offsetof( REALSENSE_HID_REPORT, customValue1 ), tmp_buffer + 16, 16 ); + memcpy( &report.customValue1, tmp_buffer + 16, 16 ); } else { From 40c8043cfad722e1325195dc1f743cf998f57f60 Mon Sep 17 00:00:00 2001 From: noacoohen Date: Wed, 17 Apr 2024 16:01:29 +0300 Subject: [PATCH 11/15] replace define with enum and constexpr --- src/hid/hid-types.h | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/hid/hid-types.h b/src/hid/hid-types.h index df861914a9..7f3680346f 100644 --- a/src/hid/hid-types.h +++ b/src/hid/hid-types.h @@ -8,16 +8,6 @@ #include #include -#define HID_REPORT_TYPE_INPUT 1 -#define HID_REPORT_TYPE_FEATURE 3 - -#define DEVICE_POWER_D0 2 -#define DEVICE_POWER_D4 6 - -#define REPORT_ID_ACCELEROMETER_3D 1 -#define REPORT_ID_GYROMETER_3D 2 -#define REPORT_ID_CUSTOM 3 - static std::string gyro = "gyro_3d"; static std::string accel = "accel_3d"; @@ -27,6 +17,18 @@ namespace librealsense { namespace platform { + constexpr int HID_REPORT_TYPE_INPUT = 1; + constexpr int HID_REPORT_TYPE_FEATURE = 3; + constexpr int DEVICE_POWER_D0 = 2; + constexpr int DEVICE_POWER_D4 = 6; + + enum REPORT_ID + { + REPORT_ID_ACCELEROMETER_3D = 1, + REPORT_ID_GYROMETER_3D = 2, + REPORT_ID_CUSTOM = 3 + }; + enum USB_REQUEST_CODE { USB_REQUEST_CODE_GET = 0xa1, USB_REQUEST_CODE_SET = 0x21 From ec63cb44c9af1464d346c103bab056c4962522ab Mon Sep 17 00:00:00 2001 From: noacoohen Date: Thu, 18 Apr 2024 16:00:40 +0300 Subject: [PATCH 12/15] remove conversion to int --- src/hid/hid-device.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hid/hid-device.cpp b/src/hid/hid-device.cpp index 3d471069c9..aaa3a18a40 100644 --- a/src/hid/hid-device.cpp +++ b/src/hid/hid-device.cpp @@ -332,7 +332,7 @@ namespace librealsense featureReport.report = (1000 / fps); //we want to change the sensitivity values only in gyro, for FW version >= 5.16 - if( (int)featureReport.reportId == REPORT_ID_GYROMETER_3D + if( featureReport.reportId == REPORT_ID_GYROMETER_3D && _realsense_hid_report_actual_size == sizeof( REALSENSE_HID_REPORT ) ) featureReport.sensitivity = sensitivity; From 14fb874721626f2af4a113a1d1d9aa1867bfae42 Mon Sep 17 00:00:00 2001 From: noacoohen Date: Thu, 18 Apr 2024 16:23:58 +0300 Subject: [PATCH 13/15] fix default value and add comment in set_report function --- src/hid/hid-device.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hid/hid-device.h b/src/hid/hid-device.h index c302f58d7d..1293fb9b0e 100644 --- a/src/hid/hid-device.h +++ b/src/hid/hid-device.h @@ -49,7 +49,8 @@ namespace librealsense void handle_interrupt(); rs_usb_endpoint get_hid_endpoint(); rs_usb_interface get_hid_interface(); - usb_status set_feature_report( unsigned char power, int report_id, int fps = 0, double sensitivity = 1 ); + //for gyro sensitivty the default value we set in feature report is 0.1 + usb_status set_feature_report( unsigned char power, int report_id, int fps = 0, double sensitivity = 0.1 ); #ifdef __APPLE__ int hidapi_PowerDevice(unsigned char reportId); #endif From 3643dfe6c578d35bac7420aa7b29deb3433ccf3f Mon Sep 17 00:00:00 2001 From: noacoohen Date: Thu, 18 Apr 2024 16:32:03 +0300 Subject: [PATCH 14/15] fix typo --- src/hid/hid-device.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hid/hid-device.h b/src/hid/hid-device.h index 1293fb9b0e..279c1da09f 100644 --- a/src/hid/hid-device.h +++ b/src/hid/hid-device.h @@ -49,7 +49,7 @@ namespace librealsense void handle_interrupt(); rs_usb_endpoint get_hid_endpoint(); rs_usb_interface get_hid_interface(); - //for gyro sensitivty the default value we set in feature report is 0.1 + //for gyro sensitivity the default value we set in feature report is 0.1 usb_status set_feature_report( unsigned char power, int report_id, int fps = 0, double sensitivity = 0.1 ); #ifdef __APPLE__ int hidapi_PowerDevice(unsigned char reportId); From 0a1b73423a1b25a2a877d40f38804d651f23e20f Mon Sep 17 00:00:00 2001 From: noacoohen Date: Thu, 18 Apr 2024 16:39:32 +0300 Subject: [PATCH 15/15] edit comment --- src/hid/hid-device.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hid/hid-device.h b/src/hid/hid-device.h index 279c1da09f..e4b478fab0 100644 --- a/src/hid/hid-device.h +++ b/src/hid/hid-device.h @@ -49,7 +49,7 @@ namespace librealsense void handle_interrupt(); rs_usb_endpoint get_hid_endpoint(); rs_usb_interface get_hid_interface(); - //for gyro sensitivity the default value we set in feature report is 0.1 + //for gyro sensitivity the default value we set in feature report is 0.1, which is mapped in FW to 30.5 millideg/sec usb_status set_feature_report( unsigned char power, int report_id, int fps = 0, double sensitivity = 0.1 ); #ifdef __APPLE__ int hidapi_PowerDevice(unsigned char reportId);