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

Download this file

297 lines (271 with data), 9.2 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
294
295
296
/******************************************************************************\
* 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 LeapInternal;
using System;
using System.Runtime.InteropServices;
/**
* An enumeration defining the types of Leap Motion events.
* @since 3.0
*/
public enum LeapEvent
{
EVENT_CONNECTION, //!< A connection event has occurred
EVENT_CONNECTION_LOST, //!< The connection with the service has been lost
EVENT_DEVICE, //!< A device event has occurred
EVENT_DEVICE_FAILURE, //!< A device failure event has occurred
EVENT_DEVICE_LOST, //!< Event asserted when the underlying device object has been lost
EVENT_POLICY_CHANGE, //!< A change in policy occurred
EVENT_CONFIG_RESPONSE, //!< Response to a Config value request
EVENT_CONFIG_CHANGE, //!< Success response to a Config value change
EVENT_FRAME, //!< A tracking frame has been received
EVENT_INTERNAL_FRAME, //!< An internal tracking frame has been received
EVENT_IMAGE, //!< A requested image is available
EVENT_IMAGE_REQUEST_FAILED, //!< A requested image could not be provided
EVENT_DISTORTION_CHANGE, //!< The distortion matrix used for image correction has changed
EVENT_LOG_EVENT, //!< A diagnostic event has occured
EVENT_INIT,
EVENT_DROPPED_FRAME,
};
/**
* A generic object with no arguments beyond the event type.
* @since 3.0
*/
public class LeapEventArgs : EventArgs
{
public LeapEventArgs(LeapEvent type)
{
this.type = type;
}
public LeapEvent type { get; set; }
}
/**
* Dispatched when a tracking frame is ready.
*
* Provides the Frame object as an argument.
* @since 3.0
*/
public class FrameEventArgs : LeapEventArgs
{
public FrameEventArgs(Frame frame) : base(LeapEvent.EVENT_FRAME)
{
this.frame = frame;
}
public Frame frame { get; set; }
}
public class InternalFrameEventArgs : LeapEventArgs
{
public InternalFrameEventArgs(ref LEAP_TRACKING_EVENT frame) : base(LeapEvent.EVENT_INTERNAL_FRAME)
{
this.frame = frame;
}
public LEAP_TRACKING_EVENT frame { get; set; }
}
/**
* Dispatched when a requested Image is ready.
*
* Provides the Image object as an argument.
* @since 3.0
*/
public class ImageEventArgs : LeapEventArgs
{
public ImageEventArgs(Image image) : base(LeapEvent.EVENT_IMAGE)
{
this.image = image;
}
public Image image { get; set; }
}
/**
* Dispatched when a image request cannot be fulfilled.
*
* Provides the requested frame id and image type of the request that failed.
* @since 3.0
*/
public class ImageRequestFailedEventArgs : LeapEventArgs
{
public ImageRequestFailedEventArgs(Int64 frameId, Image.ImageType imageType) : base(LeapEvent.EVENT_IMAGE_REQUEST_FAILED)
{
this.frameId = frameId;
this.imageType = imageType;
}
/**
* Dispatched when a image request cannot be fulfilled.
*
* Provides the requested frame id and image type of the request that failed,
* as well as the reason for the failure, and in the case of an insufficient
* buffer, the required size of the image buffer.
*
* @since 3.0
*/
public ImageRequestFailedEventArgs(Int64 frameId, Image.ImageType imageType,
Image.RequestFailureReason reason,
string message,
Int64 requiredBufferSize
) : base(LeapEvent.EVENT_IMAGE_REQUEST_FAILED)
{
this.frameId = frameId;
this.imageType = imageType;
this.reason = reason;
this.message = message;
this.requiredBufferSize = requiredBufferSize;
}
public Int64 frameId { get; set; }
public Image.ImageType imageType { get; set; }
public Image.RequestFailureReason reason { get; set; }
public string message { get; set; }
public Int64 requiredBufferSize { get; set; }
}
/**
* Dispatched when loggable events are generated by the service and the
* service connection code.
*
* Provides the severity rating, log text, and timestamp as arguments.
* @since 3.0
*/
public class LogEventArgs : LeapEventArgs
{
public LogEventArgs(MessageSeverity severity, Int64 timestamp, string message) : base(LeapEvent.EVENT_LOG_EVENT)
{
this.severity = severity;
this.message = message;
this.timestamp = timestamp;
}
public MessageSeverity severity { get; set; }
public Int64 timestamp { get; set; }
public string message { get; set; }
}
/**
* Dispatched when a policy change is complete.
*
* Provides the current and previous policies as arguments.
*
* @since 3.0
*/
public class PolicyEventArgs : LeapEventArgs
{
public PolicyEventArgs(UInt64 currentPolicies, UInt64 oldPolicies) : base(LeapEvent.EVENT_POLICY_CHANGE)
{
this.currentPolicies = currentPolicies;
this.oldPolicies = oldPolicies;
}
public UInt64 currentPolicies { get; set; }
public UInt64 oldPolicies { get; set; }
}
/**
* Dispatched when the image distortion map changes.
*
* Provides the new distortion map as an argument.
* @since 3.0
*/
public class DistortionEventArgs : LeapEventArgs
{
public DistortionEventArgs(DistortionData distortion) : base(LeapEvent.EVENT_DISTORTION_CHANGE)
{
this.distortion = distortion;
}
public DistortionData distortion { get; set; }
}
/**
* Dispatched when a configuration change is completed.
*
* Provides the configuration key, whether the change was successful, and the id of the original change request.
* @since 3.0
*/
public class ConfigChangeEventArgs : LeapEventArgs
{
public ConfigChangeEventArgs(string config_key, bool succeeded, uint requestId) : base(LeapEvent.EVENT_CONFIG_CHANGE)
{
this.ConfigKey = config_key;
this.Succeeded = succeeded;
this.RequestId = requestId;
}
public string ConfigKey { get; set; }
public bool Succeeded { get; set; }
public uint RequestId { get; set; }
}
/**
* Dispatched when a configuration change is completed.
*
* Provides the configuration key, whether the change was successful, and the id of the original change request.
* @since 3.0
*/
public class SetConfigResponseEventArgs : LeapEventArgs
{
public SetConfigResponseEventArgs(string config_key, Config.ValueType dataType, object value, uint requestId) : base(LeapEvent.EVENT_CONFIG_RESPONSE)
{
this.ConfigKey = config_key;
this.DataType = dataType;
this.Value = value;
this.RequestId = requestId;
}
public string ConfigKey { get; set; }
public Config.ValueType DataType { get; set; }
public object Value { get; set; }
public uint RequestId { get; set; }
}
/**
* Dispatched when the connection is established.
* @since 3.0
*/
public class ConnectionEventArgs : LeapEventArgs
{
public ConnectionEventArgs() : base(LeapEvent.EVENT_CONNECTION) { }
}
/**
* Dispatched when the connection is lost.
* @since 3.0
*/
public class ConnectionLostEventArgs : LeapEventArgs
{
public ConnectionLostEventArgs() : base(LeapEvent.EVENT_CONNECTION_LOST) { }
}
/**
* Dispatched when a device is plugged in.
*
* Provides the device as an argument.
* @since 3.0
*/
public class DeviceEventArgs : LeapEventArgs
{
public DeviceEventArgs(Device device) : base(LeapEvent.EVENT_DEVICE)
{
this.Device = device;
}
public Device Device { get; set; }
}
/**
* Dispatched when a device is plugged in, but fails to initialize or when
* a working device fails in use.
*
* Provides the failure reason and, if available, the serial number.
* @since 3.0
*/
public class DeviceFailureEventArgs : LeapEventArgs
{
public DeviceFailureEventArgs(uint code, string message, string serial) : base(LeapEvent.EVENT_DEVICE_FAILURE)
{
ErrorCode = code;
ErrorMessage = message;
DeviceSerialNumber = serial;
}
public uint ErrorCode { get; set; }
public string ErrorMessage { get; set; }
public string DeviceSerialNumber { get; set; }
}
public class DroppedFrameEventArgs : LeapEventArgs
{
public DroppedFrameEventArgs(Int64 frame_id, eLeapDroppedFrameType type) : base(LeapEvent.EVENT_DROPPED_FRAME)
{
frameID = frame_id;
reason = type;
}
public Int64 frameID { get; set; }
public eLeapDroppedFrameType reason { get; set; }
}
}