Skip to content

Commit 165605c

Browse files
committed
Input actions [debug] support
1 parent af1de3a commit 165605c

File tree

3 files changed

+82
-5
lines changed

3 files changed

+82
-5
lines changed

KinectHandler/KinectHandler.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
</ItemGroup>
9696
<ItemGroup>
9797
<PackageReference Include="Amethyst.Plugins.Contract">
98-
<Version>0.2.25</Version>
98+
<Version>0.3.32-alpha</Version>
9999
</PackageReference>
100100
<PackageReference Include="System.ComponentModel">
101101
<Version>4.3.0</Version>

plugin_Kinect360/Kinect360.cs

Lines changed: 79 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
// Licensed under the MIT License. See LICENSE in the project root for license information.
33

44
using System;
5+
using System.Collections.Generic;
56
using System.Collections.ObjectModel;
67
using System.ComponentModel.Composition;
8+
using System.Diagnostics;
79
using System.Drawing;
810
using System.IO;
911
using 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 () =>

plugin_Kinect360/plugin_Kinect360.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
<PublishTrimmed>true</PublishTrimmed>
1010
<Platforms>x64</Platforms>
1111
<UseWinUI>true</UseWinUI>
12+
<LangVersion>latest</LangVersion>
1213
</PropertyGroup>
1314

1415
<ItemGroup>
15-
<PackageReference Include="Amethyst.Plugins.Contract" Version="0.2.25" />
16+
<PackageReference Include="Amethyst.Plugins.Contract" Version="0.3.32-alpha" />
1617
<PackageReference Include="RestSharp" Version="108.0.3" />
1718
<PackageReference Include="System.ComponentModel.Composition" Version="8.0.0" />
1819
<PackageReference Include="System.ComponentModel.Composition.Registration" Version="8.0.0" />

0 commit comments

Comments
 (0)