Leap Motion C++ API Reference  0.8.0
Leap.h
1 /******************************************************************************\
2 * Copyright (C) 2012-2013 Leap Motion, Inc. All rights reserved. *
3 * Leap Motion proprietary and confidential. Not for distribution. *
4 * Use subject to the terms of the Leap Motion SDK Agreement available at *
5 * https://developer.leapmotion.com/sdk_agreement, or another agreement *
6 * between Leap Motion and you, your company or other organization. *
7 \******************************************************************************/
8 
9 #if !defined(__Leap_h__)
10 #define __Leap_h__
11 
12 #include "LeapMath.h"
13 
14 #include <string>
15 #include <vector>
16 
17 // Define integer types for Visual Studio 2008 and earlier
18 #if defined(_MSC_VER) && (_MSC_VER < 1600)
19 typedef __int32 int32_t;
20 typedef __int64 int64_t;
21 typedef unsigned __int32 uint32_t;
22 typedef unsigned __int64 uint64_t;
23 #else
24 #include <stdint.h>
25 #endif
26 
27 // Define Leap export macros
28 #if defined(_WIN32) // Windows
29 #if LEAP_API_INTERNAL
30 #define LEAP_EXPORT
31 #elif LEAP_API_IMPLEMENTATION
32 #define LEAP_EXPORT __declspec(dllexport)
33 #else
34 #define LEAP_EXPORT __declspec(dllimport)
35 #endif
36 #define LEAP_EXPORT_CLASS
37 #define LEAP_EXPORT_PLUGIN __declspec(dllexport)
38 #elif !defined(SWIG)
39 #define LEAP_EXPORT __attribute__((visibility("default")))
40 #define LEAP_EXPORT_CLASS __attribute__((visibility("default")))
41 #define LEAP_EXPORT_PLUGIN __attribute__((visibility("default")))
42 #else
43 #define LEAP_EXPORT
44 #define LEAP_EXPORT_CLASS
45 #define LEAP_EXPORT_PLUGIN
46 #endif
47 
48 namespace Leap {
49 
50 // Interface for internal use only
51 class LEAP_EXPORT_CLASS Interface {
52  public:
53  struct Implementation {
54  LEAP_EXPORT virtual ~Implementation() {}
55  };
56  protected:
57  LEAP_EXPORT Interface(void* owner);
58  LEAP_EXPORT Interface(Implementation* reference, void* owner);
59  LEAP_EXPORT Interface(const Interface& rhs);
60  Interface(class SharedObject* object);
61  LEAP_EXPORT Interface& operator=(const Interface& rhs);
62  LEAP_EXPORT virtual ~Interface();
63  template<typename T> T* get() const { return static_cast<T*>(reference()); }
64  class SharedObject* m_object;
65  private:
66  LEAP_EXPORT Implementation* reference() const;
67 };
68 
69 // Forward declarations for internal use only
70 class PointableImplementation;
71 class FingerImplementation;
72 class ToolImplementation;
73 class HandImplementation;
74 class GestureImplementation;
75 class ScreenImplementation;
76 class DeviceImplementation;
77 class InteractionBoxImplementation;
78 class FrameImplementation;
79 class ControllerImplementation;
80 template<typename T> class ListBaseImplementation;
81 
82 // Forward declarations
83 class PointableList;
84 class FingerList;
85 class ToolList;
86 class HandList;
87 class GestureList;
88 class Hand;
89 class Gesture;
90 class Screen;
91 class InteractionBox;
92 class Frame;
93 class Listener;
94 
117 class Pointable : public Interface {
118  public:
119 
124  enum Zone {
125  ZONE_NONE = 0,
130  };
131 
132  // For internal use only.
133  Pointable(PointableImplementation*);
134  // For internal use only.
135  Pointable(FingerImplementation*);
136  // For internal use only.
137  Pointable(ToolImplementation*);
138 
145  LEAP_EXPORT Pointable();
146 
159  LEAP_EXPORT int32_t id() const;
160 
167  LEAP_EXPORT Frame frame() const;
168 
175  LEAP_EXPORT Hand hand() const;
176 
182  LEAP_EXPORT Vector tipPosition() const;
183 
189  LEAP_EXPORT Vector tipVelocity() const;
190 
202  LEAP_EXPORT Vector direction() const;
203 
213  LEAP_EXPORT float width() const;
214 
223  LEAP_EXPORT float length() const;
224 
231  LEAP_EXPORT bool isFinger() const;
232 
239  LEAP_EXPORT bool isTool() const;
240 
246  LEAP_EXPORT bool isValid() const;
247 
269  LEAP_EXPORT Zone touchZone() const;
270 
287  LEAP_EXPORT float touchDistance() const;
288 
298  LEAP_EXPORT Vector stabilizedTipPosition() const;
299 
309  LEAP_EXPORT static const Pointable& invalid();
310 
316  LEAP_EXPORT bool operator==(const Pointable&) const;
317 
323  LEAP_EXPORT bool operator!=(const Pointable&) const;
324 
326  LEAP_EXPORT friend std::ostream& operator<<(std::ostream&, const Pointable&);
327 
333  LEAP_EXPORT std::string toString() const;
334 };
335 
349 class Finger : public Pointable {
350  public:
351  // For internal use only.
352  Finger(FingerImplementation*);
353 
360  LEAP_EXPORT Finger();
361 
366  LEAP_EXPORT explicit Finger(const Pointable&);
367 
377  LEAP_EXPORT static const Finger& invalid();
378 
384  LEAP_EXPORT std::string toString() const;
385 };
386 
403 class Tool : public Pointable {
404  public:
405  // For internal use only.
406  Tool(ToolImplementation*);
407 
414  LEAP_EXPORT Tool();
415 
420  LEAP_EXPORT explicit Tool(const Pointable&);
421 
431  LEAP_EXPORT static const Tool& invalid();
432 
438  LEAP_EXPORT std::string toString() const;
439 };
440 
455 class Hand : public Interface {
456  public:
457  // For internal use only.
458  Hand(HandImplementation*);
459 
466  LEAP_EXPORT Hand();
467 
480  LEAP_EXPORT int32_t id() const;
481 
488  LEAP_EXPORT Frame frame() const;
489 
503  LEAP_EXPORT PointableList pointables() const;
504 
522  LEAP_EXPORT Pointable pointable(int32_t id) const;
523 
531  LEAP_EXPORT FingerList fingers() const;
532 
550  LEAP_EXPORT Finger finger(int32_t id) const;
551 
559  LEAP_EXPORT ToolList tools() const;
560 
578  LEAP_EXPORT Tool tool(int32_t id) const;
579 
585  LEAP_EXPORT Vector palmPosition() const;
586 
592  LEAP_EXPORT Vector palmVelocity() const;
593 
605  LEAP_EXPORT Vector palmNormal() const;
606 
615  LEAP_EXPORT Vector direction() const;
616 
626  LEAP_EXPORT Vector sphereCenter() const;
627 
635  LEAP_EXPORT float sphereRadius() const;
636 
653  LEAP_EXPORT Vector translation(const Frame& sinceFrame) const;
654 
668  LEAP_EXPORT float translationProbability(const Frame& sinceFrame) const;
669 
686  LEAP_EXPORT Vector rotationAxis(const Frame& sinceFrame) const;
687 
706  LEAP_EXPORT float rotationAngle(const Frame& sinceFrame) const;
707 
727  LEAP_EXPORT float rotationAngle(const Frame& sinceFrame, const Vector& axis) const;
728 
743  LEAP_EXPORT Matrix rotationMatrix(const Frame& sinceFrame) const;
744 
758  LEAP_EXPORT float rotationProbability(const Frame& sinceFrame) const;
759 
781  LEAP_EXPORT float scaleFactor(const Frame& sinceFrame) const;
782 
796  LEAP_EXPORT float scaleProbability(const Frame& sinceFrame) const;
797 
803  LEAP_EXPORT bool isValid() const;
804 
814  LEAP_EXPORT static const Hand& invalid();
815 
821  LEAP_EXPORT bool operator==(const Hand&) const;
822 
828  LEAP_EXPORT bool operator!=(const Hand&) const;
829 
831  LEAP_EXPORT friend std::ostream& operator<<(std::ostream&, const Hand&);
832 
838  LEAP_EXPORT std::string toString() const;
839 };
840 
903 class Gesture : public Interface {
904  public:
905  // For internal use only.
906  Gesture(GestureImplementation*);
907 
911  enum Type {
917  };
918 
922  enum State {
927  };
928 
936  LEAP_EXPORT Gesture();
937 
941  LEAP_EXPORT Gesture(const Gesture& rhs);
942 
948  LEAP_EXPORT Type type() const;
949 
959  LEAP_EXPORT State state() const;
960 
970  LEAP_EXPORT int32_t id() const;
971 
983  LEAP_EXPORT int64_t duration() const;
984 
990  LEAP_EXPORT float durationSeconds() const;
991 
997  LEAP_EXPORT Frame frame() const;
998 
1006  LEAP_EXPORT HandList hands() const;
1007 
1015  LEAP_EXPORT PointableList pointables() const;
1016 
1030  LEAP_EXPORT bool isValid() const;
1031 
1038  LEAP_EXPORT bool operator==(const Gesture& rhs) const;
1039 
1046  LEAP_EXPORT bool operator!=(const Gesture& rhs) const;
1047 
1052  LEAP_EXPORT std::string toString() const;
1053 
1063  LEAP_EXPORT static const Gesture& invalid();
1064 };
1065 
1092 class SwipeGesture : public Gesture
1093 {
1094  public:
1100  static Type classType() { return TYPE_SWIPE; }
1101 
1102  LEAP_EXPORT SwipeGesture();
1103 
1110  LEAP_EXPORT SwipeGesture(const Gesture& rhs);
1111 
1118  LEAP_EXPORT Vector startPosition() const;
1119 
1126  LEAP_EXPORT Vector position() const;
1127 
1139  LEAP_EXPORT Vector direction() const;
1140 
1147  LEAP_EXPORT float speed() const;
1148 
1154  LEAP_EXPORT Pointable pointable() const;
1155 };
1156 
1192 class CircleGesture : public Gesture
1193 {
1194  public:
1200  static Type classType() { return TYPE_CIRCLE; }
1201 
1208  LEAP_EXPORT CircleGesture();
1209 
1216  LEAP_EXPORT CircleGesture(const Gesture& rhs);
1217 
1223  LEAP_EXPORT Vector center() const;
1224 
1238  LEAP_EXPORT Vector normal() const;
1239 
1255  LEAP_EXPORT float progress() const;
1256 
1262  LEAP_EXPORT float radius() const;
1263 
1269  LEAP_EXPORT Pointable pointable() const;
1270 };
1271 
1307 {
1308  public:
1314  static Type classType() { return TYPE_SCREEN_TAP; }
1315 
1322  LEAP_EXPORT ScreenTapGesture();
1323 
1330  LEAP_EXPORT ScreenTapGesture(const Gesture& rhs);
1331 
1337  LEAP_EXPORT Vector position() const;
1338 
1344  LEAP_EXPORT Vector direction() const;
1345 
1351  LEAP_EXPORT float progress() const;
1352 
1358  LEAP_EXPORT Pointable pointable() const;
1359 };
1360 
1396 class KeyTapGesture : public Gesture
1397 {
1398  public:
1404  static Type classType() { return TYPE_KEY_TAP; }
1405 
1412  LEAP_EXPORT KeyTapGesture();
1413 
1420  LEAP_EXPORT KeyTapGesture(const Gesture& rhs);
1421 
1427  LEAP_EXPORT Vector position() const;
1428 
1435  LEAP_EXPORT Vector direction() const;
1436 
1442  LEAP_EXPORT float progress() const;
1443 
1449  LEAP_EXPORT Pointable pointable() const;
1450 };
1451 
1476 class Screen : public Interface {
1477  public:
1478  // For internal use only.
1479  Screen(ScreenImplementation*);
1480 
1488  LEAP_EXPORT Screen();
1489 
1496  LEAP_EXPORT int32_t id() const;
1497 
1561  LEAP_EXPORT Vector intersect(const Pointable& pointable, bool normalize, float clampRatio = 1.0f) const;
1562 
1623  LEAP_EXPORT Vector intersect(const Vector& position, const Vector& direction, bool normalize, float clampRatio = 1.0f) const;
1624 
1678  LEAP_EXPORT Vector project(const Vector& position, bool normalize, float clampRatio = 1.0f) const;
1679 
1693  LEAP_EXPORT Vector horizontalAxis() const;
1694 
1708  LEAP_EXPORT Vector verticalAxis() const;
1709 
1723  LEAP_EXPORT Vector bottomLeftCorner() const;
1724 
1734  LEAP_EXPORT Vector normal() const;
1735 
1741  LEAP_EXPORT int widthPixels() const;
1742 
1748  LEAP_EXPORT int heightPixels() const;
1749 
1757  LEAP_EXPORT float distanceToPoint(const Vector& point) const;
1758 
1771  LEAP_EXPORT bool isValid() const;
1772 
1782  LEAP_EXPORT static const Screen& invalid();
1783 
1789  LEAP_EXPORT bool operator==(const Screen&) const;
1790 
1796  LEAP_EXPORT bool operator!=(const Screen&) const;
1797 
1799  LEAP_EXPORT friend std::ostream& operator<<(std::ostream&, const Screen&);
1800 
1806  LEAP_EXPORT std::string toString() const;
1807 };
1808 
1819 class Device : public Interface {
1820  public:
1821  // For internal use only.
1822  Device(DeviceImplementation*);
1823 
1831  LEAP_EXPORT Device();
1832 
1844  LEAP_EXPORT float horizontalViewAngle() const;
1845 
1857  LEAP_EXPORT float verticalViewAngle() const;
1858 
1869  LEAP_EXPORT float range() const;
1870 
1883  LEAP_EXPORT float distanceToBoundary(const Vector& position) const;
1884 
1890  LEAP_EXPORT bool isValid() const;
1891 
1901  LEAP_EXPORT static const Device& invalid();
1902 
1909  LEAP_EXPORT bool operator==(const Device&) const;
1910 
1917  LEAP_EXPORT bool operator!=(const Device&) const;
1918 
1920  LEAP_EXPORT friend std::ostream& operator<<(std::ostream&, const Device&);
1921 
1927  LEAP_EXPORT std::string toString() const;
1928 };
1929 
1930 // For internal use only.
1931 template<typename L, typename T>
1932 class ConstListIterator {
1933  public:
1934  ConstListIterator<L,T>(const L& list, int index) : m_list(list), m_index(index) {}
1935 
1936  const T operator*() const { return m_list[m_index]; }
1937  const ConstListIterator<L,T>& operator++() { ++m_index; return *this; }
1938  bool operator!=(const ConstListIterator<L,T>& rhs) const { return m_index != rhs.m_index; }
1939 
1940  typedef std::ptrdiff_t difference_type;
1941  typedef T value_type;
1942  typedef const T* pointer;
1943  typedef const T& reference;
1944  typedef std::forward_iterator_tag iterator_category;
1945 
1946  private:
1947  const L& m_list;
1948  int m_index;
1949 };
1950 
1958 class PointableList : public Interface {
1959  public:
1960  // For internal use only.
1961  PointableList(const ListBaseImplementation<Pointable>&);
1962 
1964  LEAP_EXPORT PointableList();
1965 
1970  LEAP_EXPORT int count() const;
1971 
1976  LEAP_EXPORT bool isEmpty() const;
1977 
1982  LEAP_EXPORT bool empty() const;
1983 
1989  LEAP_EXPORT Pointable operator[](int index) const;
1990 
1996  LEAP_EXPORT PointableList& append(const PointableList& other);
1997 
2003  LEAP_EXPORT PointableList& append(const FingerList& other);
2004 
2010  LEAP_EXPORT PointableList& append(const ToolList& other);
2011 
2018  LEAP_EXPORT Pointable leftmost() const;
2019 
2026  LEAP_EXPORT Pointable rightmost() const;
2027 
2028 
2035  LEAP_EXPORT Pointable frontmost() const;
2036 
2038  typedef ConstListIterator<PointableList, Pointable> const_iterator;
2039 
2041  LEAP_EXPORT const_iterator begin() const;
2042 
2044  LEAP_EXPORT const_iterator end() const;
2045 };
2046 
2052 class FingerList : public Interface {
2053  public:
2054  // For internal use only.
2055  FingerList(const ListBaseImplementation<Finger>&);
2056 
2058  LEAP_EXPORT FingerList();
2059 
2064  LEAP_EXPORT int count() const;
2065 
2070  LEAP_EXPORT bool isEmpty() const;
2071 
2076  LEAP_EXPORT bool empty() const;
2077 
2083  LEAP_EXPORT Finger operator[](int index) const;
2084 
2090  LEAP_EXPORT FingerList& append(const FingerList& other);
2091 
2098  LEAP_EXPORT Finger leftmost() const;
2099 
2106  LEAP_EXPORT Finger rightmost() const;
2107 
2114  LEAP_EXPORT Finger frontmost() const;
2115 
2117  typedef ConstListIterator<FingerList, Finger> const_iterator;
2118 
2120  LEAP_EXPORT const_iterator begin() const;
2121 
2123  LEAP_EXPORT const_iterator end() const;
2124 };
2125 
2131 class ToolList : public Interface {
2132  public:
2133  // For internal use only.
2134  ToolList(const ListBaseImplementation<Tool>&);
2135 
2137  LEAP_EXPORT ToolList();
2138 
2143  LEAP_EXPORT int count() const;
2144 
2149  LEAP_EXPORT bool isEmpty() const;
2150 
2155  LEAP_EXPORT bool empty() const;
2156 
2162  LEAP_EXPORT Tool operator[](int index) const;
2163 
2169  LEAP_EXPORT ToolList& append(const ToolList& other);
2170 
2177  LEAP_EXPORT Tool leftmost() const;
2178 
2185  LEAP_EXPORT Tool rightmost() const;
2186 
2193  LEAP_EXPORT Tool frontmost() const;
2194 
2196  typedef ConstListIterator<ToolList, Tool> const_iterator;
2197 
2199  LEAP_EXPORT const_iterator begin() const;
2200 
2202  LEAP_EXPORT const_iterator end() const;
2203 };
2204 
2210 class HandList : public Interface {
2211  public:
2212  // For internal use only.
2213  HandList(const ListBaseImplementation<Hand>&);
2214 
2216  LEAP_EXPORT HandList();
2217 
2222  LEAP_EXPORT int count() const;
2223 
2228  LEAP_EXPORT bool isEmpty() const;
2229 
2234  LEAP_EXPORT bool empty() const;
2235 
2241  LEAP_EXPORT Hand operator[](int index) const;
2242 
2248  LEAP_EXPORT HandList& append(const HandList& other);
2249 
2256  LEAP_EXPORT Hand leftmost() const;
2257 
2264  LEAP_EXPORT Hand rightmost() const;
2265 
2272  LEAP_EXPORT Hand frontmost() const;
2273 
2275  typedef ConstListIterator<HandList, Hand> const_iterator;
2276 
2278  LEAP_EXPORT const_iterator begin() const;
2279 
2281  LEAP_EXPORT const_iterator end() const;
2282 };
2283 
2289 class GestureList : public Interface {
2290  public:
2291  // For internal use only.
2292  GestureList(const ListBaseImplementation<Gesture>&);
2293 
2295  LEAP_EXPORT GestureList();
2296 
2301  LEAP_EXPORT int count() const;
2302 
2307  LEAP_EXPORT bool isEmpty() const;
2308 
2313  LEAP_EXPORT bool empty() const;
2314 
2320  LEAP_EXPORT Gesture operator[](int index) const;
2321 
2327  LEAP_EXPORT GestureList& append(const GestureList& other);
2328 
2330  typedef ConstListIterator<GestureList, Gesture> const_iterator;
2331 
2333  LEAP_EXPORT const_iterator begin() const;
2334 
2336  LEAP_EXPORT const_iterator end() const;
2337 };
2338 
2353 class ScreenList : public Interface {
2354  public:
2355  // For internal use only.
2356  ScreenList(const ListBaseImplementation<Screen>&);
2357 
2359  LEAP_EXPORT ScreenList();
2360 
2365  LEAP_EXPORT int count() const;
2366 
2371  LEAP_EXPORT bool isEmpty() const;
2372 
2377  LEAP_EXPORT bool empty() const;
2378 
2384  LEAP_EXPORT Screen operator[](int index) const;
2385 
2387  typedef ConstListIterator<ScreenList, Screen> const_iterator;
2388 
2390  LEAP_EXPORT const_iterator begin() const;
2391 
2393  LEAP_EXPORT const_iterator end() const;
2394 
2419  LEAP_EXPORT Screen closestScreenHit(const Pointable& pointable) const;
2420 
2446  LEAP_EXPORT Screen closestScreenHit(const Vector& position, const Vector& direction) const;
2447 
2461  LEAP_EXPORT Screen closestScreen(const Vector& position) const;
2462 };
2463 
2469 class DeviceList : public Interface {
2470  public:
2471  // For internal use only.
2472  DeviceList(const ListBaseImplementation<Device>&);
2473 
2475  LEAP_EXPORT DeviceList();
2476 
2481  LEAP_EXPORT int count() const;
2482 
2487  LEAP_EXPORT bool isEmpty() const;
2488 
2494  LEAP_EXPORT Device operator[](int index) const;
2495 
2501  LEAP_EXPORT DeviceList& append(const DeviceList& other);
2502 
2504  typedef ConstListIterator<DeviceList, Device> const_iterator;
2505 
2507  LEAP_EXPORT const_iterator begin() const;
2508 
2510  LEAP_EXPORT const_iterator end() const;
2511 };
2512 
2527 class InteractionBox : public Interface {
2528  public:
2529  // For internal use only.
2530  InteractionBox(InteractionBoxImplementation*);
2531 
2532  LEAP_EXPORT InteractionBox();
2533 
2546  LEAP_EXPORT Vector normalizePoint(const Vector& position, bool clamp = true) const;
2547 
2557  LEAP_EXPORT Vector denormalizePoint(const Vector& normalizedPosition) const;
2558 
2565  LEAP_EXPORT Vector center() const;
2566 
2572  LEAP_EXPORT float width() const;
2573 
2579  LEAP_EXPORT float height() const;
2580 
2586  LEAP_EXPORT float depth() const;
2587 
2593  LEAP_EXPORT bool isValid() const;
2594 
2604  LEAP_EXPORT static const InteractionBox& invalid();
2605 
2611  LEAP_EXPORT bool operator==(const InteractionBox&) const;
2612 
2618  LEAP_EXPORT bool operator!=(const InteractionBox&) const;
2619 
2621  LEAP_EXPORT friend std::ostream& operator<<(std::ostream&, const InteractionBox&);
2622 
2628  LEAP_EXPORT std::string toString() const;
2629 };
2630 
2641 class Frame : public Interface {
2642  public:
2643  // For internal use only.
2644  Frame(FrameImplementation*);
2645 
2652  LEAP_EXPORT Frame();
2653 
2660  LEAP_EXPORT int64_t id() const;
2661 
2667  LEAP_EXPORT int64_t timestamp() const;
2668 
2675  LEAP_EXPORT HandList hands() const;
2676 
2694  LEAP_EXPORT Hand hand(int32_t id) const;
2695 
2702  LEAP_EXPORT PointableList pointables() const;
2703 
2721  LEAP_EXPORT Pointable pointable(int32_t id) const;
2722 
2729  LEAP_EXPORT FingerList fingers() const;
2730 
2748  LEAP_EXPORT Finger finger(int32_t id) const;
2749 
2756  LEAP_EXPORT ToolList tools() const;
2757 
2775  LEAP_EXPORT Tool tool(int32_t id) const;
2776 
2791  LEAP_EXPORT Gesture gesture(int32_t id) const;
2792 
2801  LEAP_EXPORT GestureList gestures() const;
2802 
2813  LEAP_EXPORT GestureList gestures(const Frame& sinceFrame) const;
2814 
2833  LEAP_EXPORT Vector translation(const Frame& sinceFrame) const;
2834 
2847  LEAP_EXPORT float translationProbability(const Frame& sinceFrame) const;
2848 
2866  LEAP_EXPORT Vector rotationAxis(const Frame& sinceFrame) const;
2867 
2887  LEAP_EXPORT float rotationAngle(const Frame& sinceFrame) const;
2888 
2909  LEAP_EXPORT float rotationAngle(const Frame& sinceFrame, const Vector& axis) const;
2910 
2926  LEAP_EXPORT Matrix rotationMatrix(const Frame& sinceFrame) const;
2927 
2940  LEAP_EXPORT float rotationProbability(const Frame& sinceFrame) const;
2941 
2962  LEAP_EXPORT float scaleFactor(const Frame& sinceFrame) const;
2963 
2976  LEAP_EXPORT float scaleProbability(const Frame& sinceFrame) const;
2977 
2984  LEAP_EXPORT InteractionBox interactionBox() const;
2985 
3004  LEAP_EXPORT bool isValid() const;
3005 
3015  LEAP_EXPORT static const Frame& invalid();
3016 
3022  LEAP_EXPORT bool operator==(const Frame&) const;
3023 
3029  LEAP_EXPORT bool operator!=(const Frame&) const;
3030 
3032  LEAP_EXPORT friend std::ostream& operator<<(std::ostream&, const Frame&);
3033 
3039  LEAP_EXPORT std::string toString() const;
3040 };
3041 
3071 class Config : public Interface {
3072  public:
3074  LEAP_EXPORT Config();
3075 
3081  enum ValueType {
3087  };
3088 
3096  LEAP_EXPORT ValueType type(const std::string& key) const;
3097 
3099  LEAP_EXPORT bool getBool(const std::string& key) const;
3100 
3104  LEAP_EXPORT bool setBool(const std::string& key, bool value);
3105 
3107  LEAP_EXPORT int32_t getInt32(const std::string& key) const;
3108 
3112  LEAP_EXPORT bool setInt32(const std::string& key, int32_t value);
3113 
3115  LEAP_EXPORT float getFloat(const std::string& key) const;
3116 
3120  LEAP_EXPORT bool setFloat(const std::string& key, float value);
3121 
3123  LEAP_EXPORT std::string getString(const std::string& key) const;
3124 
3128  LEAP_EXPORT bool setString(const std::string& key, const std::string& value);
3129 
3140  LEAP_EXPORT bool save();
3141 };
3142 
3185 class Controller : public Interface {
3186  public:
3187  // For internal use only.
3188  Controller(ControllerImplementation*);
3189 
3197  LEAP_EXPORT Controller();
3198  LEAP_EXPORT virtual ~Controller();
3209  LEAP_EXPORT Controller(Listener& listener);
3210 
3225  LEAP_EXPORT bool isConnected() const;
3226 
3239  LEAP_EXPORT bool hasFocus() const;
3240 
3248  enum PolicyFlag {
3251  };
3252 
3268  LEAP_EXPORT PolicyFlag policyFlags() const;
3269 
3299  LEAP_EXPORT void setPolicyFlags(PolicyFlag flags) const;
3300 
3315  LEAP_EXPORT bool addListener(Listener& listener);
3316 
3326  LEAP_EXPORT bool removeListener(Listener& listener);
3327 
3341  LEAP_EXPORT Frame frame(int history = 0) const;
3342 
3347  LEAP_EXPORT Config config() const;
3348 
3357  LEAP_EXPORT DeviceList devices() const;
3358 
3392  LEAP_EXPORT ScreenList locatedScreens() const;
3393 
3398  LEAP_EXPORT ScreenList calibratedScreens() const;
3399 
3416  LEAP_EXPORT void enableGesture(Gesture::Type type, bool enable = true) const;
3417 
3424  LEAP_EXPORT bool isGestureEnabled(Gesture::Type type) const;
3425 };
3426 
3439 class Listener {
3440  public:
3442  LEAP_EXPORT Listener() {}
3443 
3445  LEAP_EXPORT virtual ~Listener() {}
3446 
3454  LEAP_EXPORT virtual void onInit(const Controller&) {}
3455 
3464  LEAP_EXPORT virtual void onConnect(const Controller&) {}
3465 
3480  LEAP_EXPORT virtual void onDisconnect(const Controller&) {}
3481 
3490  LEAP_EXPORT virtual void onExit(const Controller&) {}
3491 
3508  LEAP_EXPORT virtual void onFrame(const Controller&) {}
3509 
3521  LEAP_EXPORT virtual void onFocusGained(const Controller&) {}
3522 
3534  LEAP_EXPORT virtual void onFocusLost(const Controller&) {}
3535 };
3536 
3537 }
3538 
3539 #endif // __Leap_h__