[4de1c7]: / app / resources / LeapSDK / v3_python27 / src / Device.cs

Download this file

294 lines (272 with data), 9.0 kB

  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
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
/******************************************************************************\
* Copyright (C) 2012-2016 Leap Motion, Inc. All rights reserved. *
* Leap Motion proprietary and confidential. Not for distribution. *
* Use subject to the terms of the Leap Motion SDK Agreement available at *
* https://developer.leapmotion.com/sdk_agreement, or another agreement *
* between Leap Motion and you, your company or other organization. *
\******************************************************************************/
namespace Leap
{
using System;
using System.Runtime.InteropServices;
using LeapInternal;
/**
* The Device class represents a physically connected device.
*
* The Device class contains information related to a particular connected
* device such as device id, field of view relative to the device,
* and the position and orientation of the device in relative coordinates.
*
* The position and orientation describe the alignment of the device relative to the user.
* The alignment relative to the user is only descriptive. Aligning devices to users
* provides consistency in the parameters that describe user interactions.
*
* Note that Device objects can be invalid, which means that they do not contain
* valid device information and do not correspond to a physical device.
* Test for validity with the Device::isValid() function.
* @since 1.0
*/
public class Device:
IEquatable<Device>
{
/**
* Constructs a default Device object.
*
* Get valid Device objects from a DeviceList object obtained using the
* Controller::devices() method.
*
* \include Device_Device.txt
*
* @since 1.0
*/
public Device() {}
public Device(IntPtr deviceHandle,
float horizontalViewAngle,
float verticalViewAngle,
float range,
float baseline,
bool isStreaming,
string serialNumber)
{
Handle = deviceHandle;
HorizontalViewAngle = horizontalViewAngle;
VerticalViewAngle = verticalViewAngle;
Range = range;
Baseline = baseline;
IsStreaming = isStreaming;
SerialNumber = serialNumber;
}
/* For internal use. */
public void Update(
float horizontalViewAngle,
float verticalViewAngle,
float range,
float baseline,
bool isStreaming,
string serialNumber)
{
HorizontalViewAngle = horizontalViewAngle;
VerticalViewAngle = verticalViewAngle;
Range = range;
Baseline = baseline;
IsStreaming = isStreaming;
SerialNumber = serialNumber;
}
/* For internal use. */
public void Update(Device updatedDevice)
{
HorizontalViewAngle = updatedDevice.HorizontalViewAngle;
VerticalViewAngle = updatedDevice.VerticalViewAngle;
Range = updatedDevice.Range;
Baseline = updatedDevice.Baseline;
IsStreaming = updatedDevice.IsStreaming;
SerialNumber = updatedDevice.SerialNumber;
}
/* For internal use. */
public IntPtr Handle { get; private set; }
public bool SetPaused(bool pause)
{
ulong prior_state = 0;
ulong set_flags = 0;
ulong clear_flags = 0;
if (pause)
set_flags = (ulong)eLeapDeviceFlag.eLeapDeviceFlag_Stream;
else
clear_flags = (ulong)eLeapDeviceFlag.eLeapDeviceFlag_Stream;
eLeapRS result = LeapC.SetDeviceFlags(Handle, set_flags, clear_flags, out prior_state);
if (result == eLeapRS.eLeapRS_Success)
return true;
return false;
}
/**
* Compare Device object equality.
*
* \include Device_operator_equals.txt
*
* Two Device objects are equal if and only if both Device objects represent the
* exact same Device and both Devices are valid.
* @since 1.0
*/
public bool Equals(Device other)
{
return this.SerialNumber == other.SerialNumber;
}
/**
* A string containing a brief, human readable description of the Device object.
*
* @returns A description of the Device as a string.
* @since 1.0
*/
public override string ToString()
{
return "Device serial# " + this.SerialNumber;
}
/**
* The angle of view along the x axis of this device.
*
* \image html images/Leap_horizontalViewAngle.png
*
* The Leap Motion controller scans a region in the shape of an inverted pyramid
* centered at the device's center and extending upwards. The horizontalViewAngle
* reports the view angle along the long dimension of the device.
*
* \include Device_horizontalViewAngle.txt
*
* @returns The horizontal angle of view in radians.
* @since 1.0
*/
public float HorizontalViewAngle { get; private set; }
/**
* The angle of view along the z axis of this device.
*
* \image html images/Leap_verticalViewAngle.png
*
* The Leap Motion controller scans a region in the shape of an inverted pyramid
* centered at the device's center and extending upwards. The verticalViewAngle
* reports the view angle along the short dimension of the device.
*
* \include Device_verticalViewAngle.txt
*
* @returns The vertical angle of view in radians.
* @since 1.0
*/
public float VerticalViewAngle { get; private set; }
/**
* The maximum reliable tracking range from the center of this device.
*
* The range reports the maximum recommended distance from the device center
* for which tracking is expected to be reliable. This distance is not a hard limit.
* Tracking may be still be functional above this distance or begin to degrade slightly
* before this distance depending on calibration and extreme environmental conditions.
*
* \include Device_range.txt
*
* @returns The recommended maximum range of the device in mm.
* @since 1.0
*/
public float Range { get; private set; }
/**
* The distance between the center points of the stereo sensors.
*
* The baseline value, together with the maximum resolution, influence the
* maximum range.
*
* @returns The separation distance between the center of each sensor, in mm.
* @since 2.2.5
*/
public float Baseline { get; private set; }
/**
* Reports whether this device is streaming data to your application.
*
* Currently only one controller can provide data at a time.
* @since 1.2
*/
public bool IsStreaming { get; private set; }
/**
* The device type.
*
* Use the device type value in the (rare) circumstances that you
* have an application feature which relies on a particular type of device.
* Current types of device include the original Leap Motion peripheral,
* keyboard-embedded controllers, and laptop-embedded controllers.
*
* @returns The physical device type as a member of the DeviceType enumeration.
* @since 1.2
*/
public Device.DeviceType Type
{
get
{
return DeviceType.TYPE_INVALID;
}
}
/**
* An alphanumeric serial number unique to each device.
*
* Consumer device serial numbers consist of 2 letters followed by 11 digits.
*
* When using multiple devices, the serial number provides an unambiguous
* identifier for each device.
* @since 2.2.2
*/
public string SerialNumber { get; private set; }
/**
* The software has detected a possible smudge on the translucent cover
* over the Leap Motion cameras.
*
* Not implemented yet.
*
* \include Device_isSmudged.txt
*
* @since 3.0
*/
public bool IsSmudged
{
get
{
return false; //TODO implement or remove Is Smudged
}
}
/**
* The software has detected excessive IR illumination, which may interfere
* with tracking. If robust mode is enabled, the system will enter robust mode when
* isLightingBad() is true.
*
* Not implemented yet.
*
* \include Device_isLightingBad.txt
*
* @since 3.0
*/
public bool IsLightingBad
{
get
{
return false; //TODO Implement or remove IsLightingBad
}
}
/**
* The available types of Leap Motion controllers.
* @since 1.2
*/
public enum DeviceType
{
TYPE_INVALID = -1,
/**
* A standalone USB peripheral. The original Leap Motion controller device.
* @since 1.2
*/
TYPE_PERIPHERAL = 1,
/**
* A controller embedded in a keyboard.
* @since 1.2
*/
TYPE_LAPTOP,
/**
* A controller embedded in a laptop computer.
* @since 1.2
*/
TYPE_KEYBOARD
}
}
}