-
Notifications
You must be signed in to change notification settings - Fork 0
/
DroneInputProvider.cs
90 lines (88 loc) · 2.42 KB
/
DroneInputProvider.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.System.Threading;
using ARDrone2Client.Common;
using ARDrone2Client.Common.Navigation;
using ARDrone2Client.Common.Input;
namespace ARDrone2Client.Common.Input
{
public class DroneInputProvider : IInputProvider
{
private DroneClient _DroneClient = null;
public DroneInputProvider(DroneClient droneClient, IJoystickControl rollPitchThumb, IJoystickControl yawGazThumb)
{
if (droneClient == null)
throw new ArgumentNullException("DroneClient");
_DroneClient = droneClient;
_RollPitchThumb = rollPitchThumb;
_YawGazThumb = yawGazThumb;
}
public DroneClient DroneClient
{
get
{
return _DroneClient;
}
}
public string Name
{
get
{
return "Patrol Commander joystick";
}
}
private IJoystickControl _RollPitchThumb;
public IJoystickControl RollPitchThumb
{
get
{
return _RollPitchThumb;
}
set
{
if (value == _RollPitchThumb)
return;
_RollPitchThumb = value;
}
}
private IJoystickControl _YawGazThumb;
public IJoystickControl YawGazThumb
{
get
{
return _YawGazThumb;
}
set
{
if (value == _YawGazThumb)
return;
_YawGazThumb = value;
}
}
public void Update()
{
float pitch = 0, roll = 0, yaw = 0, gaz = 0;
if (_DroneClient == null)
return;
if (RollPitchThumb != null)
{
pitch = RollPitchThumb.Y;
roll = RollPitchThumb.X;
}
if (YawGazThumb != null)
{
yaw = YawGazThumb.X;
gaz = YawGazThumb.Y;
}
//Debug.WriteLine(string.Format("roll={0}, pitch={1}, yaw={2}, gaz={3}", roll, pitch, yaw, gaz));
DroneClient.InputState.Update(roll, pitch, yaw, gaz);
}
public void Dispose()
{
}
}
}