55//! Handles depth camera device control including motor tilt, native streaming,
66//! 3D preview frame polling, depth visualization settings, and calibration dialogs.
77//! LED is automatically managed by freedepth based on device state.
8+ //!
9+ //! When freedepth is not available (non-x86_64 or feature disabled), stub
10+ //! implementations are provided that return Task::none().
811
9- use crate :: app :: state :: { AppModel , Message , SceneViewMode } ;
12+ # [ cfg ( all ( target_arch = "x86_64" , feature = "freedepth" ) ) ]
1013use crate :: backends:: camera:: { NativeDepthBackend , depth_device_index, rgb_to_rgba} ;
11- use cosmic :: Task ;
14+ # [ cfg ( all ( target_arch = "x86_64" , feature = "freedepth" ) ) ]
1215use freedepth:: { DepthRegistration , TILT_MAX_DEGREES , TILT_MIN_DEGREES } ;
16+ #[ cfg( all( target_arch = "x86_64" , feature = "freedepth" ) ) ]
1317use std:: time:: { Duration , Instant } ;
18+ #[ cfg( all( target_arch = "x86_64" , feature = "freedepth" ) ) ]
1419use tracing:: { debug, info, warn} ;
1520
21+ use crate :: app:: state:: { AppModel , Message } ;
22+ #[ cfg( all( target_arch = "x86_64" , feature = "freedepth" ) ) ]
23+ use crate :: app:: state:: SceneViewMode ;
24+ use cosmic:: Task ;
25+
1626/// Set up GPU shader registration data from device calibration
1727///
1828/// This spawns an async task to update the point cloud and mesh processors
1929/// with the device-specific registration tables. Call this after the native
2030/// depth backend is initialized.
2131///
2232/// Uses the generic DepthRegistration trait for device-agnostic access.
33+ #[ cfg( all( target_arch = "x86_64" , feature = "freedepth" ) ) ]
2334pub fn setup_shader_registration_data ( registration : & dyn DepthRegistration ) {
2435 let reg_data = crate :: shaders:: RegistrationData {
2536 registration_table : registration. registration_table_flat ( ) . to_vec ( ) ,
@@ -41,6 +52,8 @@ pub fn setup_shader_registration_data(registration: &dyn DepthRegistration) {
4152 } ) ;
4253}
4354
55+ // Full implementation when freedepth is available
56+ #[ cfg( all( target_arch = "x86_64" , feature = "freedepth" ) ) ]
4457impl AppModel {
4558 /// Handle setting depth camera tilt angle (desired state)
4659 ///
@@ -58,7 +71,7 @@ impl AppModel {
5871 self . kinect . tilt_angle = degrees;
5972
6073 // Send command to motor via global motor control
61- use crate :: backends:: camera:: depth_controller :: set_motor_tilt;
74+ use crate :: backends:: camera:: motor_control :: set_motor_tilt;
6275 if let Err ( e) = set_motor_tilt ( degrees) {
6376 tracing:: warn!( "Failed to set depth camera tilt: {}" , e) ;
6477 }
@@ -150,7 +163,6 @@ impl AppModel {
150163 registration_table : registration. registration_table_flat ( ) . to_vec ( ) ,
151164 depth_to_rgb_shift : registration. depth_to_rgb_shift_table ( ) . to_vec ( ) ,
152165 target_offset : registration. target_offset ( ) ,
153- reg_x_val_scale : 256 ,
154166 reg_scale_x : 1.0 ,
155167 reg_scale_y : 1.0 ,
156168 reg_y_offset : 0 ,
@@ -207,7 +219,7 @@ impl AppModel {
207219 video_frame_is_new =
208220 self . preview_3d . last_render_video_timestamp != Some ( video_frame. timestamp ) ;
209221
210- let rgba_data = rgb_to_rgba ( & video_frame. rgb_data ) ;
222+ let rgba_data = rgb_to_rgba ( & video_frame. data ) ;
211223
212224 use crate :: backends:: camera:: types:: { CameraFrame , PixelFormat } ;
213225 let frame = CameraFrame {
@@ -470,3 +482,88 @@ impl AppModel {
470482 self . handle_request_point_cloud_render ( )
471483 }
472484}
485+
486+ // Stub implementations when freedepth is disabled
487+ #[ cfg( not( all( target_arch = "x86_64" , feature = "freedepth" ) ) ) ]
488+ impl AppModel {
489+ pub ( crate ) fn handle_set_kinect_tilt ( & mut self , _degrees : i8 ) -> Task < cosmic:: Action < Message > > {
490+ Task :: none ( )
491+ }
492+
493+ pub ( crate ) fn update_kinect_state ( & mut self ) -> Task < cosmic:: Action < Message > > {
494+ self . kinect . is_device = false ;
495+ Task :: none ( )
496+ }
497+
498+ pub ( crate ) fn is_current_camera_depth_sensor ( & self ) -> bool {
499+ false
500+ }
501+
502+ pub ( crate ) fn handle_start_native_kinect_streaming ( & mut self ) -> Task < cosmic:: Action < Message > > {
503+ Task :: none ( )
504+ }
505+
506+ pub ( crate ) fn handle_stop_native_kinect_streaming ( & mut self ) -> Task < cosmic:: Action < Message > > {
507+ Task :: none ( )
508+ }
509+
510+ pub ( crate ) fn handle_poll_native_kinect_frames ( & mut self ) -> Task < cosmic:: Action < Message > > {
511+ Task :: none ( )
512+ }
513+
514+ pub ( crate ) fn handle_toggle_depth_overlay ( & mut self ) -> Task < cosmic:: Action < Message > > {
515+ Task :: none ( )
516+ }
517+
518+ pub ( crate ) fn handle_toggle_depth_grayscale ( & mut self ) -> Task < cosmic:: Action < Message > > {
519+ Task :: none ( )
520+ }
521+
522+ pub ( crate ) fn handle_show_calibration_dialog ( & mut self ) -> Task < cosmic:: Action < Message > > {
523+ Task :: none ( )
524+ }
525+
526+ pub ( crate ) fn handle_close_calibration_dialog ( & mut self ) -> Task < cosmic:: Action < Message > > {
527+ Task :: none ( )
528+ }
529+
530+ pub ( crate ) fn handle_start_calibration ( & mut self ) -> Task < cosmic:: Action < Message > > {
531+ Task :: none ( )
532+ }
533+
534+ pub ( crate ) fn handle_toggle_3d_preview ( & mut self ) -> Task < cosmic:: Action < Message > > {
535+ Task :: none ( )
536+ }
537+
538+ pub ( crate ) fn handle_toggle_scene_view_mode ( & mut self ) -> Task < cosmic:: Action < Message > > {
539+ Task :: none ( )
540+ }
541+
542+ pub ( crate ) fn handle_preview_3d_mouse_pressed (
543+ & mut self ,
544+ _x : f32 ,
545+ _y : f32 ,
546+ ) -> Task < cosmic:: Action < Message > > {
547+ Task :: none ( )
548+ }
549+
550+ pub ( crate ) fn handle_preview_3d_mouse_moved (
551+ & mut self ,
552+ _x : f32 ,
553+ _y : f32 ,
554+ ) -> Task < cosmic:: Action < Message > > {
555+ Task :: none ( )
556+ }
557+
558+ pub ( crate ) fn handle_preview_3d_mouse_released ( & mut self ) -> Task < cosmic:: Action < Message > > {
559+ Task :: none ( )
560+ }
561+
562+ pub ( crate ) fn handle_reset_3d_preview_rotation ( & mut self ) -> Task < cosmic:: Action < Message > > {
563+ Task :: none ( )
564+ }
565+
566+ pub ( crate ) fn handle_zoom_3d_preview ( & mut self , _delta : f32 ) -> Task < cosmic:: Action < Message > > {
567+ Task :: none ( )
568+ }
569+ }
0 commit comments