22// Licensed under the MIT License. See LICENSE in the project root for license information.
33
44using System ;
5+ using System . Collections . Generic ;
56using System . Collections . ObjectModel ;
67using System . ComponentModel . Composition ;
8+ using System . Diagnostics ;
79using System . Drawing ;
810using System . IO ;
911using System . Linq ;
@@ -47,14 +49,58 @@ public class Kinect360 : KinectHandler.KinectHandler, ITrackingDevice
4749 public bool IsFlipSupported => true ;
4850 public bool IsAppOrientationSupported => true ;
4951 public object SettingsInterfaceRoot => InterfaceRoot ;
52+ private static IAmethystHost HostStatic { get ; set ; }
5053
5154 public ObservableCollection < TrackedJoint > TrackedJoints { get ; } =
5255 // Prepend all supported joints to the joints list
5356 new ( Enum . GetValues < TrackedJointType > ( )
5457 . Where ( x => x is not TrackedJointType . JointNeck and not TrackedJointType . JointManual and not
5558 TrackedJointType . JointHandTipLeft and not TrackedJointType . JointHandTipRight and not
5659 TrackedJointType . JointThumbLeft and not TrackedJointType . JointThumbRight )
57- . Select ( x => new TrackedJoint { Name = x . ToString ( ) , Role = x } ) ) ;
60+ . Select ( x => new TrackedJoint
61+ {
62+ Name = x . ToString ( ) , Role = x , SupportedInputActions = x switch
63+ {
64+ TrackedJointType . JointHandLeft =>
65+ [
66+ new KeyInputAction < bool >
67+ {
68+ Name = "Left Pause" , Description = "Left hand pause gesture" ,
69+ Guid = "5E4680F9-F232-4EA1-AE12-E96F7F8E0CC1" , GetHost = ( ) => HostStatic
70+ } ,
71+ new KeyInputAction < bool >
72+ {
73+ Name = "Left Point" , Description = "Left hand point gesture" ,
74+ Guid = "8D83B89D-5FBD-4D52-B626-4E90BDD26B08" , GetHost = ( ) => HostStatic
75+ } ,
76+ new KeyInputAction < bool >
77+ {
78+ Name = "Left Press" , Description = "Left hand press gesture" ,
79+ Guid = "E383258F-5918-4F1C-BC66-7325DB1F07E8" , GetHost = ( ) => HostStatic
80+ }
81+ ] ,
82+ TrackedJointType . JointHandRight =>
83+ [
84+ new KeyInputAction < bool >
85+ {
86+ Name = "Right Pause" , Description = "Right hand pause gesture" ,
87+ Guid = "B8389FA6-75EF-4509-AEC2-1758AFE41D95" , GetHost = ( ) => HostStatic
88+ } ,
89+ new KeyInputAction < bool >
90+ {
91+ Name = "Right Point" , Description = "Right hand point gesture" ,
92+ Guid = "C58EBCFE-0DF5-40FD-ABC1-06B415FA51BE" , GetHost = ( ) => HostStatic
93+ } ,
94+ new KeyInputAction < bool >
95+ {
96+ Name = "Right Press" , Description = "Right hand press gesture" ,
97+ Guid = "801336BE-5BD5-4881-A390-D57D958592EF" , GetHost = ( ) => HostStatic
98+ }
99+ ] ,
100+ _ => [ ]
101+ }
102+ } )
103+ ) ;
58104
59105 public string DeviceStatusString => PluginLoaded
60106 ? DeviceStatus switch
@@ -82,6 +128,9 @@ TrackedJointType.JointHandTipLeft and not TrackedJointType.JointHandTipRight and
82128
83129 public void OnLoad ( )
84130 {
131+ // Backup the plugin host
132+ HostStatic = Host ;
133+
85134 TiltNumberBox = new NumberBox
86135 {
87136 SpinButtonPlacementMode = NumberBoxSpinButtonPlacementMode . Inline ,
@@ -109,6 +158,30 @@ public void OnLoad()
109158 VerticalAlignment = VerticalAlignment . Center
110159 } ;
111160
161+ // TODO TEMPORARY
162+ var actionButtons = new StackPanel { Orientation = Orientation . Horizontal , Spacing = 6 , Margin = new Thickness ( 5 ) } ;
163+ foreach ( var action in TrackedJoints . SelectMany ( x => x . SupportedInputActions ) )
164+ {
165+ var button = new Button { Content = action . Name } ;
166+ actionButtons . Children . Add ( button ) ;
167+
168+ button . Click += ( _ , _ ) =>
169+ {
170+ try
171+ {
172+ if ( action . IsUsed )
173+ //action.Invoke(true);
174+ Host . ReceiveKeyInput ( action , true ) ;
175+ }
176+ catch ( Exception ex )
177+ {
178+ Host ? . Log ( ex ) ;
179+ Debugger . Break ( ) ;
180+ }
181+ } ;
182+ }
183+ // TODO TEMPORARY
184+
112185 CameraImage = new WriteableBitmap ( CameraImageWidth , CameraImageHeight ) ;
113186 InterfaceRoot = new Page
114187 {
@@ -120,7 +193,10 @@ public void OnLoad()
120193 {
121194 Orientation = Orientation . Horizontal ,
122195 Children = { TiltTextBlock , TiltNumberBox }
123- }
196+ } ,
197+ // TODO TEMPORARY
198+ actionButtons
199+ // TODO TEMPORARY
124200 }
125201 }
126202 } ;
@@ -178,7 +254,7 @@ public void Update()
178254 TrackedJoints [ trackedJoints . IndexOf ( x ) ] . Position = x . Position . Safe ( ) ;
179255 TrackedJoints [ trackedJoints . IndexOf ( x ) ] . Orientation = x . Orientation . Safe ( ) ;
180256 } ) ;
181-
257+
182258 // Update camera feed
183259 if ( ! IsCameraEnabled ) return ;
184260 CameraImage . DispatcherQueue . TryEnqueue ( async ( ) =>
0 commit comments