Leap.h 159 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566
  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. #if !defined(__Leap_h__)
  9. #define __Leap_h__
  10. #include "LeapMath.h"
  11. #include <string>
  12. #include <vector>
  13. // Define integer types for Visual Studio 2008 and earlier
  14. #if defined(_MSC_VER) && (_MSC_VER < 1600)
  15. typedef __int32 int32_t;
  16. typedef __int64 int64_t;
  17. typedef unsigned __int32 uint32_t;
  18. typedef unsigned __int64 uint64_t;
  19. #else
  20. #include <stdint.h>
  21. #endif
  22. // Define Leap export macros
  23. #if defined(_WIN32) // Windows
  24. #if LEAP_API_INTERNAL
  25. #define LEAP_EXPORT
  26. #elif LEAP_API_IMPLEMENTATION
  27. #define LEAP_EXPORT __declspec(dllexport)
  28. #else
  29. #define LEAP_EXPORT __declspec(dllimport)
  30. #endif
  31. #define LEAP_EXPORT_CLASS
  32. #define LEAP_EXPORT_PLUGIN __declspec(dllexport)
  33. #elif !defined(SWIG)
  34. #define LEAP_EXPORT __attribute__((visibility("default")))
  35. #define LEAP_EXPORT_CLASS __attribute__((visibility("default")))
  36. #define LEAP_EXPORT_PLUGIN __attribute__((visibility("default")))
  37. #else
  38. #define LEAP_EXPORT
  39. #define LEAP_EXPORT_CLASS
  40. #define LEAP_EXPORT_PLUGIN
  41. #endif
  42. namespace Leap {
  43. // Interface for internal use only
  44. class LEAP_EXPORT_CLASS Interface {
  45. public:
  46. struct Implementation {
  47. LEAP_EXPORT virtual ~Implementation() {}
  48. };
  49. protected:
  50. LEAP_EXPORT Interface(void* owner);
  51. LEAP_EXPORT Interface(Implementation* reference, void* owner);
  52. LEAP_EXPORT Interface(const Interface& rhs);
  53. Interface(class SharedObject* object);
  54. LEAP_EXPORT Interface& operator=(const Interface& rhs);
  55. LEAP_EXPORT virtual ~Interface();
  56. template<typename T> T* get() const { return static_cast<T*>(reference()); }
  57. class SharedObject* m_object;
  58. private:
  59. LEAP_EXPORT Implementation* reference() const;
  60. };
  61. // Forward declarations for internal use only
  62. class PointableImplementation;
  63. class FingerImplementation;
  64. class ToolImplementation;
  65. class HandImplementation;
  66. class GestureImplementation;
  67. class ScreenImplementation;
  68. class DeviceImplementation;
  69. class InteractionBoxImplementation;
  70. class FrameImplementation;
  71. class ControllerImplementation;
  72. template<typename T> class ListBaseImplementation;
  73. // Forward declarations
  74. class PointableList;
  75. class FingerList;
  76. class ToolList;
  77. class HandList;
  78. class GestureList;
  79. class Hand;
  80. class Gesture;
  81. class Screen;
  82. class InteractionBox;
  83. class Frame;
  84. class Listener;
  85. /**
  86. * The Pointable class reports the physical characteristics of a detected finger or tool.
  87. *
  88. * Both fingers and tools are classified as Pointable objects. Use the Pointable::isFinger()
  89. * function to determine whether a Pointable object represents a finger. Use the
  90. * Pointable::isTool() function to determine whether a Pointable object represents a tool.
  91. * The Leap Motion software classifies a detected entity as a tool when it is thinner, straighter, and longer
  92. * than a typical finger.
  93. *
  94. * \include Pointable_Get_Basic.txt
  95. *
  96. * To provide touch emulation, the Leap Motion software associates a floating touch
  97. * plane that adapts to the user's finger movement and hand posture. The Leap Motion
  98. * interprets purposeful movements toward this plane as potential touch points.
  99. * The Pointable class reports
  100. * touch state with the touchZone and touchDistance values.
  101. *
  102. * Note that Pointable objects can be invalid, which means that they do not contain
  103. * valid tracking data and do not correspond to a physical entity. Invalid Pointable
  104. * objects can be the result of asking for a Pointable object using an ID from an
  105. * earlier frame when no Pointable objects with that ID exist in the current frame.
  106. * A Pointable object created from the Pointable constructor is also invalid.
  107. * Test for validity with the Pointable::isValid() function.
  108. *
  109. * @since 1.0
  110. */
  111. class Pointable : public Interface {
  112. public:
  113. /**
  114. * Defines the values for reporting the state of a Pointable object in relation to
  115. * an adaptive touch plane.
  116. * @since 1.0
  117. */
  118. enum Zone {
  119. /**
  120. * The Pointable object is too far from the plane to be
  121. * considered hovering or touching.
  122. * @since 1.0
  123. */
  124. ZONE_NONE = 0,
  125. /**
  126. * The Pointable object is close to, but not touching
  127. * the plane.
  128. * @since 1.0
  129. */
  130. ZONE_HOVERING = 1,
  131. /**
  132. * The Pointable has penetrated the plane.
  133. * @since 1.0
  134. */
  135. ZONE_TOUCHING = 2,
  136. };
  137. // For internal use only.
  138. Pointable(PointableImplementation*);
  139. // For internal use only.
  140. Pointable(FingerImplementation*);
  141. // For internal use only.
  142. Pointable(ToolImplementation*);
  143. /**
  144. * Constructs a Pointable object.
  145. *
  146. * An uninitialized pointable is considered invalid.
  147. * Get valid Pointable objects from a Frame or a Hand object.
  148. *
  149. * \include Pointable_Pointable.txt
  150. *
  151. * @since 1.0
  152. */
  153. LEAP_EXPORT Pointable();
  154. /**
  155. * A unique ID assigned to this Pointable object, whose value remains the
  156. * same across consecutive frames while the tracked finger or tool remains
  157. * visible. If tracking is lost (for example, when a finger is occluded by
  158. * another finger or when it is withdrawn from the Leap Motion Controller field of view), the
  159. * Leap Motion software may assign a new ID when it detects the entity in a future frame.
  160. *
  161. * \include Pointable_id.txt
  162. *
  163. * Use the ID value with the Frame::pointable() function to find this
  164. * Pointable object in future frames.
  165. *
  166. * IDs should be from 1 to 100 (inclusive). If more than 100 objects are tracked
  167. * an IDs of -1 will be used until an ID in the defined range is available.
  168. *
  169. * @returns The ID assigned to this Pointable object.
  170. * @since 1.0
  171. */
  172. LEAP_EXPORT int32_t id() const;
  173. /**
  174. * The Frame associated with this Pointable object.
  175. *
  176. * \include Pointable_frame.txt
  177. *
  178. * @returns The associated Frame object, if available; otherwise,
  179. * an invalid Frame object is returned.
  180. * @since 1.0
  181. */
  182. LEAP_EXPORT Frame frame() const;
  183. /**
  184. * The Hand associated with this finger or tool.
  185. *
  186. * \include Pointable_hand.txt
  187. *
  188. * @returns The associated Hand object, if available; otherwise,
  189. * an invalid Hand object is returned.
  190. * @since 1.0
  191. */
  192. LEAP_EXPORT Hand hand() const;
  193. /**
  194. * The tip position in millimeters from the Leap Motion origin.
  195. *
  196. * \include Pointable_tipPosition.txt
  197. *
  198. * @returns The Vector containing the coordinates of the tip position.
  199. * @since 1.0
  200. */
  201. LEAP_EXPORT Vector tipPosition() const;
  202. /**
  203. * The rate of change of the tip position in millimeters/second.
  204. *
  205. * \include Pointable_tipVelocity.txt
  206. *
  207. * @returns The Vector containing the coordinates of the tip velocity.
  208. * @since 1.0
  209. */
  210. LEAP_EXPORT Vector tipVelocity() const;
  211. /**
  212. * The direction in which this finger or tool is pointing.
  213. *
  214. * \include Pointable_direction.txt
  215. *
  216. * The direction is expressed as a unit vector pointing in the same
  217. * direction as the tip.
  218. *
  219. * \image html images/Leap_Finger_Model.png
  220. *
  221. * @returns The Vector pointing in the same direction as the tip of this
  222. * Pointable object.
  223. * @since 1.0
  224. */
  225. LEAP_EXPORT Vector direction() const;
  226. /**
  227. * The estimated width of the finger or tool in millimeters.
  228. *
  229. * \include Pointable_width.txt
  230. *
  231. * The reported width is the average width of the visible portion of the
  232. * finger or tool from the hand to the tip. If the width isn't known,
  233. * then a value of 0 is returned.
  234. *
  235. * @returns The estimated width of this Pointable object.
  236. * @since 1.0
  237. */
  238. LEAP_EXPORT float width() const;
  239. /**
  240. * The estimated length of the finger or tool in millimeters.
  241. *
  242. * The reported length is the visible length of the finger or tool from the
  243. * hand to tip. If the length isn't known, then a value of 0 is returned.
  244. *
  245. * \include Pointable_length.txt
  246. *
  247. * @returns The estimated length of this Pointable object.
  248. * @since 1.0
  249. */
  250. LEAP_EXPORT float length() const;
  251. /**
  252. * Whether or not the Pointable is believed to be a finger.
  253. * Fingers are generally shorter, thicker, and less straight than tools.
  254. *
  255. * \include Pointable_Conversion.txt
  256. *
  257. * @returns True, if this Pointable is classified as a finger.
  258. * @since 1.0
  259. */
  260. LEAP_EXPORT bool isFinger() const;
  261. /**
  262. * Whether or not the Pointable is believed to be a tool.
  263. * Tools are generally longer, thinner, and straighter than fingers.
  264. *
  265. * \include Pointable_Conversion.txt
  266. *
  267. * @returns True, if this Pointable is classified as a tool.
  268. * @since 1.0
  269. */
  270. LEAP_EXPORT bool isTool() const;
  271. /**
  272. * Reports whether this is a valid Pointable object.
  273. *
  274. * \include Pointable_isValid.txt
  275. *
  276. * @returns True, if this Pointable object contains valid tracking data.
  277. * @since 1.0
  278. */
  279. LEAP_EXPORT bool isValid() const;
  280. /**
  281. * The current touch zone of this Pointable object.
  282. *
  283. * The Leap Motion software computes the touch zone based on a floating touch
  284. * plane that adapts to the user's finger movement and hand posture. The Leap
  285. * Motion software interprets purposeful movements toward this plane as potential touch
  286. * points. When a Pointable moves close to the adaptive touch plane, it enters the
  287. * "hovering" zone. When a Pointable reaches or passes through the plane, it enters
  288. * the "touching" zone.
  289. *
  290. * The possible states are present in the Zone enum of this class:
  291. *
  292. * * Zone.NONE -- The Pointable is outside the hovering zone.
  293. * * Zone.HOVERING -- The Pointable is close to, but not touching the touch plane.
  294. * * Zone.TOUCHING -- The Pointable has penetrated the touch plane.
  295. *
  296. * The touchDistance value provides a normalized indication of the distance to
  297. * the touch plane when the Pointable is in the hovering or touching zones.
  298. *
  299. * \include Pointable_touchZone.txt
  300. *
  301. * @returns The touch zone of this Pointable
  302. * @since 1.0
  303. */
  304. LEAP_EXPORT Zone touchZone() const;
  305. /**
  306. * A value proportional to the distance between this Pointable object and the
  307. * adaptive touch plane.
  308. *
  309. * \image html images/Leap_Touch_Plane.png
  310. *
  311. * The touch distance is a value in the range [-1, 1]. The value 1.0 indicates the
  312. * Pointable is at the far edge of the hovering zone. The value 0 indicates the
  313. * Pointable is just entering the touching zone. A value of -1.0 indicates the
  314. * Pointable is firmly within the touching zone. Values in between are
  315. * proportional to the distance from the plane. Thus, the touchDistance of 0.5
  316. * indicates that the Pointable is halfway into the hovering zone.
  317. *
  318. * \include Pointable_touchDistance.txt
  319. *
  320. * You can use the touchDistance value to modulate visual feedback given to the
  321. * user as their fingers close in on a touch target, such as a button.
  322. *
  323. * @returns The normalized touch distance of this Pointable object.
  324. * @since 1.0
  325. */
  326. LEAP_EXPORT float touchDistance() const;
  327. /**
  328. * The stabilized tip position of this Pointable.
  329. *
  330. * Smoothing and stabilization is performed in order to make
  331. * this value more suitable for interaction with 2D content. The stabilized
  332. * position lags behind the tip position by a variable amount, depending
  333. * primarily on the speed of movement.
  334. *
  335. * \include Pointable_stabilizedTipPosition.txt
  336. *
  337. * @returns A modified tip position of this Pointable object
  338. * with some additional smoothing and stabilization applied.
  339. * @since 1.0
  340. */
  341. LEAP_EXPORT Vector stabilizedTipPosition() const;
  342. /**
  343. * The duration of time this Pointable has been visible to the Leap Motion Controller.
  344. *
  345. * \include Pointable_timeVisible.txt
  346. *
  347. * @returns The duration (in seconds) that this Pointable has been tracked.
  348. * @since 1.0
  349. */
  350. LEAP_EXPORT float timeVisible() const;
  351. /**
  352. * Returns an invalid Pointable object.
  353. *
  354. * You can use the instance returned by this function in comparisons testing
  355. * whether a given Pointable instance is valid or invalid. (You can also use the
  356. * Pointable::isValid() function.)
  357. *
  358. * \include Pointable_invalid.txt
  359. *
  360. * @returns The invalid Pointable instance.
  361. * @since 1.0
  362. */
  363. LEAP_EXPORT static const Pointable& invalid();
  364. /**
  365. * Compare Pointable object equality.
  366. *
  367. * \include Pointable_operator_equals.txt
  368. *
  369. * Two Pointable objects are equal if and only if both Pointable objects represent the
  370. * exact same physical entities in the same frame and both Pointable objects are valid.
  371. * @since 1.0
  372. */
  373. LEAP_EXPORT bool operator==(const Pointable&) const;
  374. /**
  375. * Compare Pointable object inequality.
  376. *
  377. * \include Pointable_operator_not_equal.txt
  378. *
  379. * Two Pointable objects are equal if and only if both Pointable objects represent the
  380. * exact same physical entities in the same frame and both Pointable objects are valid.
  381. * @since 1.0
  382. */
  383. LEAP_EXPORT bool operator!=(const Pointable&) const;
  384. /**
  385. * Writes a brief, human readable description of the Pointable object to an output stream.
  386. *
  387. * \include Pointable_operator_stream.txt
  388. *
  389. * @since 1.0
  390. */
  391. LEAP_EXPORT friend std::ostream& operator<<(std::ostream&, const Pointable&);
  392. /**
  393. * A string containing a brief, human readable description of the Pointable object.
  394. *
  395. * @returns A description of the Pointable object as a string.
  396. * @since 1.0
  397. */
  398. LEAP_EXPORT std::string toString() const;
  399. };
  400. /**
  401. * The Finger class represents a tracked finger.
  402. *
  403. * Fingers are Pointable objects that the Leap Motion software has classified as a finger.
  404. * Get valid Finger objects from a Frame or a Hand object.
  405. *
  406. * Fingers may be permanently associated to a hand. In this case the angular order of the finger IDs
  407. * will be invariant. As fingers move in and out of view it is possible for the guessed ID
  408. * of a finger to be incorrect. Consequently, it may be necessary for finger IDs to be
  409. * exchanged. All tracked properties, such as velocity, will remain continuous in the API.
  410. * However, quantities that are derived from the API output (such as a history of positions)
  411. * will be discontinuous unless they have a corresponding ID exchange.
  412. *
  413. * Note that Finger objects can be invalid, which means that they do not contain
  414. * valid tracking data and do not correspond to a physical finger. Invalid Finger
  415. * objects can be the result of asking for a Finger object using an ID from an
  416. * earlier frame when no Finger objects with that ID exist in the current frame.
  417. * A Finger object created from the Finger constructor is also invalid.
  418. * Test for validity with the Finger::isValid() function.
  419. * @since 1.0
  420. */
  421. class Finger : public Pointable {
  422. public:
  423. // For internal use only.
  424. Finger(FingerImplementation*);
  425. /**
  426. * Constructs a Finger object.
  427. *
  428. * An uninitialized finger is considered invalid.
  429. * Get valid Finger objects from a Frame or a Hand object.
  430. * @since 1.0
  431. */
  432. LEAP_EXPORT Finger();
  433. /**
  434. * If the specified Pointable object represents a finger, creates a copy
  435. * of it as a Finger object; otherwise, creates an invalid Finger object.
  436. *
  437. * \include Finger_Finger.txt
  438. *
  439. * @since 1.0
  440. */
  441. LEAP_EXPORT explicit Finger(const Pointable&);
  442. /**
  443. * Returns an invalid Finger object.
  444. *
  445. * You can use the instance returned by this function in comparisons testing
  446. * whether a given Finger instance is valid or invalid. (You can also use the
  447. * Finger::isValid() function.)
  448. *
  449. * \include Finger_invalid.txt
  450. *
  451. * @returns The invalid Finger instance.
  452. * @since 1.0
  453. */
  454. LEAP_EXPORT static const Finger& invalid();
  455. /**
  456. * A string containing a brief, human readable description of the Finger object.
  457. *
  458. * @returns A description of the Finger object as a string.
  459. * @since 1.0
  460. */
  461. LEAP_EXPORT std::string toString() const;
  462. };
  463. /**
  464. * The Tool class represents a tracked tool.
  465. *
  466. * Tools are Pointable objects that the Leap Motion software has classified as a tool.
  467. * Tools are longer, thinner, and straighter than a typical finger.
  468. * Get valid Tool objects from a Frame or a Hand object.
  469. *
  470. * Tools may reference a hand, but unlike fingers they are not permanently associated.
  471. * Instead, a tool can be transferred between hands while keeping the same ID.
  472. *
  473. * \image html images/Leap_Tool.png
  474. *
  475. * Note that Tool objects can be invalid, which means that they do not contain
  476. * valid tracking data and do not correspond to a physical tool. Invalid Tool
  477. * objects can be the result of asking for a Tool object using an ID from an
  478. * earlier frame when no Tool objects with that ID exist in the current frame.
  479. * A Tool object created from the Tool constructor is also invalid.
  480. * Test for validity with the Tool::isValid() function.
  481. * @since 1.0
  482. */
  483. class Tool : public Pointable {
  484. public:
  485. // For internal use only.
  486. Tool(ToolImplementation*);
  487. /**
  488. * Constructs a Tool object.
  489. *
  490. * An uninitialized tool is considered invalid.
  491. * Get valid Tool objects from a Frame or a Hand object.
  492. *
  493. * \include Tool_Tool.txt
  494. *
  495. * @since 1.0
  496. */
  497. LEAP_EXPORT Tool();
  498. /**
  499. * If the specified Pointable object represents a tool, creates a copy
  500. * of it as a Tool object; otherwise, creates an invalid Tool object.
  501. *
  502. * \include Tool_Tool_copy.txt
  503. *
  504. * @since 1.0
  505. */
  506. LEAP_EXPORT explicit Tool(const Pointable&);
  507. /**
  508. * Returns an invalid Tool object.
  509. *
  510. * You can use the instance returned by this function in comparisons testing
  511. * whether a given Tool instance is valid or invalid. (You can also use the
  512. * Tool::isValid() function.)
  513. *
  514. * \include Tool_invalid.txt
  515. *
  516. * @returns The invalid Tool instance.
  517. * @since 1.0
  518. */
  519. LEAP_EXPORT static const Tool& invalid();
  520. /**
  521. * A string containing a brief, human readable description of the Tool object.
  522. *
  523. * @returns A description of the Tool object as a string.
  524. * @since 1.0
  525. */
  526. LEAP_EXPORT std::string toString() const;
  527. };
  528. /**
  529. * The Hand class reports the physical characteristics of a detected hand.
  530. *
  531. * Hand tracking data includes a palm position and velocity; vectors for
  532. * the palm normal and direction to the fingers; properties of a sphere fit
  533. * to the hand; and lists of the attached fingers and tools.
  534. *
  535. * Get Hand objects from a Frame object:
  536. *
  537. * \include Hand_Get_First.txt
  538. *
  539. * Note that Hand objects can be invalid, which means that they do not contain
  540. * valid tracking data and do not correspond to a physical entity. Invalid Hand
  541. * objects can be the result of asking for a Hand object using an ID from an
  542. * earlier frame when no Hand objects with that ID exist in the current frame.
  543. * A Hand object created from the Hand constructor is also invalid.
  544. * Test for validity with the Hand::isValid() function.
  545. * @since 1.0
  546. */
  547. class Hand : public Interface {
  548. public:
  549. // For internal use only.
  550. Hand(HandImplementation*);
  551. /**
  552. * Constructs a Hand object.
  553. *
  554. * An uninitialized hand is considered invalid.
  555. * Get valid Hand objects from a Frame object.
  556. *
  557. * \include Hand_Hand.txt
  558. *
  559. * @since 1.0
  560. */
  561. LEAP_EXPORT Hand();
  562. /**
  563. * A unique ID assigned to this Hand object, whose value remains the same
  564. * across consecutive frames while the tracked hand remains visible. If
  565. * tracking is lost (for example, when a hand is occluded by another hand
  566. * or when it is withdrawn from or reaches the edge of the Leap Motion Controller field of view),
  567. * the Leap Motion software may assign a new ID when it detects the hand in a future frame.
  568. *
  569. * Use the ID value with the Frame::hand() function to find this Hand object
  570. * in future frames:
  571. *
  572. * \include Hand_Get_ID.txt
  573. *
  574. * @returns The ID of this hand.
  575. * @since 1.0
  576. */
  577. LEAP_EXPORT int32_t id() const;
  578. /**
  579. * The Frame associated with this Hand.
  580. *
  581. * \include Hand_frame.txt
  582. *
  583. * @returns The associated Frame object, if available; otherwise,
  584. * an invalid Frame object is returned.
  585. * @since 1.0
  586. */
  587. LEAP_EXPORT Frame frame() const;
  588. /**
  589. * The list of Pointable objects (fingers and tools) detected in this frame
  590. * that are associated with this hand, given in arbitrary order. The list
  591. * can be empty if no fingers or tools associated with this hand are detected.
  592. *
  593. * Use the Pointable::isFinger() function to determine whether or not an
  594. * item in the list represents a finger. Use the Pointable::isTool() function
  595. * to determine whether or not an item in the list represents a tool.
  596. * You can also get only fingers using the Hand::fingers() function or
  597. * only tools using the Hand::tools() function.
  598. *
  599. * \include Hand_Get_Fingers.txt
  600. *
  601. * @returns The PointableList containing all Pointable objects associated with this hand.
  602. * @since 1.0
  603. */
  604. LEAP_EXPORT PointableList pointables() const;
  605. /**
  606. * The Pointable object with the specified ID associated with this hand.
  607. *
  608. * Use the Hand::pointable() function to retrieve a Pointable object
  609. * associated with this hand using an ID value obtained from a previous frame.
  610. * This function always returns a Pointable object, but if no finger or tool
  611. * with the specified ID is present, an invalid Pointable object is returned.
  612. *
  613. * \include Hand_Get_Pointable_ByID.txt
  614. *
  615. * Note that the ID values assigned to objects persist across frames, but only until
  616. * tracking of that object is lost. If tracking of a finger or tool is lost and subsequently
  617. * regained, the new Pointable object representing that finger or tool may have a
  618. * different ID than that representing the finger or tool in an earlier frame.
  619. *
  620. * @param id The ID value of a Pointable object from a previous frame.
  621. * @returns The Pointable object with the matching ID if one exists for this
  622. * hand in this frame; otherwise, an invalid Pointable object is returned.
  623. * @since 1.0
  624. */
  625. LEAP_EXPORT Pointable pointable(int32_t id) const;
  626. /**
  627. * The list of Finger objects detected in this frame that are attached to
  628. * this hand, given in arbitrary order.
  629. * The list can be empty if no fingers attached to this hand are detected.
  630. *
  631. * \include Hand_Get_Fingers.txt
  632. *
  633. * @returns The FingerList containing all Finger objects attached to this hand.
  634. * @since 1.0
  635. */
  636. LEAP_EXPORT FingerList fingers() const;
  637. /**
  638. * The Finger object with the specified ID attached to this hand.
  639. *
  640. * Use the Hand::finger() function to retrieve a Finger object attached to
  641. * this hand using an ID value obtained from a previous frame.
  642. * This function always returns a Finger object, but if no finger
  643. * with the specified ID is present, an invalid Finger object is returned.
  644. *
  645. * \include Hand_finger.txt
  646. *
  647. * Note that ID values persist across frames, but only until tracking of a
  648. * particular object is lost. If tracking of a finger is lost and subsequently
  649. * regained, the new Finger object representing that finger may have a
  650. * different ID than that representing the finger in an earlier frame.
  651. *
  652. * @param id The ID value of a Finger object from a previous frame.
  653. * @returns The Finger object with the matching ID if one exists for this
  654. * hand in this frame; otherwise, an invalid Finger object is returned.
  655. * @since 1.0
  656. */
  657. LEAP_EXPORT Finger finger(int32_t id) const;
  658. /**
  659. * The list of Tool objects detected in this frame that are held by this
  660. * hand, given in arbitrary order.
  661. * The list can be empty if no tools held by this hand are detected.
  662. *
  663. * \include Hand_tools.txt
  664. *
  665. * @returns The ToolList containing all Tool objects held by this hand.
  666. * @since 1.0
  667. */
  668. LEAP_EXPORT ToolList tools() const;
  669. /**
  670. * The Tool object with the specified ID held by this hand.
  671. *
  672. * Use the Hand::tool() function to retrieve a Tool object held by
  673. * this hand using an ID value obtained from a previous frame.
  674. * This function always returns a Tool object, but if no tool
  675. * with the specified ID is present, an invalid Tool object is returned.
  676. *
  677. * \include Hand_tool.txt
  678. *
  679. * Note that ID values persist across frames, but only until tracking of a
  680. * particular object is lost. If tracking of a tool is lost and subsequently
  681. * regained, the new Tool object representing that tool may have a
  682. * different ID than that representing the tool in an earlier frame.
  683. *
  684. * @param id The ID value of a Tool object from a previous frame.
  685. * @returns The Tool object with the matching ID if one exists for this
  686. * hand in this frame; otherwise, an invalid Tool object is returned.
  687. * @since 1.0
  688. */
  689. LEAP_EXPORT Tool tool(int32_t id) const;
  690. /**
  691. * The center position of the palm in millimeters from the Leap Motion Controller origin.
  692. *
  693. * \include Hand_palmPosition.txt
  694. *
  695. * @returns The Vector representing the coordinates of the palm position.
  696. * @since 1.0
  697. */
  698. LEAP_EXPORT Vector palmPosition() const;
  699. /**
  700. * The stabilized palm position of this Hand.
  701. *
  702. * Smoothing and stabilization is performed in order to make
  703. * this value more suitable for interaction with 2D content. The stabilized
  704. * position lags behind the palm position by a variable amount, depending
  705. * primarily on the speed of movement.
  706. *
  707. * \include Hand_stabilizedPalmPosition.txt
  708. *
  709. * @returns A modified palm position of this Hand object
  710. * with some additional smoothing and stabilization applied.
  711. * @since 1.0
  712. */
  713. LEAP_EXPORT Vector stabilizedPalmPosition() const;
  714. /**
  715. * The rate of change of the palm position in millimeters/second.
  716. *
  717. * \include Hand_palmVelocity.txt
  718. *
  719. * @returns The Vector representing the coordinates of the palm velocity.
  720. * @since 1.0
  721. */
  722. LEAP_EXPORT Vector palmVelocity() const;
  723. /**
  724. * The normal vector to the palm. If your hand is flat, this vector will
  725. * point downward, or "out" of the front surface of your palm.
  726. *
  727. * \image html images/Leap_Palm_Vectors.png
  728. *
  729. * The direction is expressed as a unit vector pointing in the same
  730. * direction as the palm normal (that is, a vector orthogonal to the palm).
  731. *
  732. * You can use the palm normal vector to compute the roll angle of the palm with
  733. * respect to the horizontal plane:
  734. *
  735. * \include Hand_Get_Angles.txt
  736. *
  737. * @returns The Vector normal to the plane formed by the palm.
  738. * @since 1.0
  739. */
  740. LEAP_EXPORT Vector palmNormal() const;
  741. /**
  742. * The direction from the palm position toward the fingers.
  743. *
  744. * The direction is expressed as a unit vector pointing in the same
  745. * direction as the directed line from the palm position to the fingers.
  746. *
  747. * You can use the palm direction vector to compute the pitch and yaw angles of the palm with
  748. * respect to the horizontal plane:
  749. *
  750. * \include Hand_Get_Angles.txt
  751. *
  752. * @returns The Vector pointing from the palm position toward the fingers.
  753. * @since 1.0
  754. */
  755. LEAP_EXPORT Vector direction() const;
  756. /**
  757. * The center of a sphere fit to the curvature of this hand.
  758. *
  759. * \include Hand_sphereCenter.txt
  760. *
  761. * This sphere is placed roughly as if the hand were holding a ball.
  762. *
  763. * \image html images/Leap_Hand_Ball.png
  764. *
  765. * @returns The Vector representing the center position of the sphere.
  766. * @since 1.0
  767. */
  768. LEAP_EXPORT Vector sphereCenter() const;
  769. /**
  770. * The radius of a sphere fit to the curvature of this hand.
  771. *
  772. * This sphere is placed roughly as if the hand were holding a ball. Thus the
  773. * size of the sphere decreases as the fingers are curled into a fist.
  774. *
  775. * \include Hand_sphereRadius.txt
  776. *
  777. * @returns The radius of the sphere in millimeters.
  778. * @since 1.0
  779. */
  780. LEAP_EXPORT float sphereRadius() const;
  781. /**
  782. * The change of position of this hand between the current frame and
  783. * the specified frame.
  784. *
  785. * The returned translation vector provides the magnitude and direction of
  786. * the movement in millimeters.
  787. *
  788. * \include Hand_translation.txt
  789. *
  790. * If a corresponding Hand object is not found in sinceFrame, or if either
  791. * this frame or sinceFrame are invalid Frame objects, then this method
  792. * returns a zero vector.
  793. *
  794. * @param sinceFrame The starting frame for computing the translation.
  795. * @returns A Vector representing the heuristically determined change in
  796. * hand position between the current frame and that specified in the
  797. * sinceFrame parameter.
  798. * @since 1.0
  799. */
  800. LEAP_EXPORT Vector translation(const Frame& sinceFrame) const;
  801. /**
  802. * The estimated probability that the hand motion between the current
  803. * frame and the specified frame is intended to be a translating motion.
  804. *
  805. * \include Hand_translationProbability.txt
  806. *
  807. * If a corresponding Hand object is not found in sinceFrame, or if either
  808. * this frame or sinceFrame are invalid Frame objects, then this method
  809. * returns zero.
  810. *
  811. * @param sinceFrame The starting frame for computing the translation.
  812. * @returns A value between 0 and 1 representing the estimated probability
  813. * that the hand motion between the current frame and the specified frame
  814. * is intended to be a translating motion.
  815. * @since 1.0
  816. */
  817. LEAP_EXPORT float translationProbability(const Frame& sinceFrame) const;
  818. /**
  819. * The axis of rotation derived from the change in orientation of this
  820. * hand, and any associated fingers and tools, between the current frame
  821. * and the specified frame.
  822. *
  823. * \include Hand_rotationAxis.txt
  824. *
  825. * The returned direction vector is normalized.
  826. *
  827. * If a corresponding Hand object is not found in sinceFrame, or if either
  828. * this frame or sinceFrame are invalid Frame objects, then this method
  829. * returns a zero vector.
  830. *
  831. * @param sinceFrame The starting frame for computing the relative rotation.
  832. * @returns A normalized direction Vector representing the heuristically
  833. * determined axis of rotational change of the hand between the current
  834. * frame and that specified in the sinceFrame parameter.
  835. * @since 1.0
  836. */
  837. LEAP_EXPORT Vector rotationAxis(const Frame& sinceFrame) const;
  838. /**
  839. * The angle of rotation around the rotation axis derived from the change
  840. * in orientation of this hand, and any associated fingers and tools,
  841. * between the current frame and the specified frame.
  842. *
  843. * \include Hand_rotationAngle.txt
  844. *
  845. * The returned angle is expressed in radians measured clockwise around the
  846. * rotation axis (using the right-hand rule) between the start and end frames.
  847. * The value is always between 0 and pi radians (0 and 180 degrees).
  848. *
  849. * If a corresponding Hand object is not found in sinceFrame, or if either
  850. * this frame or sinceFrame are invalid Frame objects, then the angle of
  851. * rotation is zero.
  852. *
  853. * @param sinceFrame The starting frame for computing the relative rotation.
  854. * @returns A positive value representing the heuristically determined
  855. * rotational change of the hand between the current frame and that
  856. * specified in the sinceFrame parameter.
  857. * @since 1.0
  858. */
  859. LEAP_EXPORT float rotationAngle(const Frame& sinceFrame) const;
  860. /**
  861. * The angle of rotation around the specified axis derived from the change
  862. * in orientation of this hand, and any associated fingers and tools,
  863. * between the current frame and the specified frame.
  864. *
  865. * \include Hand_rotationAngle_axis.txt
  866. *
  867. * The returned angle is expressed in radians measured clockwise around the
  868. * rotation axis (using the right-hand rule) between the start and end frames.
  869. * The value is always between -pi and pi radians (-180 and 180 degrees).
  870. *
  871. * If a corresponding Hand object is not found in sinceFrame, or if either
  872. * this frame or sinceFrame are invalid Frame objects, then the angle of
  873. * rotation is zero.
  874. *
  875. * @param sinceFrame The starting frame for computing the relative rotation.
  876. * @param axis The axis to measure rotation around.
  877. * @returns A value representing the heuristically determined rotational
  878. * change of the hand between the current frame and that specified in the
  879. * sinceFrame parameter around the specified axis.
  880. * @since 1.0
  881. */
  882. LEAP_EXPORT float rotationAngle(const Frame& sinceFrame, const Vector& axis) const;
  883. /**
  884. * The transform matrix expressing the rotation derived from the change
  885. * in orientation of this hand, and any associated fingers and tools,
  886. * between the current frame and the specified frame.
  887. *
  888. * \include Hand_rotationMatrix.txt
  889. *
  890. * If a corresponding Hand object is not found in sinceFrame, or if either
  891. * this frame or sinceFrame are invalid Frame objects, then this method
  892. * returns an identity matrix.
  893. *
  894. * @param sinceFrame The starting frame for computing the relative rotation.
  895. * @returns A transformation Matrix representing the heuristically determined
  896. * rotational change of the hand between the current frame and that specified
  897. * in the sinceFrame parameter.
  898. * @since 1.0
  899. */
  900. LEAP_EXPORT Matrix rotationMatrix(const Frame& sinceFrame) const;
  901. /**
  902. * The estimated probability that the hand motion between the current
  903. * frame and the specified frame is intended to be a rotating motion.
  904. *
  905. * \include Hand_rotationProbability.txt
  906. *
  907. * If a corresponding Hand object is not found in sinceFrame, or if either
  908. * this frame or sinceFrame are invalid Frame objects, then this method
  909. * returns zero.
  910. *
  911. * @param sinceFrame The starting frame for computing the relative rotation.
  912. * @returns A value between 0 and 1 representing the estimated probability
  913. * that the hand motion between the current frame and the specified frame
  914. * is intended to be a rotating motion.
  915. * @since 1.0
  916. */
  917. LEAP_EXPORT float rotationProbability(const Frame& sinceFrame) const;
  918. /**
  919. * The scale factor derived from this hand's motion between the current frame
  920. * and the specified frame.
  921. *
  922. * The scale factor is always positive. A value of 1.0 indicates no
  923. * scaling took place. Values between 0.0 and 1.0 indicate contraction
  924. * and values greater than 1.0 indicate expansion.
  925. *
  926. * \include Hand_scaleFactor.txt
  927. *
  928. * The Leap Motion software derives scaling from the relative inward or outward motion of
  929. * a hand and its associated fingers and tools (independent of translation
  930. * and rotation).
  931. *
  932. * If a corresponding Hand object is not found in sinceFrame, or if either
  933. * this frame or sinceFrame are invalid Frame objects, then this method
  934. * returns 1.0.
  935. *
  936. * @param sinceFrame The starting frame for computing the relative scaling.
  937. * @returns A positive value representing the heuristically determined
  938. * scaling change ratio of the hand between the current frame and that
  939. * specified in the sinceFrame parameter.
  940. * @since 1.0
  941. */
  942. LEAP_EXPORT float scaleFactor(const Frame& sinceFrame) const;
  943. /**
  944. * The estimated probability that the hand motion between the current
  945. * frame and the specified frame is intended to be a scaling motion.
  946. *
  947. * \include Hand_scaleProbability.txt
  948. *
  949. * If a corresponding Hand object is not found in sinceFrame, or if either
  950. * this frame or sinceFrame are invalid Frame objects, then this method
  951. * returns zero.
  952. *
  953. * @param sinceFrame The starting frame for computing the relative scaling.
  954. * @returns A value between 0 and 1 representing the estimated probability
  955. * that the hand motion between the current frame and the specified frame
  956. * is intended to be a scaling motion.
  957. * @since 1.0
  958. */
  959. LEAP_EXPORT float scaleProbability(const Frame& sinceFrame) const;
  960. /**
  961. * The duration of time this Hand has been visible to the Leap Motion Controller.
  962. *
  963. * \include Hand_timeVisible.txt
  964. *
  965. * @returns The duration (in seconds) that this Hand has been tracked.
  966. * @since 1.0
  967. */
  968. LEAP_EXPORT float timeVisible() const;
  969. /**
  970. * Reports whether this is a valid Hand object.
  971. *
  972. * \include Hand_isValid.txt
  973. *
  974. * @returns True, if this Hand object contains valid tracking data.
  975. * @since 1.0
  976. */
  977. LEAP_EXPORT bool isValid() const;
  978. /**
  979. * Returns an invalid Hand object.
  980. *
  981. * \include Hand_invalid.txt
  982. *
  983. * You can use the instance returned by this function in comparisons testing
  984. * whether a given Hand instance is valid or invalid. (You can also use the
  985. * Hand::isValid() function.)
  986. *
  987. * @returns The invalid Hand instance.
  988. * @since 1.0
  989. */
  990. LEAP_EXPORT static const Hand& invalid();
  991. /**
  992. * Compare Hand object equality.
  993. *
  994. * \include Hand_operator_equals.txt
  995. *
  996. * Two Hand objects are equal if and only if both Hand objects represent the
  997. * exact same physical hand in the same frame and both Hand objects are valid.
  998. * @since 1.0
  999. */
  1000. LEAP_EXPORT bool operator==(const Hand&) const;
  1001. /**
  1002. * Compare Hand object inequality.
  1003. *
  1004. * \include Hand_operator_not_equals.txt
  1005. *
  1006. * Two Hand objects are equal if and only if both Hand objects represent the
  1007. * exact same physical hand in the same frame and both Hand objects are valid.
  1008. * @since 1.0
  1009. */
  1010. LEAP_EXPORT bool operator!=(const Hand&) const;
  1011. /**
  1012. * Writes a brief, human readable description of the Hand object to an output stream.
  1013. *
  1014. * \include Hand_operator_stream.txt
  1015. *
  1016. * @since 1.0
  1017. */
  1018. LEAP_EXPORT friend std::ostream& operator<<(std::ostream&, const Hand&);
  1019. /**
  1020. * A string containing a brief, human readable description of the Hand object.
  1021. *
  1022. * @returns A description of the Hand as a string.
  1023. * @since 1.0
  1024. */
  1025. LEAP_EXPORT std::string toString() const;
  1026. };
  1027. /**
  1028. * The Gesture class represents a recognized movement by the user.
  1029. *
  1030. * The Leap Motion Controller watches the activity within its field of view for certain movement
  1031. * patterns typical of a user gesture or command. For example, a movement from side to
  1032. * side with the hand can indicate a swipe gesture, while a finger poking forward
  1033. * can indicate a screen tap gesture.
  1034. *
  1035. * When the Leap Motion software recognizes a gesture, it assigns an ID and adds a
  1036. * Gesture object to the frame gesture list. For continuous gestures, which
  1037. * occur over many frames, the Leap Motion software updates the gesture by adding
  1038. * a Gesture object having the same ID and updated properties in each
  1039. * subsequent frame.
  1040. *
  1041. * **Important:** Recognition for each type of gesture must be enabled using the
  1042. * Controller::enableGesture() function; otherwise **no gestures are recognized or
  1043. * reported**.
  1044. *
  1045. * \include Gesture_Feature_enable.txt
  1046. *
  1047. * Subclasses of Gesture define the properties for the specific movement patterns
  1048. * recognized by the Leap Motion software.
  1049. *
  1050. * The Gesture subclasses for include:
  1051. *
  1052. * * CircleGesture -- A circular movement by a finger.
  1053. * * SwipeGesture -- A straight line movement by the hand with fingers extended.
  1054. * * ScreenTapGesture -- A forward tapping movement by a finger.
  1055. * * KeyTapGesture -- A downward tapping movement by a finger.
  1056. *
  1057. * Circle and swipe gestures are continuous and these objects can have a
  1058. * state of start, update, and stop.
  1059. *
  1060. * The screen tap gesture is a discrete gesture. The Leap Motion software only creates a single
  1061. * ScreenTapGesture object for each tap and it always has a stop state.
  1062. *
  1063. * Get valid Gesture instances from a Frame object. You can get a list of gestures
  1064. * with the Frame::gestures() method. You can get a list of gestures since a
  1065. * specified frame with the `Frame::gestures(const Frame&)` method. You can also
  1066. * use the `Frame::gesture()` method to find a gesture in the current frame using
  1067. * an ID value obtained in a previous frame.
  1068. *
  1069. * Gesture objects can be invalid. For example, when you get a gesture by ID
  1070. * using `Frame::gesture()`, and there is no gesture with that ID in the current
  1071. * frame, then `gesture()` returns an Invalid Gesture object (rather than a null
  1072. * value). Always check object validity in situations where a gesture might be
  1073. * invalid.
  1074. *
  1075. * The following keys can be used with the Config class to configure the gesture
  1076. * recognizer:
  1077. *
  1078. * Key string | Value type | Default value | Units
  1079. * -----------|------------|---------------|------
  1080. * Gesture.Circle.MinRadius | float | 5.0 | mm
  1081. * Gesture.Circle.MinArc | float | 1.5*pi | radians
  1082. * Gesture.Swipe.MinLength | float | 150 | mm
  1083. * Gesture.Swipe.MinVelocity | float | 1000 | mm/s
  1084. * Gesture.KeyTap.MinDownVelocity | float | 50 | mm/s
  1085. * Gesture.KeyTap.HistorySeconds | float | 0.1 | s
  1086. * Gesture.KeyTap.MinDistance | float | 5.0 | mm
  1087. * Gesture.ScreenTap.MinForwardVelocity | float | 50 | mm/s
  1088. * Gesture.ScreenTap.HistorySeconds | float | 0.1 | s
  1089. * Gesture.ScreenTap.MinDistance | float | 3.0 | mm
  1090. * @since 1.0
  1091. */
  1092. class Gesture : public Interface {
  1093. public:
  1094. // For internal use only.
  1095. Gesture(GestureImplementation*);
  1096. /**
  1097. * The supported types of gestures.
  1098. * @since 1.0
  1099. */
  1100. enum Type {
  1101. /**
  1102. * An invalid type.
  1103. * @since 1.0
  1104. */
  1105. TYPE_INVALID = -1,
  1106. /**
  1107. * A straight line movement by the hand with fingers extended.
  1108. * @since 1.0
  1109. */
  1110. TYPE_SWIPE = 1,
  1111. /**
  1112. * A circular movement by a finger.
  1113. * @since 1.0
  1114. */
  1115. TYPE_CIRCLE = 4,
  1116. /**
  1117. * A forward tapping movement by a finger.
  1118. * @since 1.0
  1119. */
  1120. TYPE_SCREEN_TAP = 5,
  1121. /**
  1122. * A downward tapping movement by a finger.
  1123. * @since 1.0
  1124. */
  1125. TYPE_KEY_TAP = 6
  1126. };
  1127. /**
  1128. * The possible gesture states.
  1129. * @since 1.0
  1130. */
  1131. enum State {
  1132. /**
  1133. * An invalid state
  1134. * @since 1.0
  1135. */
  1136. STATE_INVALID = -1,
  1137. /**
  1138. * The gesture is starting. Just enough has happened to recognize it.
  1139. * @since 1.0
  1140. */
  1141. STATE_START = 1,
  1142. /**
  1143. * The gesture is in progress. (Note: not all gestures have updates).
  1144. * @since 1.0
  1145. */
  1146. STATE_UPDATE = 2,
  1147. /**
  1148. * The gesture has completed or stopped.
  1149. * @since 1.0
  1150. */
  1151. STATE_STOP = 3,
  1152. };
  1153. /**
  1154. * Constructs a new Gesture object.
  1155. *
  1156. * An uninitialized Gesture object is considered invalid. Get valid instances
  1157. * of the Gesture class, which will be one of the Gesture subclasses, from a
  1158. * Frame object.
  1159. * @since 1.0
  1160. */
  1161. LEAP_EXPORT Gesture();
  1162. /**
  1163. * Constructs a new copy of an Gesture object.
  1164. *
  1165. * \include Gesture_Gesture_copy.txt
  1166. *
  1167. * @since 1.0
  1168. */
  1169. LEAP_EXPORT Gesture(const Gesture& rhs);
  1170. /**
  1171. * The gesture type.
  1172. *
  1173. * \include Gesture_type.txt
  1174. *
  1175. * @returns Gesture::Type A value from the Gesture::Type enumeration.
  1176. * @since 1.0
  1177. */
  1178. LEAP_EXPORT Type type() const;
  1179. /**
  1180. * The gesture state.
  1181. *
  1182. * Recognized movements occur over time and have a beginning, a middle,
  1183. * and an end. The 'state()' attribute reports where in that sequence this
  1184. * Gesture object falls.
  1185. *
  1186. * \include Gesture_state.txt
  1187. *
  1188. * @returns Gesture::State A value from the Gesture::State enumeration.
  1189. * @since 1.0
  1190. */
  1191. LEAP_EXPORT State state() const;
  1192. /**
  1193. * The gesture ID.
  1194. *
  1195. * All Gesture objects belonging to the same recognized movement share the
  1196. * same ID value. Use the ID value with the Frame::gesture() method to
  1197. * find updates related to this Gesture object in subsequent frames.
  1198. *
  1199. * \include Gesture_id.txt
  1200. *
  1201. * @returns int32_t the ID of this Gesture.
  1202. * @since 1.0
  1203. */
  1204. LEAP_EXPORT int32_t id() const;
  1205. /**
  1206. * The elapsed duration of the recognized movement up to the
  1207. * frame containing this Gesture object, in microseconds.
  1208. *
  1209. * \include Gesture_duration.txt
  1210. *
  1211. * The duration reported for the first Gesture in the sequence (with the
  1212. * STATE_START state) will typically be a small positive number since
  1213. * the movement must progress far enough for the Leap Motion software to recognize it as
  1214. * an intentional gesture.
  1215. *
  1216. * @return int64_t the elapsed duration in microseconds.
  1217. * @since 1.0
  1218. */
  1219. LEAP_EXPORT int64_t duration() const;
  1220. /**
  1221. * The elapsed duration in seconds.
  1222. *
  1223. * \include Gesture_durationSeconds.txt
  1224. *
  1225. * @see duration()
  1226. * @return float the elapsed duration in seconds.
  1227. * @since 1.0
  1228. */
  1229. LEAP_EXPORT float durationSeconds() const;
  1230. /**
  1231. * The Frame containing this Gesture instance.
  1232. *
  1233. * \include Gesture_frame.txt
  1234. _
  1235. * @return Frame The parent Frame object.
  1236. * @since 1.0
  1237. */
  1238. LEAP_EXPORT Frame frame() const;
  1239. /**
  1240. * The list of hands associated with this Gesture, if any.
  1241. *
  1242. * \include Gesture_hands.txt
  1243. *
  1244. * If no hands are related to this gesture, the list is empty.
  1245. *
  1246. * @return HandList the list of related Hand objects.
  1247. * @since 1.0
  1248. */
  1249. LEAP_EXPORT HandList hands() const;
  1250. /**
  1251. * The list of fingers and tools associated with this Gesture, if any.
  1252. *
  1253. * If no Pointable objects are related to this gesture, the list is empty.
  1254. *
  1255. * \include Gesture_pointables.txt
  1256. *
  1257. * @return PointableList the list of related Pointable objects.
  1258. * @since 1.0
  1259. */
  1260. LEAP_EXPORT PointableList pointables() const;
  1261. /**
  1262. * Reports whether this Gesture instance represents a valid Gesture.
  1263. *
  1264. * An invalid Gesture object does not represent a snapshot of a recognized
  1265. * movement. Invalid Gesture objects are returned when a valid object cannot
  1266. * be provided. For example, when you get an gesture by ID
  1267. * using Frame::gesture(), and there is no gesture with that ID in the current
  1268. * frame, then gesture() returns an Invalid Gesture object (rather than a null
  1269. * value). Always check object validity in situations where an gesture might be
  1270. * invalid.
  1271. *
  1272. * \include Gesture_isValid.txt
  1273. *
  1274. * @returns bool True, if this is a valid Gesture instance; false, otherwise.
  1275. * @since 1.0
  1276. */
  1277. LEAP_EXPORT bool isValid() const;
  1278. /**
  1279. * Compare Gesture object equality.
  1280. *
  1281. * \include Gesture_operator_equals.txt
  1282. *
  1283. * Two Gestures are equal if they represent the same snapshot of the same
  1284. * recognized movement.
  1285. * @since 1.0
  1286. */
  1287. LEAP_EXPORT bool operator==(const Gesture& rhs) const;
  1288. /**
  1289. * Compare Gesture object inequality.
  1290. *
  1291. * \include Gesture_operator_not_equals.txt
  1292. *
  1293. * Two Gestures are equal only if they represent the same snapshot of the same
  1294. * recognized movement.
  1295. * @since 1.0
  1296. */
  1297. LEAP_EXPORT bool operator!=(const Gesture& rhs) const;
  1298. /**
  1299. * A string containing a brief, human-readable description of this
  1300. * Gesture.
  1301. *
  1302. * \include Gesture_toString.txt
  1303. *
  1304. * @since 1.0
  1305. */
  1306. LEAP_EXPORT std::string toString() const;
  1307. /**
  1308. * Returns an invalid Gesture object.
  1309. *
  1310. * You can use the instance returned by this function in comparisons testing
  1311. * whether a given Gesture instance is valid or invalid. (You can also use the
  1312. * Gesture::isValid() function.)
  1313. *
  1314. * \include Gesture_invalid.txt
  1315. *
  1316. * @returns The invalid Gesture instance.
  1317. * @since 1.0
  1318. */
  1319. LEAP_EXPORT static const Gesture& invalid();
  1320. };
  1321. /**
  1322. * The SwipeGesture class represents a swiping motion of a finger or tool.
  1323. *
  1324. * \image html images/Leap_Gesture_Swipe.png
  1325. *
  1326. * **Important:** To use swipe gestures in your application, you must enable
  1327. * recognition of the swipe gesture. You can enable recognition with:
  1328. *
  1329. * \include Gesture_Swipe_Enable.txt
  1330. *
  1331. * Swipe gestures are continuous.
  1332. *
  1333. * You can set the minimum length and velocity required for a movement
  1334. * to be recognized as a swipe using the config attribute of a connected
  1335. * Controller object. Use the following keys to configure swipe recognition:
  1336. *
  1337. * Key string | Value type | Default value | Units
  1338. * -----------|------------|---------------|------
  1339. * Gesture.Swipe.MinLength | float | 150 | mm
  1340. * Gesture.Swipe.MinVelocity | float | 1000 | mm/s
  1341. *
  1342. * The following example demonstrates how to set the swipe configuration
  1343. * parameters:
  1344. *
  1345. * \include Gesture_Swipe_Params.txt
  1346. * @since 1.0
  1347. */
  1348. class SwipeGesture : public Gesture
  1349. {
  1350. public:
  1351. /**
  1352. * The swipe gesture type.
  1353. *
  1354. * \include SwipeGesture_classType.txt
  1355. *
  1356. * @returns Type The type value designating a swipe gesture.
  1357. * @since 1.0
  1358. */
  1359. static Type classType() { return TYPE_SWIPE; }
  1360. LEAP_EXPORT SwipeGesture();
  1361. /**
  1362. * Constructs a SwipeGesture object from an instance of the Gesture class.
  1363. *
  1364. * \include SwipeGesture_SwipeGesture.txt
  1365. *
  1366. * @param rhs The Gesture instance to specialize. This Gesture instance must
  1367. * be a SwipeGesture object.
  1368. * @since 1.0
  1369. */
  1370. LEAP_EXPORT SwipeGesture(const Gesture& rhs);
  1371. /**
  1372. * The position where the swipe began.
  1373. *
  1374. * \include SwipeGesture_startPosition.txt
  1375. *
  1376. * @returns Vector The starting position within the Leap Motion frame of
  1377. * reference, in mm.
  1378. * @since 1.0
  1379. */
  1380. LEAP_EXPORT Vector startPosition() const;
  1381. /**
  1382. * The current position of the swipe.
  1383. *
  1384. * \include SwipeGesture_position.txt
  1385. *
  1386. * @returns Vector The current swipe position within the Leap Motion frame of
  1387. * reference, in mm.
  1388. * @since 1.0
  1389. */
  1390. LEAP_EXPORT Vector position() const;
  1391. /**
  1392. * The unit direction vector parallel to the swipe motion.
  1393. *
  1394. * \include SwipeGesture_direction.txt
  1395. *
  1396. * You can compare the components of the vector to classify the swipe as
  1397. * appropriate for your application. For example, if you are using swipes
  1398. * for two dimensional scrolling, you can compare the x and y values to
  1399. * determine if the swipe is primarily horizontal or vertical.
  1400. *
  1401. * @returns Vector The unit direction vector representing the swipe
  1402. * motion.
  1403. * @since 1.0
  1404. */
  1405. LEAP_EXPORT Vector direction() const;
  1406. /**
  1407. * The swipe speed in mm/second.
  1408. *
  1409. * \include SwipeGesture_speed.txt
  1410. *
  1411. * @returns float The speed of the finger performing the swipe gesture in
  1412. * millimeters per second.
  1413. * @since 1.0
  1414. */
  1415. LEAP_EXPORT float speed() const;
  1416. /**
  1417. * The finger performing the swipe gesture.
  1418. *
  1419. * \include SwipeGesture_pointable.txt
  1420. *
  1421. * @returns Pointable A Pointable object representing the swiping finger.
  1422. * @since 1.0
  1423. */
  1424. LEAP_EXPORT Pointable pointable() const;
  1425. };
  1426. /**
  1427. * The CircleGesture classes represents a circular finger movement.
  1428. *
  1429. * A circle movement is recognized when the tip of a finger draws a circle
  1430. * within the Leap Motion Controller field of view.
  1431. *
  1432. * \image html images/Leap_Gesture_Circle.png
  1433. *
  1434. * **Important:** To use circle gestures in your application, you must enable
  1435. * recognition of the circle gesture. You can enable recognition with:
  1436. *
  1437. * \include Gesture_Circle_Enable.txt
  1438. *
  1439. * Circle gestures are continuous. The CircleGesture objects for the gesture have
  1440. * three possible states:
  1441. *
  1442. * * State::STATE_START -- The circle gesture has just started. The movement has
  1443. * progressed far enough for the recognizer to classify it as a circle.
  1444. * * State::STATE_UPDATE -- The circle gesture is continuing.
  1445. * * State::STATE_STOP -- The circle gesture is finished.
  1446. *
  1447. * You can set the minimum radius and minimum arc length required for a movement
  1448. * to be recognized as a circle using the config attribute of a connected
  1449. * Controller object. Use the following keys to configure circle recognition:
  1450. *
  1451. * Key string | Value type | Default value | Units
  1452. * -----------|------------|---------------|------
  1453. * Gesture.Circle.MinRadius | float | 5.0 | mm
  1454. * Gesture.Circle.MinArc | float | 1.5*pi | radians
  1455. *
  1456. * The following example demonstrates how to set the circle configuration
  1457. * parameters:
  1458. *
  1459. * \include Gesture_Circle_Params.txt
  1460. *
  1461. * @since 1.0
  1462. */
  1463. class CircleGesture : public Gesture
  1464. {
  1465. public:
  1466. /**
  1467. * The circle gesture type.
  1468. *
  1469. * \include CircleGesture_classType.txt
  1470. *
  1471. * @returns Type The type value designating a circle gesture.
  1472. * @since 1.0
  1473. */
  1474. static Type classType() { return TYPE_CIRCLE; }
  1475. /**
  1476. * Constructs a new CircleGesture object.
  1477. *
  1478. * An uninitialized CircleGesture object is considered invalid. Get valid instances
  1479. * of the CircleGesture class from a Frame object.
  1480. * @since 1.0
  1481. */
  1482. LEAP_EXPORT CircleGesture();
  1483. /**
  1484. * Constructs a CircleGesture object from an instance of the Gesture class.
  1485. *
  1486. * \include CircleGesture_CircleGesture.txt
  1487. *
  1488. * @param rhs The Gesture instance to specialize. This Gesture instance must
  1489. * be a CircleGesture object.
  1490. * @since 1.0
  1491. */
  1492. LEAP_EXPORT CircleGesture(const Gesture& rhs);
  1493. /**
  1494. * The center point of the circle within the Leap Motion frame of reference.
  1495. *
  1496. * \include CircleGesture_center.txt
  1497. * @returns Vector The center of the circle in mm from the Leap Motion origin.
  1498. * @since 1.0
  1499. */
  1500. LEAP_EXPORT Vector center() const;
  1501. /**
  1502. * Returns the normal vector for the circle being traced.
  1503. *
  1504. * If you draw the circle clockwise, the normal vector points in the same
  1505. * general direction as the pointable object drawing the circle. If you draw
  1506. * the circle counterclockwise, the normal points back toward the
  1507. * pointable. If the angle between the normal and the pointable object
  1508. * drawing the circle is less than 90 degrees, then the circle is clockwise.
  1509. *
  1510. * \include Gesture_Circle_Direction.txt
  1511. *
  1512. * @return Vector the normal vector for the circle being traced
  1513. * @since 1.0
  1514. */
  1515. LEAP_EXPORT Vector normal() const;
  1516. /**
  1517. * The number of times the finger tip has traversed the circle.
  1518. *
  1519. * Progress is reported as a positive number of the number. For example,
  1520. * a progress value of .5 indicates that the finger has gone halfway
  1521. * around, while a value of 3 indicates that the finger has gone around
  1522. * the the circle three times.
  1523. *
  1524. * \include CircleGesture_progress.txt
  1525. *
  1526. * Progress starts where the circle gesture began. Since the circle
  1527. * must be partially formed before the Leap Motion software can recognize it, progress
  1528. * will be greater than zero when a circle gesture first appears in the
  1529. * frame.
  1530. *
  1531. * @returns float A positive number indicating the gesture progress.
  1532. * @since 1.0
  1533. */
  1534. LEAP_EXPORT float progress() const;
  1535. /**
  1536. * The radius of the circle.
  1537. *
  1538. * \include CircleGesture_radius.txt
  1539. *
  1540. * @returns The circle radius in mm.
  1541. * @since 1.0
  1542. */
  1543. LEAP_EXPORT float radius() const;
  1544. /**
  1545. * The finger performing the circle gesture.
  1546. *
  1547. * \include CircleGesture_pointable.txt
  1548. *
  1549. * @returns Pointable A Pointable object representing the circling finger.
  1550. * @since 1.0
  1551. */
  1552. LEAP_EXPORT Pointable pointable() const;
  1553. };
  1554. /**
  1555. * The ScreenTapGesture class represents a tapping gesture by a finger or tool.
  1556. *
  1557. * A screen tap gesture is recognized when the tip of a finger pokes forward
  1558. * and then springs back to approximately the original postion, as if
  1559. * tapping a vertical screen. The tapping finger must pause briefly before beginning the tap.
  1560. *
  1561. * \image html images/Leap_Gesture_Tap2.png
  1562. *
  1563. * **Important:** To use screen tap gestures in your application, you must enable
  1564. * recognition of the screen tap gesture. You can enable recognition with:
  1565. *
  1566. * \include Gesture_ScreenTap_Enable.txt
  1567. *
  1568. * ScreenTap gestures are discrete. The ScreenTapGesture object representing a tap always
  1569. * has the state, STATE_STOP. Only one ScreenTapGesture object is created for each
  1570. * screen tap gesture recognized.
  1571. *
  1572. * You can set the minimum finger movement and velocity required for a movement
  1573. * to be recognized as a screen tap as well as adjust the detection window for
  1574. * evaluating the movement using the config attribute of a connected
  1575. * Controller object. Use the following keys to configure screen tap recognition:
  1576. *
  1577. * Key string | Value type | Default value | Units
  1578. * -----------|------------|---------------|------
  1579. * Gesture.ScreenTap.MinForwardVelocity | float | 50 | mm/s
  1580. * Gesture.ScreenTap.HistorySeconds | float | 0.1 | s
  1581. * Gesture.ScreenTap.MinDistance | float | 3.0 | mm
  1582. *
  1583. * The following example demonstrates how to set the screen tap configuration
  1584. * parameters:
  1585. *
  1586. * \include Gesture_ScreenTap_Params.txt
  1587. * @since 1.0
  1588. */
  1589. class ScreenTapGesture : public Gesture
  1590. {
  1591. public:
  1592. /**
  1593. * The screen tap gesture type.
  1594. *
  1595. * \include ScreenTapGesture_classType.txt
  1596. *
  1597. * @returns Type The type value designating a screen tap gesture.
  1598. * @since 1.0
  1599. */
  1600. static Type classType() { return TYPE_SCREEN_TAP; }
  1601. /**
  1602. * Constructs a new ScreenTapGesture object.
  1603. *
  1604. * An uninitialized ScreenTapGesture object is considered invalid. Get valid instances
  1605. * of the ScreenTapGesture class from a Frame object.
  1606. * @since 1.0
  1607. */
  1608. LEAP_EXPORT ScreenTapGesture();
  1609. /**
  1610. * Constructs a ScreenTapGesture object from an instance of the Gesture class.
  1611. *
  1612. * \include ScreenTapGesture_ScreenTapGesture.txt
  1613. *
  1614. * @param rhs The Gesture instance to specialize. This Gesture instance must
  1615. * be a ScreenTapGesture object.
  1616. * @since 1.0
  1617. */
  1618. LEAP_EXPORT ScreenTapGesture(const Gesture& rhs);
  1619. /**
  1620. * The position where the screen tap is registered.
  1621. *
  1622. * \include ScreenTapGesture_position.txt
  1623. *
  1624. * @return Vector A Vector containing the coordinates of screen tap location.
  1625. * @since 1.0
  1626. */
  1627. LEAP_EXPORT Vector position() const;
  1628. /**
  1629. * The direction of finger tip motion.
  1630. *
  1631. * \include ScreenTapGesture_direction.txt
  1632. *
  1633. * @returns Vector A unit direction vector.
  1634. * @since 1.0
  1635. */
  1636. LEAP_EXPORT Vector direction() const;
  1637. /**
  1638. * The progess value is always 1.0 for a screen tap gesture.
  1639. *
  1640. * @returns float The value 1.0.
  1641. * @since 1.0
  1642. */
  1643. LEAP_EXPORT float progress() const;
  1644. /**
  1645. * The finger performing the screen tap gesture.
  1646. *
  1647. * \include ScreenTapGesture_pointable.txt
  1648. *
  1649. * @returns Pointable A Pointable object representing the tapping finger.
  1650. * @since 1.0
  1651. */
  1652. LEAP_EXPORT Pointable pointable() const;
  1653. };
  1654. /**
  1655. * The KeyTapGesture class represents a tapping gesture by a finger or tool.
  1656. *
  1657. * A key tap gesture is recognized when the tip of a finger rotates down toward the
  1658. * palm and then springs back to approximately the original postion, as if
  1659. * tapping. The tapping finger must pause briefly before beginning the tap.
  1660. *
  1661. * \image html images/Leap_Gesture_Tap.png
  1662. *
  1663. * **Important:** To use key tap gestures in your application, you must enable
  1664. * recognition of the key tap gesture. You can enable recognition with:
  1665. *
  1666. * \include Gesture_KeyTap_Enable.txt
  1667. *
  1668. * Key tap gestures are discrete. The KeyTapGesture object representing a tap always
  1669. * has the state, STATE_STOP. Only one KeyTapGesture object is created for each
  1670. * key tap gesture recognized.
  1671. *
  1672. * You can set the minimum finger movement and velocity required for a movement
  1673. * to be recognized as a key tap as well as adjust the detection window for
  1674. * evaluating the movement using the config attribute of a connected
  1675. * Controller object. Use the following configuration keys to configure key tap
  1676. * recognition:
  1677. *
  1678. * Key string | Value type | Default value | Units
  1679. * -----------|------------|---------------|------
  1680. * Gesture.KeyTap.MinDownVelocity | float | 50 | mm/s
  1681. * Gesture.KeyTap.HistorySeconds | float | 0.1 | s
  1682. * Gesture.KeyTap.MinDistance | float | 5.0 | mm
  1683. *
  1684. * The following example demonstrates how to set the key tap configuration
  1685. * parameters:
  1686. *
  1687. * \include Gesture_KeyTap_Params.txt
  1688. *
  1689. * @since 1.0
  1690. */
  1691. class KeyTapGesture : public Gesture
  1692. {
  1693. public:
  1694. /**
  1695. * The key tap gesture type.
  1696. *
  1697. * \include KeyTapGesture_classType.txt
  1698. *
  1699. * @returns Type The type value designating a key tap gesture.
  1700. * @since 1.0
  1701. */
  1702. static Type classType() { return TYPE_KEY_TAP; }
  1703. /**
  1704. * Constructs a new KeyTapGesture object.
  1705. *
  1706. * An uninitialized KeyTapGesture object is considered invalid. Get valid instances
  1707. * of the KeyTapGesture class from a Frame object.
  1708. * @since 1.0
  1709. */
  1710. LEAP_EXPORT KeyTapGesture();
  1711. /**
  1712. * Constructs a KeyTapGesture object from an instance of the Gesture class.
  1713. *
  1714. * \include KeyTapGesture_KeyTapGesture.txt
  1715. *
  1716. * @param rhs The Gesture instance to specialize. This Gesture instance must
  1717. * be a KeyTapGesture object.
  1718. * @since 1.0
  1719. */
  1720. LEAP_EXPORT KeyTapGesture(const Gesture& rhs);
  1721. /**
  1722. * The position where the key tap is registered.
  1723. *
  1724. * \include KeyTapGesture_position.txt
  1725. *
  1726. * @return Vector A Vector containing the coordinates of tap location.
  1727. * @since 1.0
  1728. */
  1729. LEAP_EXPORT Vector position() const;
  1730. /**
  1731. * The direction of finger tip motion.
  1732. *
  1733. * \include KeyTapGesture_direction.txt
  1734. *
  1735. * @returns Vector A unit direction vector if the finger tip is moving;
  1736. * otherwise, a zero-vector.
  1737. * @since 1.0
  1738. */
  1739. LEAP_EXPORT Vector direction() const;
  1740. /**
  1741. * The progess value is always 1.0 for a key tap gesture.
  1742. *
  1743. * @returns float The value 1.0.
  1744. * @since 1.0
  1745. */
  1746. LEAP_EXPORT float progress() const;
  1747. /**
  1748. * The finger performing the key tap gesture.
  1749. *
  1750. * \include KeyTapGesture_pointable.txt
  1751. *
  1752. * @returns Pointable A Pointable object representing the tapping finger.
  1753. * @since 1.0
  1754. */
  1755. LEAP_EXPORT Pointable pointable() const;
  1756. };
  1757. /*
  1758. * The Screen class is currently unsupported.
  1759. *
  1760. * We are re-evaluating this feature due to the cumbersome location process
  1761. * required to use it and the amount of confusion about the feature's purpose.
  1762. *
  1763. * The Screen class represents a computer monitor screen.
  1764. *
  1765. * The Screen class reports characteristics describing the position and
  1766. * orientation of the monitor screen within the Leap Motion coordinate system. These
  1767. * characteristics include the bottom-left corner position of the screen,
  1768. * direction vectors for the horizontal and vertical axes of the screen, and
  1769. * the screen's normal vector. The screen must be properly registered with the
  1770. * Screen Locator for the Leap Motion software to report these characteristics accurately.
  1771. * The Screen class also reports the size of the screen in pixels, using
  1772. * information obtained from the operating system. (Run the Screen Locator
  1773. * from the Leap Motion Settings dialog, on the Screen page.)
  1774. *
  1775. * You can get the point of intersection between the screen and a ray
  1776. * projected from a Pointable object using the Screen::intersect() function.
  1777. * Likewise, you can get the closest point on the screen to a point in space
  1778. * using the Screen::project() function. Again, the screen location
  1779. * must be registered with the Screen Locator for these functions to
  1780. * return accurate values.
  1781. *
  1782. * Note that Screen objects can be invalid, which means that they do not contain
  1783. * valid screen coordinate data and do not correspond to a physical entity.
  1784. * Test for validity with the Screen::isValid() function.
  1785. * @since 1.0
  1786. */
  1787. class Screen : public Interface {
  1788. public:
  1789. // For internal use only.
  1790. Screen(ScreenImplementation*);
  1791. /**
  1792. * Constructs a Screen object.
  1793. *
  1794. * An uninitialized screen is considered invalid.
  1795. * Get valid Screen objects from a ScreenList object obtained using the
  1796. * Controller::locatedScreens() method.
  1797. * @since 1.0
  1798. */
  1799. LEAP_EXPORT Screen();
  1800. /**
  1801. * A unique identifier for this screen based on the screen
  1802. * information in the configuration. A default screen with ID, *0*,
  1803. * always exists and contains default characteristics, even if no screens
  1804. * have been located.
  1805. * @since 1.0
  1806. */
  1807. LEAP_EXPORT int32_t id() const;
  1808. /**
  1809. * Returns the intersection between this screen and a ray projecting from a
  1810. * Pointable object.
  1811. *
  1812. * The projected ray emanates from the Pointable tipPosition along the
  1813. * Pointable's direction vector.
  1814. *
  1815. * Set the normalize parameter to true to request the intersection point in
  1816. * normalized screen coordinates. Normalized screen coordinates are usually
  1817. * values between 0 and 1, where 0 represents the screen's origin at the
  1818. * bottom-left corner and 1 represents the opposite edge (either top or
  1819. * right). When you request normalized coordinates, the z-component of the
  1820. * returned vector is zero. Multiply a normalized coordinate by the values
  1821. * returned by Screen::widthPixels() or Screen::heightPixels() to calculate
  1822. * the screen position in pixels (remembering that many other computer
  1823. * graphics coordinate systems place the origin in the top-left corner).
  1824. *
  1825. * Set the normalize parameter to false to request the intersection point
  1826. * in Leap Motion coordinates (millimeters from the Leap Motion origin).
  1827. *
  1828. * If the Pointable object points outside the screen's border (but still
  1829. * intersects the plane in which the screen lies), the returned intersection
  1830. * point is clamped to the nearest point on the edge of the screen.
  1831. *
  1832. * You can use the clampRatio parameter to contract or expand the area in
  1833. * which you can point. For example, if you set the clampRatio parameter to
  1834. * 0.5, then the positions reported for intersection points outside the
  1835. * central 50% of the screen are moved to the border of this smaller area.
  1836. * If, on the other hand, you expanded the area by setting clampRatio to
  1837. * a value such as 3.0, then you could point well outside screen's physical
  1838. * boundary before the intersection points would be clamped. The positions
  1839. * for any points clamped would also be placed on this larger outer border.
  1840. * The positions reported for any intersection points inside the clamping
  1841. * border are unaffected by clamping.
  1842. *
  1843. * \include Screen_Normalized_2.txt
  1844. *
  1845. * If the Pointable object does not point toward the plane of the screen
  1846. * (i.e. it is pointing parallel to or away from the screen), then the
  1847. * components of the returned vector are all set to NaN (not-a-number).
  1848. *
  1849. * @param pointable The Pointable object to check for screen intersection.
  1850. *
  1851. * @param normalize If true, return normalized coordinates representing
  1852. * the intersection point as a percentage of the screen's width and height.
  1853. * If false, return Leap Motion coordinates (millimeters from the Leap Motion origin,
  1854. * which is located at the center of the top surface of the Leap Motion Controller).
  1855. * If true and the clampRatio parameter is set to 1.0, coordinates will be
  1856. * of the form (0..1, 0..1, 0). Setting the clampRatio to a different value
  1857. * changes the range for normalized coordinates. For example, a clampRatio
  1858. * of 5.0 changes the range of values to be of the form (-2..3, -2..3, 0).
  1859. *
  1860. * @param clampRatio Adjusts the clamping border around this screen.
  1861. * By default this ratio is 1.0, and the border corresponds to the actual
  1862. * boundaries of the screen. Setting clampRatio to 0.5 would reduce the
  1863. * interaction area. Likewise, setting the ratio to 2.0 would increase the
  1864. * interaction area, adding 50% around each edge of the physical monitor.
  1865. * Intersection points outside the interaction area are repositioned to
  1866. * the closest point on the clamping border before the vector is returned.
  1867. *
  1868. * @returns A Vector containing the coordinates of the intersection between
  1869. * this screen and a ray projecting from the specified Pointable object.
  1870. * @since 1.0
  1871. */
  1872. LEAP_EXPORT Vector intersect(const Pointable& pointable, bool normalize, float clampRatio = 1.0f) const;
  1873. /**
  1874. * Returns the intersection between this screen and a ray projecting from
  1875. * the specified position along the specified direction.
  1876. *
  1877. * Set the normalize parameter to true to request the intersection point in
  1878. * normalized screen coordinates. Normalized screen coordinates are usually
  1879. * values between 0 and 1, where 0 represents the screen's origin at the
  1880. * bottom-left corner and 1 represents the opposite edge (either top or
  1881. * right). When you request normalized coordinates, the z-component of the
  1882. * returned vector is zero. Multiply a normalized coordinate by the values
  1883. * returned by Screen::widthPixels() or Screen::heightPixels() to calculate
  1884. * the screen position in pixels (remembering that many other computer
  1885. * graphics coordinate systems place the origin in the top-left corner).
  1886. *
  1887. * Set the normalize parameter to false to request the intersection point
  1888. * in Leap Motion coordinates (millimeters from the Leap Motion origin).
  1889. *
  1890. * If the specified ray points outside the screen's border (but still
  1891. * intersects the plane in which the screen lies), the returned intersection
  1892. * point is clamped to the nearest point on the edge of the screen.
  1893. *
  1894. * You can use the clampRatio parameter to contract or expand the area in
  1895. * which you can point. For example, if you set the clampRatio parameter to
  1896. * 0.5, then the positions reported for intersection points outside the
  1897. * central 50% of the screen are moved to the border of this smaller area.
  1898. * If, on the other hand, you expanded the area by setting clampRatio to
  1899. * a value such as 3.0, then you could point well outside screen's physical
  1900. * boundary before the intersection points would be clamped. The positions
  1901. * for any points clamped would also be placed on this larger outer border.
  1902. * The positions reported for any intersection points inside the clamping
  1903. * border are unaffected by clamping.
  1904. *
  1905. * If the specified ray does not point toward the plane of the screen
  1906. * (i.e. it is pointing parallel to or away from the screen), then the
  1907. * components of the returned vector are all set to NaN (not-a-number).
  1908. *
  1909. * @param position The position from which to check for screen intersection.
  1910. * @param direction The direction in which to check for screen intersection.
  1911. *
  1912. * @param normalize If true, return normalized coordinates representing
  1913. * the intersection point as a percentage of the screen's width and height.
  1914. * If false, return Leap Motion coordinates (millimeters from the Leap Motion origin,
  1915. * which is located at the center of the top surface of the Leap Motion Controller).
  1916. * If true and the clampRatio parameter is set to 1.0, coordinates will be
  1917. * of the form (0..1, 0..1, 0). Setting the clampRatio to a different value
  1918. * changes the range for normalized coordinates. For example, a clampRatio
  1919. * of 5.0 changes the range of values to be of the form (-2..3, -2..3, 0).
  1920. *
  1921. * @param clampRatio Adjusts the clamping border around this screen.
  1922. * By default this ratio is 1.0, and the border corresponds to the actual
  1923. * boundaries of the screen. Setting clampRatio to 0.5 would reduce the
  1924. * interaction area. Likewise, setting the ratio to 2.0 would increase the
  1925. * interaction area, adding 50% around each edge of the physical monitor.
  1926. * Intersection points outside the interaction area are repositioned to
  1927. * the closest point on the clamping border before the vector is returned.
  1928. *
  1929. * @returns A Vector containing the coordinates of the intersection between
  1930. * this screen and a ray projecting from the specified position in the
  1931. * specified direction.
  1932. * @since 1.0
  1933. */
  1934. LEAP_EXPORT Vector intersect(const Vector& position, const Vector& direction, bool normalize, float clampRatio = 1.0f) const;
  1935. /**
  1936. * Returns the projection from the specified position onto this screen.
  1937. *
  1938. * Set the normalize parameter to true to request the projection point in
  1939. * normalized screen coordinates. Normalized screen coordinates are usually
  1940. * values between 0 and 1, where 0 represents the screen's origin at the
  1941. * bottom-left corner and 1 represents the opposite edge (either top or
  1942. * right). When you request normalized coordinates, the z-component of the
  1943. * returned vector is zero. Multiply a normalized coordinate by the values
  1944. * returned by Screen::widthPixels() or Screen::heightPixels() to calculate
  1945. * the screen position in pixels (remembering that many other computer
  1946. * graphics coordinate systems place the origin in the top-left corner).
  1947. *
  1948. * Set the normalize parameter to false to request the projection point
  1949. * in Leap Motion coordinates (millimeters from the Leap Motion origin).
  1950. *
  1951. * If the specified point projects outside the screen's border, the returned
  1952. * projection point is clamped to the nearest point on the edge of the screen.
  1953. *
  1954. * You can use the clampRatio parameter to contract or expand the area in
  1955. * which you can point. For example, if you set the clampRatio parameter to
  1956. * 0.5, then the positions reported for projection points outside the
  1957. * central 50% of the screen are moved to the border of this smaller area.
  1958. * If, on the other hand, you expanded the area by setting clampRatio to
  1959. * a value such as 3.0, then you could point well outside screen's physical
  1960. * boundary before the projection points would be clamped. The positions
  1961. * for any points clamped would also be placed on this larger outer border.
  1962. * The positions reported for any projection points inside the clamping
  1963. * border are unaffected by clamping.
  1964. *
  1965. * @param position The position from which to project onto this screen.
  1966. *
  1967. * @param normalize If true, return normalized coordinates representing
  1968. * the projection point as a percentage of the screen's width and height.
  1969. * If false, return Leap Motion coordinates (millimeters from the Leap Motion origin,
  1970. * which is located at the center of the top surface of the Leap Motion Controller).
  1971. * If true and the clampRatio parameter is set to 1.0, coordinates will be
  1972. * of the form (0..1, 0..1, 0). Setting the clampRatio to a different value
  1973. * changes the range for normalized coordinates. For example, a clampRatio
  1974. * of 5.0 changes the range of values to be of the form (-2..3, -2..3, 0).
  1975. *
  1976. * @param clampRatio Adjusts the clamping border around this screen.
  1977. * By default this ratio is 1.0, and the border corresponds to the actual
  1978. * boundaries of the screen. Setting clampRatio to 0.5 would reduce the
  1979. * interaction area. Likewise, setting the ratio to 2.0 would increase the
  1980. * interaction area, adding 50% around each edge of the physical monitor.
  1981. * Projection points outside the interaction area are repositioned to
  1982. * the closest point on the clamping border before the vector is returned.
  1983. *
  1984. * @returns A Vector containing the coordinates of the projection between
  1985. * this screen and a ray projecting from the specified position onto the
  1986. * screen along its normal vector.
  1987. * @since 1.0
  1988. */
  1989. LEAP_EXPORT Vector project(const Vector& position, bool normalize, float clampRatio = 1.0f) const;
  1990. /**
  1991. * A Vector representing the horizontal axis of this Screen within the
  1992. * Leap Motion coordinate system.
  1993. *
  1994. * The magnitude of this vector estimates the physical width of this Screen
  1995. * in millimeters. The direction of this vector is parallel to the bottom
  1996. * edge of the screen and points toward the right edge of the screen.
  1997. *
  1998. * Together, horizontalAxis(), verticalAxis(), and bottomLeftCorner()
  1999. * describe the physical position, size and orientation of this Screen.
  2000. *
  2001. * @returns A Vector representing the bottom, horizontal edge of this Screen.
  2002. * @since 1.0
  2003. */
  2004. LEAP_EXPORT Vector horizontalAxis() const;
  2005. /**
  2006. * A Vector representing the vertical axis of this Screen within the
  2007. * Leap Motion coordinate system.
  2008. *
  2009. * The magnitude of this vector estimates the physical height of this Screen
  2010. * in millimeters. The direction of this vector is parallel to the left
  2011. * edge of the screen and points toward the top edge of the screen.
  2012. *
  2013. * Together, horizontalAxis(), verticalAxis(), and bottomLeftCorner()
  2014. * describe the physical position, size and orientation of this screen.
  2015. *
  2016. * @returns A Vector representing the left, vertical edge of this Screen.
  2017. * @since 1.0
  2018. */
  2019. LEAP_EXPORT Vector verticalAxis() const;
  2020. /**
  2021. * A Vector representing the bottom left corner of this Screen within the
  2022. * Leap Motion coordinate system.
  2023. *
  2024. * The point represented by this vector defines the origin of the screen
  2025. * in the Leap Motion coordinate system.
  2026. *
  2027. * Together, horizontalAxis(), verticalAxis(), and bottomLeftCorner()
  2028. * describe the physical position, size and orientation of this Screen.
  2029. *
  2030. * @returns A Vector containing the coordinates of the bottom-left corner
  2031. * of this Screen.
  2032. * @since 1.0
  2033. */
  2034. LEAP_EXPORT Vector bottomLeftCorner() const;
  2035. /**
  2036. * A Vector normal to the plane in which this Screen lies.
  2037. *
  2038. * The normal vector is a unit direction vector orthogonal to the screen's
  2039. * surface plane. It points toward a viewer positioned for typical use of
  2040. * the monitor.
  2041. *
  2042. * @returns A Vector representing this Screen's normal vector.
  2043. * @since 1.0
  2044. */
  2045. LEAP_EXPORT Vector normal() const;
  2046. /**
  2047. * The horizontal resolution of this screen, in pixels.
  2048. *
  2049. * @returns The width of this Screen in pixels.
  2050. * @since 1.0
  2051. */
  2052. LEAP_EXPORT int widthPixels() const;
  2053. /**
  2054. * The vertical resolution of this screen, in pixels.
  2055. *
  2056. * @returns The height of this Screen in pixels.
  2057. * @since 1.0
  2058. */
  2059. LEAP_EXPORT int heightPixels() const;
  2060. /**
  2061. * The shortest distance from the specified point to the plane in which this
  2062. * Screen lies.
  2063. *
  2064. * @returns The length of the perpendicular line segment extending from
  2065. * the plane this Screen lies in to the specified point.
  2066. * @since 1.0
  2067. */
  2068. LEAP_EXPORT float distanceToPoint(const Vector& point) const;
  2069. /**
  2070. * Reports whether this is a valid Screen object.
  2071. *
  2072. * **Important:** A valid Screen object does not necessarily contain
  2073. * up-to-date screen location information. Location information is only
  2074. * accurate until the Leap Motion Controller or the monitor are moved. In addition, the
  2075. * primary screen always contains default location information even if the
  2076. * user has never run the screen location utility. This default location
  2077. * information will not return accurate results.
  2078. *
  2079. * @returns True, if this Screen object contains valid data.
  2080. * @since 1.0
  2081. */
  2082. LEAP_EXPORT bool isValid() const;
  2083. /**
  2084. * Returns an invalid Screen object.
  2085. *
  2086. * You can use the instance returned by this function in comparisons testing
  2087. * whether a given Screen instance is valid or invalid. (You can also use the
  2088. * Screen::isValid() function.)
  2089. *
  2090. * @returns The invalid Screen instance.
  2091. * @since 1.0
  2092. */
  2093. LEAP_EXPORT static const Screen& invalid();
  2094. /**
  2095. * Compare Screen object equality.
  2096. * Two Screen objects are equal if and only if both Screen objects represent the
  2097. * exact same Screens and both Screens are valid.
  2098. * @since 1.0
  2099. */
  2100. LEAP_EXPORT bool operator==(const Screen&) const;
  2101. /**
  2102. * Compare Screen object inequality.
  2103. * Two Screen objects are equal if and only if both Screen objects represent the
  2104. * exact same Screens and both Screens are valid.
  2105. * @since 1.0
  2106. */
  2107. LEAP_EXPORT bool operator!=(const Screen&) const;
  2108. /**
  2109. * Writes a brief, human readable description of the Screen object.
  2110. * @since 1.0
  2111. */
  2112. LEAP_EXPORT friend std::ostream& operator<<(std::ostream&, const Screen&);
  2113. /**
  2114. * A string containing a brief, human readable description of the Screen object.
  2115. *
  2116. * @returns A description of the Screen as a string.
  2117. * @since 1.0
  2118. */
  2119. LEAP_EXPORT std::string toString() const;
  2120. };
  2121. /**
  2122. * The Device class represents a physically connected device.
  2123. *
  2124. * The Device class contains information related to a particular connected
  2125. * device such as field of view, device id, and calibrated positions.
  2126. *
  2127. * Note that Device objects can be invalid, which means that they do not contain
  2128. * valid device information and do not correspond to a physical device.
  2129. * Test for validity with the Device::isValid() function.
  2130. * @since 1.0
  2131. */
  2132. class Device : public Interface {
  2133. public:
  2134. // For internal use only.
  2135. Device(DeviceImplementation*);
  2136. /**
  2137. * Constructs a Device object.
  2138. *
  2139. * An uninitialized device is considered invalid.
  2140. * Get valid Device objects from a DeviceList object obtained using the
  2141. * Controller::devices() method.
  2142. *
  2143. * \include Device_Device.txt
  2144. *
  2145. * @since 1.0
  2146. */
  2147. LEAP_EXPORT Device();
  2148. /**
  2149. * The angle of view along the x axis of this device.
  2150. *
  2151. * \image html images/Leap_horizontalViewAngle.png
  2152. *
  2153. * The Leap Motion controller scans a region in the shape of an inverted pyramid
  2154. * centered at the device's center and extending upwards. The horizontalViewAngle
  2155. * reports the view angle along the long dimension of the device.
  2156. *
  2157. * \include Device_horizontalViewAngle.txt
  2158. *
  2159. * @returns The horizontal angle of view in radians.
  2160. * @since 1.0
  2161. */
  2162. LEAP_EXPORT float horizontalViewAngle() const;
  2163. /**
  2164. * The angle of view along the z axis of this device.
  2165. *
  2166. * \image html images/Leap_verticalViewAngle.png
  2167. *
  2168. * The Leap Motion controller scans a region in the shape of an inverted pyramid
  2169. * centered at the device's center and extending upwards. The verticalViewAngle
  2170. * reports the view angle along the short dimension of the device.
  2171. *
  2172. * \include Device_verticalViewAngle.txt
  2173. *
  2174. * @returns The vertical angle of view in radians.
  2175. * @since 1.0
  2176. */
  2177. LEAP_EXPORT float verticalViewAngle() const;
  2178. /**
  2179. * The maximum reliable tracking range.
  2180. *
  2181. * The range reports the maximum recommended distance from the device center
  2182. * for which tracking is expected to be reliable. This distance is not a hard limit.
  2183. * Tracking may be still be functional above this distance or begin to degrade slightly
  2184. * before this distance depending on calibration and extreme environmental conditions.
  2185. *
  2186. * \include Device_range.txt
  2187. *
  2188. * @returns The recommended maximum range of the device in mm.
  2189. * @since 1.0
  2190. */
  2191. LEAP_EXPORT float range() const;
  2192. /**
  2193. * The distance to the nearest edge of the Leap Motion controller's view volume.
  2194. *
  2195. * The view volume is an axis-aligned, inverted pyramid centered on the device origin
  2196. * and extending upward to the range limit. The walls of the pyramid are described
  2197. * by the horizontalViewAngle and verticalViewAngle and the roof by the range.
  2198. * This function estimates the distance between the specified input position and the
  2199. * nearest wall or roof of the view volume.
  2200. *
  2201. * \include Device_distanceToBoundary.txt
  2202. *
  2203. * @param position The point to use for the distance calculation.
  2204. * @returns The distance in millimeters from the input position to the nearest boundary.
  2205. * @since 1.0
  2206. */
  2207. LEAP_EXPORT float distanceToBoundary(const Vector& position) const;
  2208. /**
  2209. * Reports whether this is a valid Device object.
  2210. *
  2211. * \include Device_isValid.txt
  2212. *
  2213. * @returns True, if this Device object contains valid data.
  2214. * @since 1.0
  2215. */
  2216. LEAP_EXPORT bool isValid() const;
  2217. /**
  2218. * Returns an invalid Device object.
  2219. *
  2220. * You can use the instance returned by this function in comparisons testing
  2221. * whether a given Device instance is valid or invalid. (You can also use the
  2222. * Device::isValid() function.)
  2223. *
  2224. * \include Device_invalid.txt
  2225. *
  2226. * @returns The invalid Device instance.
  2227. * @since 1.0
  2228. */
  2229. LEAP_EXPORT static const Device& invalid();
  2230. /**
  2231. * Compare Device object equality.
  2232. *
  2233. * \include Device_operator_equals.txt
  2234. *
  2235. * Two Device objects are equal if and only if both Device objects represent the
  2236. * exact same Device and both Devices are valid.
  2237. * @since 1.0
  2238. */
  2239. LEAP_EXPORT bool operator==(const Device&) const;
  2240. /**
  2241. * Compare Device object inequality.
  2242. *
  2243. * \include Device_operator_not_equals.txt
  2244. *
  2245. * Two Device objects are equal if and only if both Device objects represent the
  2246. * exact same Device and both Devices are valid.
  2247. * @since 1.0
  2248. */
  2249. LEAP_EXPORT bool operator!=(const Device&) const;
  2250. /**
  2251. * Writes a brief, human readable description of the Device object.
  2252. *
  2253. * \include Device_operator_stream.txt
  2254. *
  2255. * @since 1.0
  2256. */
  2257. LEAP_EXPORT friend std::ostream& operator<<(std::ostream&, const Device&);
  2258. /**
  2259. * A string containing a brief, human readable description of the Device object.
  2260. *
  2261. * @returns A description of the Device as a string.
  2262. * @since 1.0
  2263. */
  2264. LEAP_EXPORT std::string toString() const;
  2265. };
  2266. // For internal use only.
  2267. template<typename L, typename T>
  2268. class ConstListIterator {
  2269. public:
  2270. ConstListIterator<L,T>(const L& list, int index) : m_list(list), m_index(index) {}
  2271. const T operator*() const { return m_list[m_index]; }
  2272. void operator++(int) {++m_index;}
  2273. const ConstListIterator<L,T>& operator++() { ++m_index; return *this; }
  2274. bool operator!=(const ConstListIterator<L,T>& rhs) const { return m_index != rhs.m_index; }
  2275. bool operator==(const ConstListIterator<L,T>& rhs) const { return m_index == rhs.m_index; }
  2276. typedef std::ptrdiff_t difference_type;
  2277. typedef T value_type;
  2278. typedef const T* pointer;
  2279. typedef const T& reference;
  2280. typedef std::forward_iterator_tag iterator_category;
  2281. private:
  2282. const L& m_list;
  2283. int m_index;
  2284. };
  2285. /**
  2286. * The PointableList class represents a list of Pointable objects.
  2287. *
  2288. * Pointable objects include entities that can be pointed, such as fingers and tools.
  2289. *
  2290. * Get a PointableList object by calling Frame::pointables() or Hand::pointables().
  2291. *
  2292. * \include PointableList_PointableList.txt
  2293. *
  2294. * @since 1.0
  2295. */
  2296. class PointableList : public Interface {
  2297. public:
  2298. // For internal use only.
  2299. PointableList(const ListBaseImplementation<Pointable>&);
  2300. /**
  2301. * Constructs an empty list of pointable entities.
  2302. * @since 1.0
  2303. */
  2304. LEAP_EXPORT PointableList();
  2305. /**
  2306. * Returns the number of pointable entities in this list.
  2307. *
  2308. * \include PointableList_count.txt
  2309. *
  2310. * @returns The number of pointable entities in this list.
  2311. * @since 1.0
  2312. */
  2313. LEAP_EXPORT int count() const;
  2314. /**
  2315. * Reports whether the list is empty.
  2316. *
  2317. * \include PointableList_isEmpty.txt
  2318. *
  2319. * @returns True, if the list has no members.
  2320. * @since 1.0
  2321. */
  2322. LEAP_EXPORT bool isEmpty() const;
  2323. /**
  2324. * Access a list member by its position in the list.
  2325. *
  2326. * \include PointableList_operator_index.txt
  2327. *
  2328. * @param index The zero-based list position index.
  2329. * @returns The Pointable object at the specified index.
  2330. * @since 1.0
  2331. */
  2332. LEAP_EXPORT Pointable operator[](int index) const;
  2333. /**
  2334. * Appends the members of the specifed PointableList to this PointableList.
  2335. * @param other A PointableList object containing Pointable objects
  2336. * to append to the end of this PointableList.
  2337. * @since 1.0
  2338. */
  2339. LEAP_EXPORT PointableList& append(const PointableList& other);
  2340. /**
  2341. * Appends the members of the specifed FingerList to this PointableList.
  2342. * @param other A FingerList object containing Finger objects
  2343. * to append to the end of this PointableList.
  2344. * @since 1.0
  2345. */
  2346. LEAP_EXPORT PointableList& append(const FingerList& other);
  2347. /**
  2348. * Appends the members of the specifed ToolList to this PointableList.
  2349. * @param other A ToolList object containing Tool objects
  2350. * to append to the end of this PointableList.
  2351. * @since 1.0
  2352. */
  2353. LEAP_EXPORT PointableList& append(const ToolList& other);
  2354. /**
  2355. * The member of the list that is farthest to the left within the standard
  2356. * Leap Motion frame of reference (i.e has the smallest X coordinate).
  2357. *
  2358. * \include PointableList_leftmost.txt
  2359. *
  2360. * @returns The leftmost pointable, or invalid if list is empty.
  2361. * @since 1.0
  2362. */
  2363. LEAP_EXPORT Pointable leftmost() const;
  2364. /**
  2365. * The member of the list that is farthest to the right within the standard
  2366. * Leap Motion frame of reference (i.e has the largest X coordinate).
  2367. *
  2368. * \include PointableList_rightmost.txt
  2369. *
  2370. * @returns The rightmost pointable, or invalid if list is empty.
  2371. * @since 1.0
  2372. */
  2373. LEAP_EXPORT Pointable rightmost() const;
  2374. /**
  2375. * The member of the list that is farthest to the front within the standard
  2376. * Leap Motion frame of reference (i.e has the smallest Z coordinate).
  2377. *
  2378. * \include PointableList_frontmost.txt
  2379. *
  2380. * @returns The frontmost pointable, or invalid if list is empty.
  2381. * @since 1.0
  2382. */
  2383. LEAP_EXPORT Pointable frontmost() const;
  2384. /**
  2385. * A C++ iterator type for PointableList objects.
  2386. *
  2387. * \include PointableList_iterator.txt
  2388. *
  2389. * @since 1.0
  2390. */
  2391. typedef ConstListIterator<PointableList, Pointable> const_iterator;
  2392. /**
  2393. * The C++ iterator set to the beginning of this PointableList.
  2394. *
  2395. * \include PointableList_begin.txt
  2396. *
  2397. * @since 1.0
  2398. */
  2399. LEAP_EXPORT const_iterator begin() const;
  2400. /**
  2401. * The C++ iterator set to the end of this PointableList.
  2402. *
  2403. * \include PointableList_end.txt
  2404. *
  2405. * @since 1.0
  2406. */
  2407. LEAP_EXPORT const_iterator end() const;
  2408. };
  2409. /**
  2410. * The FingerList class represents a list of Finger objects.
  2411. *
  2412. * Get a FingerList object by calling Frame::fingers().
  2413. *
  2414. * \include FingerList_FingerList.txt
  2415. *
  2416. * @since 1.0
  2417. */
  2418. class FingerList : public Interface {
  2419. public:
  2420. // For internal use only.
  2421. FingerList(const ListBaseImplementation<Finger>&);
  2422. /**
  2423. * Constructs an empty list of fingers.
  2424. * @since 1.0
  2425. */
  2426. LEAP_EXPORT FingerList();
  2427. /**
  2428. * Returns the number of fingers in this list.
  2429. *
  2430. * \include FingerList_count.txt
  2431. *
  2432. * @returns The number of fingers in this list.
  2433. * @since 1.0
  2434. */
  2435. LEAP_EXPORT int count() const;
  2436. /**
  2437. * Reports whether the list is empty.
  2438. *
  2439. * \include FingerList_isEmpty.txt
  2440. *
  2441. * @returns True, if the list has no members.
  2442. * @since 1.0
  2443. */
  2444. LEAP_EXPORT bool isEmpty() const;
  2445. /**
  2446. * Access a list member by its position in the list.
  2447. *
  2448. * \include FingerList_index.txt
  2449. *
  2450. * @param index The zero-based list position index.
  2451. * @returns The Finger object at the specified index.
  2452. * @since 1.0
  2453. */
  2454. LEAP_EXPORT Finger operator[](int index) const;
  2455. /**
  2456. * Appends the members of the specifed FingerList to this FingerList.
  2457. * @param other A FingerList object containing Finger objects
  2458. * to append to the end of this FingerList.
  2459. * @since 1.0
  2460. */
  2461. LEAP_EXPORT FingerList& append(const FingerList& other);
  2462. /**
  2463. * The member of the list that is farthest to the left within the standard
  2464. * Leap Motion frame of reference (i.e has the smallest X coordinate).
  2465. *
  2466. * \include FingerList_leftmost.txt
  2467. *
  2468. * @returns The leftmost finger, or invalid if list is empty.
  2469. * @since 1.0
  2470. */
  2471. LEAP_EXPORT Finger leftmost() const;
  2472. /**
  2473. * The member of the list that is farthest to the right within the standard
  2474. * Leap Motion frame of reference (i.e has the largest X coordinate).
  2475. *
  2476. * \include FingerList_rightmost.txt
  2477. *
  2478. * @returns The rightmost finger, or invalid if list is empty.
  2479. * @since 1.0
  2480. */
  2481. LEAP_EXPORT Finger rightmost() const;
  2482. /**
  2483. * The member of the list that is farthest to the front within the standard
  2484. * Leap Motion frame of reference (i.e has the smallest Z coordinate).
  2485. *
  2486. * \include FingerList_frontmost.txt
  2487. *
  2488. * @returns The frontmost finger, or invalid if list is empty.
  2489. * @since 1.0
  2490. */
  2491. LEAP_EXPORT Finger frontmost() const;
  2492. /**
  2493. * A C++ iterator type for FingerList objects.
  2494. *
  2495. * \include FingerList_iterator.txt
  2496. *
  2497. * @since 1.0
  2498. */
  2499. typedef ConstListIterator<FingerList, Finger> const_iterator;
  2500. /**
  2501. * The C++ iterator set to the beginning of this FingerList.
  2502. *
  2503. * \include FingerList_begin.txt
  2504. *
  2505. * @since 1.0
  2506. */
  2507. LEAP_EXPORT const_iterator begin() const;
  2508. /**
  2509. * The C++ iterator set to the end of this FingerList.
  2510. *
  2511. * \include FingerList_end.txt
  2512. *
  2513. * @since 1.0
  2514. */
  2515. LEAP_EXPORT const_iterator end() const;
  2516. };
  2517. /**
  2518. * The ToolList class represents a list of Tool objects.
  2519. *
  2520. * Get a ToolList object by calling Frame::tools() or Hand::tools().
  2521. *
  2522. * \include ToolList_ToolList.txt
  2523. *
  2524. * @since 1.0
  2525. */
  2526. class ToolList : public Interface {
  2527. public:
  2528. // For internal use only.
  2529. ToolList(const ListBaseImplementation<Tool>&);
  2530. /**
  2531. * Constructs an empty list of tools.
  2532. * @since 1.0
  2533. */
  2534. LEAP_EXPORT ToolList();
  2535. /**
  2536. * Returns the number of tools in this list.
  2537. *
  2538. * \include ToolList_count.txt
  2539. *
  2540. * @returns The number of tools in this list.
  2541. * @since 1.0
  2542. */
  2543. LEAP_EXPORT int count() const;
  2544. /**
  2545. * Reports whether the list is empty.
  2546. *
  2547. * \include ToolList_isEmpty.txt
  2548. *
  2549. * @returns True, if the list has no members.
  2550. * @since 1.0
  2551. */
  2552. LEAP_EXPORT bool isEmpty() const;
  2553. /**
  2554. * Access a list member by its position in the list.
  2555. *
  2556. * \include ToolList_operator_index.txt
  2557. *
  2558. * @param index The zero-based list position index.
  2559. * @returns The Tool object at the specified index.
  2560. * @since 1.0
  2561. */
  2562. LEAP_EXPORT Tool operator[](int index) const;
  2563. /**
  2564. * Appends the members of the specifed ToolList to this ToolList.
  2565. * @param other A ToolList object containing Tool objects
  2566. * to append to the end of this ToolList.
  2567. * @since 1.0
  2568. */
  2569. LEAP_EXPORT ToolList& append(const ToolList& other);
  2570. /**
  2571. * The member of the list that is farthest to the left within the standard
  2572. * Leap Motion frame of reference (i.e has the smallest X coordinate).
  2573. *
  2574. * \include ToolList_leftmost.txt
  2575. *
  2576. * @returns The leftmost tool, or invalid if list is empty.
  2577. * @since 1.0
  2578. */
  2579. LEAP_EXPORT Tool leftmost() const;
  2580. /**
  2581. * The member of the list that is farthest to the right within the standard
  2582. * Leap Motion frame of reference (i.e has the largest X coordinate).
  2583. *
  2584. * \include ToolList_rightmost.txt
  2585. *
  2586. * @returns The rightmost tool, or invalid if list is empty.
  2587. * @since 1.0
  2588. */
  2589. LEAP_EXPORT Tool rightmost() const;
  2590. /**
  2591. * The member of the list that is farthest to the front within the standard
  2592. * Leap Motion frame of reference (i.e has the smallest Z coordinate).
  2593. *
  2594. * \include ToolList_frontmost.txt
  2595. *
  2596. * @returns The frontmost tool, or invalid if list is empty.
  2597. * @since 1.0
  2598. */
  2599. LEAP_EXPORT Tool frontmost() const;
  2600. /**
  2601. * A C++ iterator type for ToolList objects.
  2602. *
  2603. * \include ToolList_iterator.txt
  2604. *
  2605. * @since 1.0
  2606. */
  2607. typedef ConstListIterator<ToolList, Tool> const_iterator;
  2608. /**
  2609. * The C++ iterator set to the beginning of this ToolList.
  2610. *
  2611. * \include ToolList_begin.txt
  2612. * @since 1.0
  2613. */
  2614. LEAP_EXPORT const_iterator begin() const;
  2615. /**
  2616. * The C++ iterator set to the end of this ToolList.
  2617. *
  2618. * \include ToolList_end.txt
  2619. *
  2620. * @since 1.0
  2621. */
  2622. LEAP_EXPORT const_iterator end() const;
  2623. };
  2624. /**
  2625. * The HandList class represents a list of Hand objects.
  2626. *
  2627. * Get a HandList object by calling Frame::hands().
  2628. *
  2629. * \include HandList_HandList.txt
  2630. *
  2631. * @since 1.0
  2632. */
  2633. class HandList : public Interface {
  2634. public:
  2635. // For internal use only.
  2636. HandList(const ListBaseImplementation<Hand>&);
  2637. /**
  2638. * Constructs an empty list of hands.
  2639. * @since 1.0
  2640. */
  2641. LEAP_EXPORT HandList();
  2642. /**
  2643. * Returns the number of hands in this list.
  2644. *
  2645. * \include HandList_count.txt
  2646. * @returns The number of hands in this list.
  2647. * @since 1.0
  2648. */
  2649. LEAP_EXPORT int count() const;
  2650. /**
  2651. * Reports whether the list is empty.
  2652. *
  2653. * \include HandList_isEmpty.txt
  2654. *
  2655. * @returns True, if the list has no members.
  2656. * @since 1.0
  2657. */
  2658. LEAP_EXPORT bool isEmpty() const;
  2659. /**
  2660. * Access a list member by its position in the list.
  2661. *
  2662. * \include HandList_operator_index.txt
  2663. *
  2664. * @param index The zero-based list position index.
  2665. * @returns The Hand object at the specified index.
  2666. * @since 1.0
  2667. */
  2668. LEAP_EXPORT Hand operator[](int index) const;
  2669. /**
  2670. * Appends the members of the specifed HandList to this HandList.
  2671. * @param other A HandList object containing Hand objects
  2672. * to append to the end of this HandList.
  2673. */
  2674. LEAP_EXPORT HandList& append(const HandList& other);
  2675. /**
  2676. * The member of the list that is farthest to the left within the standard
  2677. * Leap Motion frame of reference (i.e has the smallest X coordinate).
  2678. *
  2679. * \include HandList_leftmost.txt
  2680. *
  2681. * @returns The leftmost hand, or invalid if list is empty.
  2682. * @since 1.0
  2683. */
  2684. LEAP_EXPORT Hand leftmost() const;
  2685. /**
  2686. * The member of the list that is farthest to the right within the standard
  2687. * Leap Motion frame of reference (i.e has the largest X coordinate).
  2688. *
  2689. * \include HandList_rightmost.txt
  2690. *
  2691. * @returns The rightmost hand, or invalid if list is empty.
  2692. * @since 1.0
  2693. */
  2694. LEAP_EXPORT Hand rightmost() const;
  2695. /**
  2696. * The member of the list that is farthest to the front within the standard
  2697. * Leap Motion frame of reference (i.e has the smallest Z coordinate).
  2698. *
  2699. * \include HandList_frontmost.txt
  2700. *
  2701. * @returns The frontmost hand, or invalid if list is empty.
  2702. * @since 1.0
  2703. */
  2704. LEAP_EXPORT Hand frontmost() const;
  2705. /**
  2706. * A C++ iterator type for this HandList objects.
  2707. *
  2708. * \include HandList_iterator.txt
  2709. *
  2710. * @since 1.0
  2711. */
  2712. typedef ConstListIterator<HandList, Hand> const_iterator;
  2713. /**
  2714. * The C++ iterator set to the beginning of this HandList.
  2715. *
  2716. * \include HandList_begin.txt
  2717. *
  2718. * @since 1.0
  2719. */
  2720. LEAP_EXPORT const_iterator begin() const;
  2721. /**
  2722. * The C++ iterator set to the end of this HandList.
  2723. *
  2724. * \include HandList_end.txt
  2725. *
  2726. * @since 1.0
  2727. */
  2728. LEAP_EXPORT const_iterator end() const;
  2729. };
  2730. /**
  2731. * The GestureList class represents a list of Gesture objects.
  2732. *
  2733. * Get a GestureList object from a Frame object.
  2734. * @since 1.0
  2735. */
  2736. class GestureList : public Interface {
  2737. public:
  2738. // For internal use only.
  2739. GestureList(const ListBaseImplementation<Gesture>&);
  2740. /**
  2741. * Constructs an empty gesture list.
  2742. * @since 1.0
  2743. */
  2744. LEAP_EXPORT GestureList();
  2745. /**
  2746. * The length of this list.
  2747. *
  2748. * \include GestureList_count.txt
  2749. *
  2750. * @returns The number of gestures in this list.
  2751. * @since 1.0
  2752. */
  2753. LEAP_EXPORT int count() const;
  2754. /**
  2755. * Reports whether the list is empty.
  2756. *
  2757. * \include GestureList_isEmpty.txt
  2758. *
  2759. * @returns True, if the list has no members.
  2760. * @since 1.0
  2761. */
  2762. LEAP_EXPORT bool isEmpty() const;
  2763. /**
  2764. * Access a list member by its position in the list.
  2765. *
  2766. * \include GestureList_operator_index.txt
  2767. *
  2768. * @param index The zero-based list position index.
  2769. * @returns The Gesture object at the specified index.
  2770. * @since 1.0
  2771. */
  2772. LEAP_EXPORT Gesture operator[](int index) const;
  2773. /**
  2774. * Appends the members of the specified GestureList to this GestureList.
  2775. * @param other A GestureList object containing Gesture objects
  2776. * to append to the end of this GestureList.
  2777. * @since 1.0
  2778. */
  2779. LEAP_EXPORT GestureList& append(const GestureList& other);
  2780. /**
  2781. * A C++ iterator type for GestureList objects.
  2782. *
  2783. * \include GestureList_iterator.txt
  2784. * @since 1.0
  2785. */
  2786. typedef ConstListIterator<GestureList, Gesture> const_iterator;
  2787. /**
  2788. * The C++ iterator set to the beginning of this GestureList.
  2789. *
  2790. * \include GestureList_begin.txt
  2791. *
  2792. * @since 1.0
  2793. */
  2794. LEAP_EXPORT const_iterator begin() const;
  2795. /**
  2796. * The C++ iterator set to the end of this GestureList.
  2797. *
  2798. * \include GestureList_end.txt
  2799. *
  2800. * @since 1.0
  2801. */
  2802. LEAP_EXPORT const_iterator end() const;
  2803. };
  2804. /*
  2805. * The ScreenList and Screen classes are currently unsupported.
  2806. *
  2807. * We are re-evaluating this feature due to the cumbersome location process
  2808. * required to use it and the amount of confusion about the feature's purpose.
  2809. *
  2810. * The ScreenList class represents a list of Screen objects.
  2811. *
  2812. * The list always contains at least one entry representing the default
  2813. * screen. If the user has not registered the location of this default
  2814. * screen, then the coordinates, directions, and other values reported by
  2815. * the functions in its Screen object will not be accurate. Other monitor
  2816. * screens only appear in the list if their positions have been registered
  2817. * using the Leap Motion Screen Locator.
  2818. *
  2819. * Get a ScreenList object by calling Controller::locatedScreens().
  2820. *
  2821. * \include Screen_Closest_1.txt
  2822. * @since 1.0
  2823. */
  2824. class ScreenList : public Interface {
  2825. public:
  2826. // For internal use only.
  2827. ScreenList(const ListBaseImplementation<Screen>&);
  2828. /**
  2829. * Constructs an empty list of screens.
  2830. * @since 1.0
  2831. */
  2832. LEAP_EXPORT ScreenList();
  2833. /**
  2834. * Returns the number of screens in this list.
  2835. * @returns The number of screens in this list.
  2836. * @since 1.0
  2837. */
  2838. LEAP_EXPORT int count() const;
  2839. /**
  2840. * Reports whether the list is empty.
  2841. * @returns True, if the list has no members.
  2842. * @since 1.0
  2843. */
  2844. LEAP_EXPORT bool isEmpty() const;
  2845. /**
  2846. * Access a list member by its position in the list.
  2847. * @param index The zero-based list position index.
  2848. * @returns The Screen object at the specified index.
  2849. * @since 1.0
  2850. */
  2851. LEAP_EXPORT Screen operator[](int index) const;
  2852. /**
  2853. * A C++ iterator type for this ScreenList objects.
  2854. * @since 1.0
  2855. */
  2856. typedef ConstListIterator<ScreenList, Screen> const_iterator;
  2857. /**
  2858. * The C++ iterator set to the beginning of this ScreenList.
  2859. * @since 1.0
  2860. */
  2861. LEAP_EXPORT const_iterator begin() const;
  2862. /**
  2863. * The C++ iterator set to the end of this ScreenList.
  2864. * @since 1.0
  2865. */
  2866. LEAP_EXPORT const_iterator end() const;
  2867. /**
  2868. * Gets the closest Screen intercepting a ray projecting from the specified
  2869. * Pointable object.
  2870. *
  2871. * The projected ray emanates from the Pointable tipPosition along the
  2872. * Pointable's direction vector. If the projected ray does not intersect
  2873. * any screen surface directly, then the Leap Motion software checks for intersection with
  2874. * the planes extending from the surfaces of the known screens
  2875. * and returns the Screen with the closest intersection.
  2876. *
  2877. * \include Screen_Closest_2.txt
  2878. *
  2879. * If no intersections are found (i.e. the ray is directed parallel to or
  2880. * away from all known screens), then an invalid Screen object is returned.
  2881. *
  2882. * *Note:* Be sure to test whether the Screen object returned by this method
  2883. * is valid. Attempting to use an invalid Screen object will lead to
  2884. * incorrect results.
  2885. *
  2886. * @param pointable The Pointable object to check for screen intersection.
  2887. * @returns The closest Screen toward which the specified Pointable object
  2888. * is pointing, or, if the pointable is not pointing in the direction of
  2889. * any known screen, an invalid Screen object.
  2890. * @since 1.0
  2891. */
  2892. LEAP_EXPORT Screen closestScreenHit(const Pointable& pointable) const;
  2893. /**
  2894. * Gets the closest Screen intercepting a ray projecting from the specified
  2895. * position in the specified direction.
  2896. *
  2897. * The projected ray emanates from the position along the direction vector.
  2898. * If the projected ray does not intersect any screen surface directly,
  2899. * then the Leap Motion software checks for intersection with the planes extending from the
  2900. * surfaces of the known screens and returns the Screen with the closest
  2901. * intersection.
  2902. *
  2903. * \include Screen_Closest_3.txt
  2904. *
  2905. * If no intersections are found (i.e. the ray is directed parallel to or
  2906. * away from all known screens), then an invalid Screen object is returned.
  2907. *
  2908. * *Note:* Be sure to test whether the Screen object returned by this method
  2909. * is valid. Attempting to use an invalid Screen object will lead to
  2910. * incorrect results.
  2911. *
  2912. * @param position The position from which to check for screen intersection.
  2913. * @param direction The direction in which to check for screen intersection.
  2914. * @returns The closest Screen toward which the specified ray is pointing,
  2915. * or, if the ray is not pointing in the direction of any known screen,
  2916. * an invalid Screen object.
  2917. * @since 1.0
  2918. */
  2919. LEAP_EXPORT Screen closestScreenHit(const Vector& position, const Vector& direction) const;
  2920. /**
  2921. * Gets the Screen closest to the specified position.
  2922. *
  2923. * The specified position is projected along each screen's normal vector
  2924. * onto the screen's plane. The screen whose projected point is closest to
  2925. * the specified position is returned. Call Screen::project(position)
  2926. * on the returned Screen object to find the projected point.
  2927. *
  2928. * \include Screen_Closest_3.txt
  2929. *
  2930. * @param position The position from which to check for screen projection.
  2931. * @returns The closest Screen onto which the specified position is projected.
  2932. * @since 1.0
  2933. */
  2934. LEAP_EXPORT Screen closestScreen(const Vector& position) const;
  2935. };
  2936. /**
  2937. * The DeviceList class represents a list of Device objects.
  2938. *
  2939. * Get a DeviceList object by calling Controller::devices().
  2940. * @since 1.0
  2941. */
  2942. class DeviceList : public Interface {
  2943. public:
  2944. // For internal use only.
  2945. DeviceList(const ListBaseImplementation<Device>&);
  2946. /**
  2947. * Constructs an empty list of devices.
  2948. * @since 1.0
  2949. */
  2950. LEAP_EXPORT DeviceList();
  2951. /**
  2952. * Returns the number of devices in this list.
  2953. * @returns The number of devices in this list.
  2954. * @since 1.0
  2955. */
  2956. LEAP_EXPORT int count() const;
  2957. /**
  2958. * Reports whether the list is empty.
  2959. *
  2960. * \include DeviceList_isEmpty.txt
  2961. *
  2962. * @returns True, if the list has no members.
  2963. * @since 1.0
  2964. */
  2965. LEAP_EXPORT bool isEmpty() const;
  2966. /**
  2967. * Access a list member by its position in the list.
  2968. * @param index The zero-based list position index.
  2969. * @returns The Device object at the specified index.
  2970. * @since 1.0
  2971. */
  2972. LEAP_EXPORT Device operator[](int index) const;
  2973. /**
  2974. * Appends the members of the specifed DeviceList to this DeviceList.
  2975. * @param other A DeviceList object containing Device objects
  2976. * to append to the end of this DeviceList.
  2977. * @since 1.0
  2978. */
  2979. LEAP_EXPORT DeviceList& append(const DeviceList& other);
  2980. /**
  2981. * A C++ iterator type for this DeviceList objects.
  2982. * @since 1.0
  2983. */
  2984. typedef ConstListIterator<DeviceList, Device> const_iterator;
  2985. /**
  2986. * The C++ iterator set to the beginning of this DeviceList.
  2987. * @since 1.0
  2988. */
  2989. LEAP_EXPORT const_iterator begin() const;
  2990. /**
  2991. * The C++ iterator set to the end of this DeviceList.
  2992. * @since 1.0
  2993. */
  2994. LEAP_EXPORT const_iterator end() const;
  2995. };
  2996. /**
  2997. * The InteractionBox class represents a box-shaped region completely
  2998. * within the field of view of the Leap Motion controller.
  2999. *
  3000. * The interaction box is an axis-aligned rectangular prism and provides normalized
  3001. * coordinates for hands, fingers, and tools within this box. The InteractionBox class
  3002. * can make it easier to map positions in the Leap Motion coordinate system to 2D or
  3003. * 3D coordinate systems used for application drawing.
  3004. *
  3005. * \image html images/Leap_InteractionBox.png
  3006. *
  3007. * The InteractionBox region is defined by a center and dimensions along the x, y,
  3008. * and z axes.
  3009. *
  3010. * Get an InteractionBox object from a Frame object.
  3011. * @since 1.0
  3012. */
  3013. class InteractionBox : public Interface {
  3014. public:
  3015. // For internal use only.
  3016. InteractionBox(InteractionBoxImplementation*);
  3017. LEAP_EXPORT InteractionBox();
  3018. /**
  3019. * Normalizes the coordinates of a point using the interaction box.
  3020. *
  3021. * \include InteractionBox_normalizePoint.txt
  3022. *
  3023. * Coordinates from the Leap Motion frame of reference (millimeters) are converted
  3024. * to a range of [0..1] such that the minimum value of the InteractionBox maps to 0
  3025. * and the maximum value of the InteractionBox maps to 1.
  3026. *
  3027. * @param position The input position in device coordinates.
  3028. * @param clamp Whether or not to limit the output value to the range [0,1] when the
  3029. * input position is outside the InteractionBox. Defaults to true.
  3030. * @returns The normalized position.
  3031. * @since 1.0
  3032. */
  3033. LEAP_EXPORT Vector normalizePoint(const Vector& position, bool clamp = true) const;
  3034. /**
  3035. * Converts a position defined by normalized InteractionBox coordinates into device
  3036. * coordinates in millimeters.
  3037. *
  3038. * \include InteractionBox_denormalizePoint.txt
  3039. *
  3040. * This function performs the inverse of normalizePoint().
  3041. *
  3042. * @param normalizedPosition The input position in InteractionBox coordinates.
  3043. * @returns The corresponding denormalized position in device coordinates.
  3044. * @since 1.0
  3045. */
  3046. LEAP_EXPORT Vector denormalizePoint(const Vector& normalizedPosition) const;
  3047. /**
  3048. * The center of the InteractionBox in device coordinates (millimeters). This point
  3049. * is equidistant from all sides of the box.
  3050. *
  3051. * \include InteractionBox_center.txt
  3052. *
  3053. * @returns The InteractionBox center in device coordinates.
  3054. * @since 1.0
  3055. */
  3056. LEAP_EXPORT Vector center() const;
  3057. /**
  3058. * The width of the InteractionBox in millimeters, measured along the x-axis.
  3059. *
  3060. * \include InteractionBox_width.txt
  3061. *
  3062. * @returns The InteractionBox width in millimeters.
  3063. * @since 1.0
  3064. */
  3065. LEAP_EXPORT float width() const;
  3066. /**
  3067. * The height of the InteractionBox in millimeters, measured along the y-axis.
  3068. *
  3069. * \include InteractionBox_height.txt
  3070. *
  3071. * @returns The InteractionBox height in millimeters.
  3072. * @since 1.0
  3073. */
  3074. LEAP_EXPORT float height() const;
  3075. /**
  3076. * The depth of the InteractionBox in millimeters, measured along the z-axis.
  3077. *
  3078. * \include InteractionBox_depth.txt
  3079. *
  3080. * @returns The InteractionBox depth in millimeters.
  3081. * @since 1.0
  3082. */
  3083. LEAP_EXPORT float depth() const;
  3084. /**
  3085. * Reports whether this is a valid InteractionBox object.
  3086. *
  3087. * \include InteractionBox_isValid.txt
  3088. *
  3089. * @returns True, if this InteractionBox object contains valid data.
  3090. * @since 1.0
  3091. */
  3092. LEAP_EXPORT bool isValid() const;
  3093. /**
  3094. * Returns an invalid InteractionBox object.
  3095. *
  3096. * You can use the instance returned by this function in comparisons testing
  3097. * whether a given InteractionBox instance is valid or invalid. (You can also use the
  3098. * InteractionBox::isValid() function.)
  3099. *
  3100. * \include InteractionBox_invalid.txt
  3101. *
  3102. * @returns The invalid InteractionBox instance.
  3103. * @since 1.0
  3104. */
  3105. LEAP_EXPORT static const InteractionBox& invalid();
  3106. /**
  3107. * Compare InteractionBox object equality.
  3108. *
  3109. * \include InteractionBox_operator_equals.txt
  3110. *
  3111. * Two InteractionBox objects are equal if and only if both InteractionBox objects represent the
  3112. * exact same InteractionBox and both InteractionBoxes are valid.
  3113. * @since 1.0
  3114. */
  3115. LEAP_EXPORT bool operator==(const InteractionBox&) const;
  3116. /**
  3117. * Compare InteractionBox object inequality.
  3118. *
  3119. * \include InteractionBox_operator_not_equals.txt
  3120. *
  3121. * Two InteractionBox objects are equal if and only if both InteractionBox objects represent the
  3122. * exact same InteractionBox and both InteractionBoxes are valid.
  3123. * @since 1.0
  3124. */
  3125. LEAP_EXPORT bool operator!=(const InteractionBox&) const;
  3126. /**
  3127. * Writes a brief, human readable description of the InteractionBox object.
  3128. *
  3129. * \include InteractionBox_operator_stream.txt
  3130. *
  3131. * @since 1.0
  3132. */
  3133. LEAP_EXPORT friend std::ostream& operator<<(std::ostream&, const InteractionBox&);
  3134. /**
  3135. * A string containing a brief, human readable description of the InteractionBox object.
  3136. *
  3137. * @returns A description of the InteractionBox as a string.
  3138. * @since 1.0
  3139. */
  3140. LEAP_EXPORT std::string toString() const;
  3141. };
  3142. /**
  3143. * The Frame class represents a set of hand and finger tracking data detected
  3144. * in a single frame.
  3145. *
  3146. * The Leap Motion software detects hands, fingers and tools within the tracking area, reporting
  3147. * their positions, orientations, gestures, and motions in frames at the Leap Motion frame rate.
  3148. *
  3149. * Access Frame objects through an instance of the Controller class:
  3150. *
  3151. * \include Controller_Frame_1.txt
  3152. *
  3153. * Implement a Listener subclass to receive a callback event when a new Frame is available.
  3154. * @since 1.0
  3155. */
  3156. class Frame : public Interface {
  3157. public:
  3158. // For internal use only.
  3159. Frame(FrameImplementation*);
  3160. /**
  3161. * Constructs a Frame object.
  3162. *
  3163. * Frame instances created with this constructor are invalid.
  3164. * Get valid Frame objects by calling the Controller::frame() function.
  3165. *
  3166. * \include Frame_Frame.txt
  3167. *
  3168. * @since 1.0
  3169. */
  3170. LEAP_EXPORT Frame();
  3171. /**
  3172. * A unique ID for this Frame.
  3173. *
  3174. * Consecutive frames processed by the Leap Motion software have consecutive
  3175. * increasing values. You can use the frame ID to avoid processing the same
  3176. * Frame object twice:
  3177. *
  3178. * \include Frame_Duplicate.txt
  3179. *
  3180. * As well as to make sure that your application processes every frame:
  3181. *
  3182. * \include Frame_Skipped.txt
  3183. *
  3184. * @returns The frame ID.
  3185. * @since 1.0
  3186. */
  3187. LEAP_EXPORT int64_t id() const;
  3188. /**
  3189. * The frame capture time in microseconds elapsed since the Leap started.
  3190. *
  3191. * \include Frame_timestamp.txt
  3192. *
  3193. * @returns The timestamp in microseconds.
  3194. * @since 1.0
  3195. */
  3196. LEAP_EXPORT int64_t timestamp() const;
  3197. /**
  3198. * The list of Hand objects detected in this frame, given in arbitrary order.
  3199. * The list can be empty if no hands are detected.
  3200. *
  3201. * \include Frame_hands.txt
  3202. *
  3203. * @returns The HandList containing all Hand objects detected in this frame.
  3204. * @since 1.0
  3205. */
  3206. LEAP_EXPORT HandList hands() const;
  3207. /**
  3208. * The Hand object with the specified ID in this frame.
  3209. *
  3210. * Use the Frame::hand() function to retrieve the Hand object from
  3211. * this frame using an ID value obtained from a previous frame.
  3212. * This function always returns a Hand object, but if no hand
  3213. * with the specified ID is present, an invalid Hand object is returned.
  3214. *
  3215. * \include Frame_hand.txt
  3216. *
  3217. * Note that ID values persist across frames, but only until tracking of a
  3218. * particular object is lost. If tracking of a hand is lost and subsequently
  3219. * regained, the new Hand object representing that physical hand may have
  3220. * a different ID than that representing the physical hand in an earlier frame.
  3221. *
  3222. * @param id The ID value of a Hand object from a previous frame.
  3223. * @returns The Hand object with the matching ID if one exists in this frame;
  3224. * otherwise, an invalid Hand object is returned.
  3225. * @since 1.0
  3226. */
  3227. LEAP_EXPORT Hand hand(int32_t id) const;
  3228. /**
  3229. * The list of Pointable objects (fingers and tools) detected in this frame,
  3230. * given in arbitrary order. The list can be empty if no fingers or tools are detected.
  3231. *
  3232. * \include Frame_pointables.txt
  3233. *
  3234. * @returns The PointableList containing all Pointable objects detected in this frame.
  3235. * @since 1.0
  3236. */
  3237. LEAP_EXPORT PointableList pointables() const;
  3238. /**
  3239. * The Pointable object with the specified ID in this frame.
  3240. *
  3241. * Use the Frame::pointable() function to retrieve the Pointable object from
  3242. * this frame using an ID value obtained from a previous frame.
  3243. * This function always returns a Pointable object, but if no finger or tool
  3244. * with the specified ID is present, an invalid Pointable object is returned.
  3245. *
  3246. * \include Frame_pointable.txt
  3247. *
  3248. * Note that ID values persist across frames, but only until tracking of a
  3249. * particular object is lost. If tracking of a finger or tool is lost and subsequently
  3250. * regained, the new Pointable object representing that finger or tool may have
  3251. * a different ID than that representing the finger or tool in an earlier frame.
  3252. *
  3253. * @param id The ID value of a Pointable object from a previous frame.
  3254. * @returns The Pointable object with the matching ID if one exists in this frame;
  3255. * otherwise, an invalid Pointable object is returned.
  3256. * @since 1.0
  3257. */
  3258. LEAP_EXPORT Pointable pointable(int32_t id) const;
  3259. /**
  3260. * The list of Finger objects detected in this frame, given in arbitrary order.
  3261. * The list can be empty if no fingers are detected.
  3262. *
  3263. * \include Frame_fingers.txt
  3264. *
  3265. * @returns The FingerList containing all Finger objects detected in this frame.
  3266. * @since 1.0
  3267. */
  3268. LEAP_EXPORT FingerList fingers() const;
  3269. /**
  3270. * The Finger object with the specified ID in this frame.
  3271. *
  3272. * Use the Frame::finger() function to retrieve the Finger object from
  3273. * this frame using an ID value obtained from a previous frame.
  3274. * This function always returns a Finger object, but if no finger
  3275. * with the specified ID is present, an invalid Finger object is returned.
  3276. *
  3277. * \include Frame_finger.txt
  3278. *
  3279. * Note that ID values persist across frames, but only until tracking of a
  3280. * particular object is lost. If tracking of a finger is lost and subsequently
  3281. * regained, the new Finger object representing that physical finger may have
  3282. * a different ID than that representing the finger in an earlier frame.
  3283. *
  3284. * @param id The ID value of a Finger object from a previous frame.
  3285. * @returns The Finger object with the matching ID if one exists in this frame;
  3286. * otherwise, an invalid Finger object is returned.
  3287. * @since 1.0
  3288. */
  3289. LEAP_EXPORT Finger finger(int32_t id) const;
  3290. /**
  3291. * The list of Tool objects detected in this frame, given in arbitrary order.
  3292. * The list can be empty if no tools are detected.
  3293. *
  3294. * \include Frame_tools.txt
  3295. *
  3296. * @returns The ToolList containing all Tool objects detected in this frame.
  3297. * @since 1.0
  3298. */
  3299. LEAP_EXPORT ToolList tools() const;
  3300. /**
  3301. * The Tool object with the specified ID in this frame.
  3302. *
  3303. * Use the Frame::tool() function to retrieve the Tool object from
  3304. * this frame using an ID value obtained from a previous frame.
  3305. * This function always returns a Tool object, but if no tool
  3306. * with the specified ID is present, an invalid Tool object is returned.
  3307. *
  3308. * \include Frame_tool.txt
  3309. *
  3310. * Note that ID values persist across frames, but only until tracking of a
  3311. * particular object is lost. If tracking of a tool is lost and subsequently
  3312. * regained, the new Tool object representing that tool may have a
  3313. * different ID than that representing the tool in an earlier frame.
  3314. *
  3315. * @param id The ID value of a Tool object from a previous frame.
  3316. * @returns The Tool object with the matching ID if one exists in this frame;
  3317. * otherwise, an invalid Tool object is returned.
  3318. * @since 1.0
  3319. */
  3320. LEAP_EXPORT Tool tool(int32_t id) const;
  3321. /**
  3322. * The Gesture object with the specified ID in this frame.
  3323. *
  3324. * Use the Frame::gesture() function to return a Gesture object in this
  3325. * frame using an ID obtained in an earlier frame. The function always
  3326. * returns a Gesture object, but if there was no update for the gesture in
  3327. * this frame, then an invalid Gesture object is returned.
  3328. *
  3329. * \include Frame_gesture.txt
  3330. *
  3331. * All Gesture objects representing the same recognized movement share the
  3332. * same ID.
  3333. * @param id The ID of an Gesture object from a previous frame.
  3334. * @returns The Gesture object in the frame with the specified ID if one
  3335. * exists; Otherwise, an Invalid Gesture object.
  3336. * @since 1.0
  3337. */
  3338. LEAP_EXPORT Gesture gesture(int32_t id) const;
  3339. /**
  3340. * The gestures recognized or continuing in this frame.
  3341. *
  3342. * \include Frame_gestures_now.txt
  3343. *
  3344. * Circle and swipe gestures are updated every frame. Tap gestures
  3345. * only appear in the list for a single frame.
  3346. *
  3347. * @return GestureList the list of gestures.
  3348. * @since 1.0
  3349. */
  3350. LEAP_EXPORT GestureList gestures() const;
  3351. /**
  3352. * Returns a GestureList containing all gestures that have occured since
  3353. * the specified frame.
  3354. *
  3355. * \include Frame_gestures_since.txt
  3356. *
  3357. * @param sinceFrame An earlier Frame object. The starting frame must
  3358. * still be in the frame history cache, which has a default length of
  3359. * 60 frames.
  3360. * @return GestureList The list of the Gesture objects that have occured
  3361. * since the specified frame.
  3362. * @since 1.0
  3363. */
  3364. LEAP_EXPORT GestureList gestures(const Frame& sinceFrame) const;
  3365. /**
  3366. * The change of position derived from the overall linear motion between
  3367. * the current frame and the specified frame.
  3368. *
  3369. * The returned translation vector provides the magnitude and direction of
  3370. * the movement in millimeters.
  3371. *
  3372. * \include Frame_translation.txt
  3373. *
  3374. * The Leap Motion software derives frame translation from the linear motion of
  3375. * all objects detected in the field of view.
  3376. *
  3377. * If either this frame or sinceFrame is an invalid Frame object, then this
  3378. * method returns a zero vector.
  3379. *
  3380. * @param sinceFrame The starting frame for computing the relative translation.
  3381. * @returns A Vector representing the heuristically determined change in
  3382. * position of all objects between the current frame and that specified
  3383. * in the sinceFrame parameter.
  3384. * @since 1.0
  3385. */
  3386. LEAP_EXPORT Vector translation(const Frame& sinceFrame) const;
  3387. /**
  3388. * The estimated probability that the overall motion between the current
  3389. * frame and the specified frame is intended to be a translating motion.
  3390. *
  3391. * \include Frame_translationProbability.txt
  3392. *
  3393. * If either this frame or sinceFrame is an invalid Frame object, then this
  3394. * method returns zero.
  3395. *
  3396. * @param sinceFrame The starting frame for computing the translation.
  3397. * @returns A value between 0 and 1 representing the estimated probability
  3398. * that the overall motion between the current frame and the specified frame
  3399. * is intended to be a translating motion.
  3400. * @since 1.0
  3401. */
  3402. LEAP_EXPORT float translationProbability(const Frame& sinceFrame) const;
  3403. /**
  3404. * The axis of rotation derived from the overall rotational motion between
  3405. * the current frame and the specified frame.
  3406. *
  3407. * The returned direction vector is normalized.
  3408. *
  3409. * \include Frame_rotationAxis.txt
  3410. *
  3411. * The Leap Motion software derives frame rotation from the relative change in position and
  3412. * orientation of all objects detected in the field of view.
  3413. *
  3414. * If either this frame or sinceFrame is an invalid Frame object, or if no
  3415. * rotation is detected between the two frames, a zero vector is returned.
  3416. *
  3417. * @param sinceFrame The starting frame for computing the relative rotation.
  3418. * @returns A normalized direction Vector representing the axis of the
  3419. * heuristically determined rotational change between the current frame
  3420. * and that specified in the sinceFrame parameter.
  3421. * @since 1.0
  3422. */
  3423. LEAP_EXPORT Vector rotationAxis(const Frame& sinceFrame) const;
  3424. /**
  3425. * The angle of rotation around the rotation axis derived from the overall
  3426. * rotational motion between the current frame and the specified frame.
  3427. *
  3428. * The returned angle is expressed in radians measured clockwise around the
  3429. * rotation axis (using the right-hand rule) between the start and end frames.
  3430. * The value is always between 0 and pi radians (0 and 180 degrees).
  3431. *
  3432. * \include Frame_rotationAngle.txt
  3433. *
  3434. * The Leap Motion software derives frame rotation from the relative change in position and
  3435. * orientation of all objects detected in the field of view.
  3436. *
  3437. * If either this frame or sinceFrame is an invalid Frame object, then the
  3438. * angle of rotation is zero.
  3439. *
  3440. * @param sinceFrame The starting frame for computing the relative rotation.
  3441. * @returns A positive value containing the heuristically determined
  3442. * rotational change between the current frame and that specified in the
  3443. * sinceFrame parameter.
  3444. * @since 1.0
  3445. */
  3446. LEAP_EXPORT float rotationAngle(const Frame& sinceFrame) const;
  3447. /**
  3448. * The angle of rotation around the specified axis derived from the overall
  3449. * rotational motion between the current frame and the specified frame.
  3450. *
  3451. * The returned angle is expressed in radians measured clockwise around the
  3452. * rotation axis (using the right-hand rule) between the start and end frames.
  3453. * The value is always between -pi and pi radians (-180 and 180 degrees).
  3454. *
  3455. * \include Frame_rotationAngle_axis.txt
  3456. *
  3457. * The Leap Motion software derives frame rotation from the relative change in position and
  3458. * orientation of all objects detected in the field of view.
  3459. *
  3460. * If either this frame or sinceFrame is an invalid Frame object, then the
  3461. * angle of rotation is zero.
  3462. *
  3463. * @param sinceFrame The starting frame for computing the relative rotation.
  3464. * @param axis The axis to measure rotation around.
  3465. * @returns A value containing the heuristically determined rotational
  3466. * change between the current frame and that specified in the sinceFrame
  3467. * parameter around the given axis.
  3468. * @since 1.0
  3469. */
  3470. LEAP_EXPORT float rotationAngle(const Frame& sinceFrame, const Vector& axis) const;
  3471. /**
  3472. * The transform matrix expressing the rotation derived from the overall
  3473. * rotational motion between the current frame and the specified frame.
  3474. *
  3475. * \include Frame_rotationMatrix.txt
  3476. *
  3477. * The Leap Motion software derives frame rotation from the relative change in position and
  3478. * orientation of all objects detected in the field of view.
  3479. *
  3480. * If either this frame or sinceFrame is an invalid Frame object, then this
  3481. * method returns an identity matrix.
  3482. *
  3483. * @param sinceFrame The starting frame for computing the relative rotation.
  3484. * @returns A transformation Matrix containing the heuristically determined
  3485. * rotational change between the current frame and that specified in the
  3486. * sinceFrame parameter.
  3487. * @since 1.0
  3488. */
  3489. LEAP_EXPORT Matrix rotationMatrix(const Frame& sinceFrame) const;
  3490. /**
  3491. * The estimated probability that the overall motion between the current
  3492. * frame and the specified frame is intended to be a rotating motion.
  3493. *
  3494. * \include Frame_rotationProbability.txt
  3495. *
  3496. * If either this frame or sinceFrame is an invalid Frame object, then this
  3497. * method returns zero.
  3498. *
  3499. * @param sinceFrame The starting frame for computing the relative rotation.
  3500. * @returns A value between 0 and 1 representing the estimated probability
  3501. * that the overall motion between the current frame and the specified frame
  3502. * is intended to be a rotating motion.
  3503. * @since 1.0
  3504. */
  3505. LEAP_EXPORT float rotationProbability(const Frame& sinceFrame) const;
  3506. /**
  3507. * The scale factor derived from the overall motion between the current frame
  3508. * and the specified frame.
  3509. *
  3510. * The scale factor is always positive. A value of 1.0 indicates no
  3511. * scaling took place. Values between 0.0 and 1.0 indicate contraction
  3512. * and values greater than 1.0 indicate expansion.
  3513. *
  3514. * \include Frame_scaleFactor.txt
  3515. *
  3516. * The Leap Motion software derives scaling from the relative inward or outward motion of
  3517. * all objects detected in the field of view (independent of translation
  3518. * and rotation).
  3519. *
  3520. * If either this frame or sinceFrame is an invalid Frame object, then this
  3521. * method returns 1.0.
  3522. *
  3523. * @param sinceFrame The starting frame for computing the relative scaling.
  3524. * @returns A positive value representing the heuristically determined
  3525. * scaling change ratio between the current frame and that specified in the
  3526. * sinceFrame parameter.
  3527. * @since 1.0
  3528. */
  3529. LEAP_EXPORT float scaleFactor(const Frame& sinceFrame) const;
  3530. /**
  3531. * The estimated probability that the overall motion between the current
  3532. * frame and the specified frame is intended to be a scaling motion.
  3533. *
  3534. * \include Frame_scaleProbability.txt
  3535. *
  3536. * If either this frame or sinceFrame is an invalid Frame object, then this
  3537. * method returns zero.
  3538. *
  3539. * @param sinceFrame The starting frame for computing the relative scaling.
  3540. * @returns A value between 0 and 1 representing the estimated probability
  3541. * that the overall motion between the current frame and the specified frame
  3542. * is intended to be a scaling motion.
  3543. * @since 1.0
  3544. */
  3545. LEAP_EXPORT float scaleProbability(const Frame& sinceFrame) const;
  3546. /**
  3547. * The current InteractionBox for the frame. See the InteractionBox class
  3548. * documentation for more details on how this class should be used.
  3549. *
  3550. * \include Frame_interactionBox.txt
  3551. *
  3552. * @returns The current InteractionBox object.
  3553. * @since 1.0
  3554. */
  3555. LEAP_EXPORT InteractionBox interactionBox() const;
  3556. /**
  3557. * The instantaneous framerate.
  3558. *
  3559. * The rate at which the Leap Motion software is providing frames of data
  3560. * (in frames per second). The framerate can fluctuate depending on available computing
  3561. * resources, activity within the device field of view, software tracking settings,
  3562. * and other factors.
  3563. *
  3564. * \include Frame_currentFramesPerSecond.txt
  3565. *
  3566. * @returns An estimate of frames per second of the Leap Motion Controller.
  3567. * @since 1.0
  3568. */
  3569. LEAP_EXPORT float currentFramesPerSecond() const;
  3570. /**
  3571. * Reports whether this Frame instance is valid.
  3572. *
  3573. * A valid Frame is one generated by the Leap::Controller object that contains
  3574. * tracking data for all detected entities. An invalid Frame contains no
  3575. * actual tracking data, but you can call its functions without risk of a
  3576. * null pointer exception. The invalid Frame mechanism makes it more
  3577. * convenient to track individual data across the frame history. For example,
  3578. * you can invoke:
  3579. *
  3580. * \include Frame_Valid_Chain.txt
  3581. *
  3582. * for an arbitrary Frame history value, "n", without first checking whether
  3583. * frame(n) returned a null object. (You should still check that the
  3584. * returned Finger instance is valid.)
  3585. *
  3586. * @returns True, if this is a valid Frame object; false otherwise.
  3587. * @since 1.0
  3588. */
  3589. LEAP_EXPORT bool isValid() const;
  3590. /**
  3591. * Returns an invalid Frame object.
  3592. *
  3593. * You can use the instance returned by this function in comparisons testing
  3594. * whether a given Frame instance is valid or invalid. (You can also use the
  3595. * Frame::isValid() function.)
  3596. *
  3597. * \include Frame_Invalid_Demo.txt
  3598. *
  3599. * @returns The invalid Frame instance.
  3600. * @since 1.0
  3601. */
  3602. LEAP_EXPORT static const Frame& invalid();
  3603. /**
  3604. * Compare Frame object equality.
  3605. *
  3606. * \include Frame_operator_equals.txt
  3607. *
  3608. * Two Frame objects are equal if and only if both Frame objects represent
  3609. * the exact same frame of tracking data and both Frame objects are valid.
  3610. * @since 1.0
  3611. */
  3612. LEAP_EXPORT bool operator==(const Frame&) const;
  3613. /**
  3614. * Compare Frame object inequality.
  3615. *
  3616. * \include Frame_operator_not_equals.txt
  3617. *
  3618. * Two Frame objects are equal if and only if both Frame objects represent
  3619. * the exact same frame of tracking data and both Frame objects are valid.
  3620. * @since 1.0
  3621. */
  3622. LEAP_EXPORT bool operator!=(const Frame&) const;
  3623. /**
  3624. * Writes a brief, human readable description of the Frame object to an output stream.
  3625. *
  3626. * \include Frame_operator_stream.txt
  3627. *
  3628. * @since 1.0
  3629. */
  3630. LEAP_EXPORT friend std::ostream& operator<<(std::ostream&, const Frame&);
  3631. /**
  3632. * A string containing a brief, human readable description of the Frame object.
  3633. *
  3634. * @returns A description of the Frame as a string.
  3635. * @since 1.0
  3636. */
  3637. LEAP_EXPORT std::string toString() const;
  3638. };
  3639. /**
  3640. * The Config class provides access to Leap Motion system configuration information.
  3641. *
  3642. * You can get and set gesture configuration parameters using the Config object
  3643. * obtained from a connected Controller object. The key strings required to
  3644. * identify a configuration parameter include:
  3645. *
  3646. * Key string | Value type | Default value | Units
  3647. * -----------|------------|---------------|------
  3648. * Gesture.Circle.MinRadius | float | 5.0 | mm
  3649. * Gesture.Circle.MinArc | float | 1.5*pi | radians
  3650. * Gesture.Swipe.MinLength | float | 150 | mm
  3651. * Gesture.Swipe.MinVelocity | float | 1000 | mm/s
  3652. * Gesture.KeyTap.MinDownVelocity | float | 50 | mm/s
  3653. * Gesture.KeyTap.HistorySeconds | float | 0.1 | s
  3654. * Gesture.KeyTap.MinDistance | float | 3.0 | mm
  3655. * Gesture.ScreenTap.MinForwardVelocity | float | 50 | mm/s
  3656. * Gesture.ScreenTap.HistorySeconds | float | 0.1 | s
  3657. * Gesture.ScreenTap.MinDistance | float | 5.0 | mm
  3658. *
  3659. * After setting a configuration value, you must call the Config::save method
  3660. * to commit the changes. The configuration value changes are not persistent;
  3661. * your application needs to set the values everytime it runs.
  3662. *
  3663. * @see CircleGesture
  3664. * @see KeyTapGesture
  3665. * @see ScreenTapGesture
  3666. * @see SwipeGesture
  3667. * @since 1.0
  3668. */
  3669. class Config : public Interface {
  3670. public:
  3671. /**
  3672. * Constructs a Config object.
  3673. * Do not create your own Config objects. Get a Config object using
  3674. * the Controller::config() function.
  3675. *
  3676. * \include Config_Constructor.txt
  3677. *
  3678. * @since 1.0
  3679. */
  3680. LEAP_EXPORT Config();
  3681. /**
  3682. * Enumerates the possible data types for configuration values.
  3683. *
  3684. * The Config::type() function returns an item from the ValueType enumeration.
  3685. * @since 1.0
  3686. */
  3687. enum ValueType {
  3688. /**
  3689. * The data type is unknown.
  3690. * @since 1.0
  3691. */
  3692. TYPE_UNKNOWN = 0,
  3693. /**
  3694. * A boolean value.
  3695. * @since 1.0
  3696. */
  3697. TYPE_BOOLEAN = 1,
  3698. /**
  3699. * A 32-bit integer.
  3700. * @since 1.0
  3701. */
  3702. TYPE_INT32 = 2,
  3703. /**
  3704. * A floating-point number.
  3705. * @since 1.0
  3706. */
  3707. TYPE_FLOAT = 6,
  3708. /**
  3709. * A string of characters.
  3710. * @since 1.0
  3711. */
  3712. TYPE_STRING = 8
  3713. };
  3714. /**
  3715. * Reports the natural data type for the value related to the specified key.
  3716. *
  3717. * \include Config_type.txt
  3718. *
  3719. * @param key The key for the looking up the value in the configuration dictionary.
  3720. * @returns The native data type of the value, that is, the type that does not
  3721. * require a data conversion.
  3722. * @since 1.0
  3723. */
  3724. LEAP_EXPORT ValueType type(const std::string& key) const;
  3725. /**
  3726. * Gets the boolean representation for the specified key.
  3727. *
  3728. * \include Config_getBool.txt
  3729. *
  3730. * @since 1.0
  3731. */
  3732. LEAP_EXPORT bool getBool(const std::string& key) const;
  3733. /** Sets the boolean representation for the specified key.
  3734. *
  3735. * \include Config_setBool.txt
  3736. *
  3737. * @returns true on success, false on failure.
  3738. * @since 1.0
  3739. */
  3740. LEAP_EXPORT bool setBool(const std::string& key, bool value);
  3741. /**
  3742. * Gets the 32-bit integer representation for the specified key.
  3743. *
  3744. * \include Config_getInt32.txt
  3745. *
  3746. * @since 1.0
  3747. */
  3748. LEAP_EXPORT int32_t getInt32(const std::string& key) const;
  3749. /** Sets the 32-bit integer representation for the specified key.
  3750. *
  3751. * \include Config_setInt32.txt
  3752. *
  3753. * @returns true on success, false on failure.
  3754. * @since 1.0
  3755. */
  3756. LEAP_EXPORT bool setInt32(const std::string& key, int32_t value);
  3757. /**
  3758. * Gets the floating point representation for the specified key.
  3759. *
  3760. * \include Config_getFloat.txt
  3761. *
  3762. * @since 1.0
  3763. */
  3764. LEAP_EXPORT float getFloat(const std::string& key) const;
  3765. /** Sets the floating point representation for the specified key.
  3766. *
  3767. * \include Config_setFloat.txt
  3768. *
  3769. * @returns true on success, false on failure.
  3770. * @since 1.0
  3771. */
  3772. LEAP_EXPORT bool setFloat(const std::string& key, float value);
  3773. /**
  3774. * Gets the string representation for the specified key.
  3775. *
  3776. * \include Config_getString.txt
  3777. *
  3778. * @since 1.0
  3779. */
  3780. LEAP_EXPORT std::string getString(const std::string& key) const;
  3781. /** Sets the string representation for the specified key.
  3782. *
  3783. * \include Config_setString.txt
  3784. *
  3785. * @returns true on success, false on failure.
  3786. * @since 1.0
  3787. */
  3788. LEAP_EXPORT bool setString(const std::string& key, const std::string& value);
  3789. /**
  3790. * Saves the current state of the config.
  3791. *
  3792. * Call ``save()`` after making a set of configuration changes. The
  3793. * ``save()`` function transfers the configuration changes to the Leap Motion
  3794. * service. The configuration value changes are not persistent; your
  3795. * application must set the values everytime it runs.
  3796. *
  3797. * \include Config_save.txt
  3798. *
  3799. * @returns true on success, false on failure.
  3800. * @since 1.0
  3801. */
  3802. LEAP_EXPORT bool save();
  3803. };
  3804. /**
  3805. * The Controller class is your main interface to the Leap Motion Controller.
  3806. *
  3807. * Create an instance of this Controller class to access frames of tracking
  3808. * data and configuration information. Frame data can be polled at any time
  3809. * using the Controller::frame() function. Call frame() or frame(0) to get the
  3810. * most recent frame. Set the history parameter to a positive integer to access
  3811. * previous frames. A controller stores up to 60 frames in its frame history.
  3812. *
  3813. * Polling is an appropriate strategy for applications which already have an
  3814. * intrinsic update loop, such as a game. You can also add an instance of a
  3815. * subclass of Leap::Listener to the controller to handle events as they occur.
  3816. * The Controller dispatches events to the listener upon initialization and exiting,
  3817. * on connection changes, when the application gains and loses the OS input focus,
  3818. * and when a new frame of tracking data is available.
  3819. * When these events occur, the controller object invokes the appropriate
  3820. * callback function defined in your subclass of Listener.
  3821. *
  3822. * To access frames of tracking data as they become available:
  3823. *
  3824. * 1. Implement a subclass of the Listener class and override the
  3825. * Listener::onFrame() function.
  3826. * 2. In your Listener::onFrame() function, call the Controller::frame()
  3827. * function to access the newest frame of tracking data.
  3828. * 3. To start receiving frames, create a Controller object and add an instance
  3829. * of the Listener subclass to the Controller::addListener() function.
  3830. *
  3831. * When an instance of a Listener subclass is added to a Controller object,
  3832. * it calls the Listener::onInit() function when the listener is ready for use.
  3833. * When a connection is established between the controller and the Leap Motion software,
  3834. * the controller calls the Listener::onConnect() function. At this point, your
  3835. * application will start receiving frames of data. The controller calls the
  3836. * Listener::onFrame() function each time a new frame is available. If the
  3837. * controller loses its connection with the Leap Motion software or device for any
  3838. * reason, it calls the Listener::onDisconnect() function. If the listener is
  3839. * removed from the controller or the controller is destroyed, it calls the
  3840. * Listener::onExit() function. At that point, unless the listener is added to
  3841. * another controller again, it will no longer receive frames of tracking data.
  3842. *
  3843. * The Controller object is multithreaded and calls the Listener functions on
  3844. * its own thread, not on an application thread.
  3845. * @since 1.0
  3846. */
  3847. class Controller : public Interface {
  3848. public:
  3849. // For internal use only.
  3850. Controller(ControllerImplementation*);
  3851. /**
  3852. * Constructs a Controller object.
  3853. *
  3854. * When creating a Controller object, you may optionally pass in a
  3855. * reference to an instance of a subclass of Leap::Listener. Alternatively,
  3856. * you may add a listener using the Controller::addListener() function.
  3857. *
  3858. * @since 1.0
  3859. */
  3860. LEAP_EXPORT Controller();
  3861. LEAP_EXPORT virtual ~Controller();
  3862. /**
  3863. * Constructs a Controller object.
  3864. *
  3865. * When creating a Controller object, you may optionally pass in a
  3866. * reference to an instance of a subclass of Leap::Listener. Alternatively,
  3867. * you may add a listener using the Controller::addListener() function.
  3868. *
  3869. * \include Controller_Controller.txt
  3870. *
  3871. * @param listener An instance of Leap::Listener implementing the callback
  3872. * functions for the Leap Motion events you want to handle in your application.
  3873. * @since 1.0
  3874. */
  3875. LEAP_EXPORT Controller(Listener& listener);
  3876. /**
  3877. * Reports whether this Controller is connected to the Leap Motion service and
  3878. * the Leap Motion hardware is plugged in.
  3879. *
  3880. * When you first create a Controller object, isConnected() returns false.
  3881. * After the controller finishes initializing and connects to the Leap Motion
  3882. * software and if the Leap Motion hardware is plugged in, isConnected() returns true.
  3883. *
  3884. * You can either handle the onConnect event using a Listener instance or
  3885. * poll the isConnected() function if you need to wait for your
  3886. * application to be connected to the Leap Motion software before performing some other
  3887. * operation.
  3888. *
  3889. * \include Controller_isConnected.txt
  3890. * @returns True, if connected; false otherwise.
  3891. * @since 1.0
  3892. */
  3893. LEAP_EXPORT bool isConnected() const;
  3894. /**
  3895. * Reports whether this application is the focused, foreground application.
  3896. *
  3897. * By default, your application only receives tracking information from
  3898. * the Leap Motion controller when it has the operating system input focus.
  3899. * To receive tracking data when your application is in the background,
  3900. * the background frames policy flag must be set.
  3901. *
  3902. * \include Controller_hasFocus.txt
  3903. *
  3904. * @returns True, if application has focus; false otherwise.
  3905. *
  3906. * @see Controller::setPolicyFlags()
  3907. * @since 1.0
  3908. */
  3909. LEAP_EXPORT bool hasFocus() const;
  3910. /**
  3911. * The supported controller policies.
  3912. *
  3913. * Currently, the only supported policy is the background frames policy,
  3914. * which determines whether your application receives frames of tracking
  3915. * data when it is not the focused, foreground application.
  3916. * @since 1.0
  3917. */
  3918. enum PolicyFlag {
  3919. /**
  3920. * The default policy.
  3921. * @since 1.0
  3922. */
  3923. POLICY_DEFAULT = 0,
  3924. /**
  3925. * Receive background frames.
  3926. * @since 1.0
  3927. */
  3928. POLICY_BACKGROUND_FRAMES = (1 << 0)
  3929. };
  3930. /**
  3931. * Gets the active policy settings.
  3932. *
  3933. * Use this function to determine the current policy state.
  3934. * Keep in mind that setting a policy flag is asynchronous, so changes are
  3935. * not effective immediately after calling setPolicyFlag(). In addition, a
  3936. * policy request can be declined by the user. You should always set the
  3937. * policy flags required by your application at startup and check that the
  3938. * policy change request was successful after an appropriate interval.
  3939. *
  3940. * If the controller object is not connected to the Leap Motion software, then the default
  3941. * policy state is returned.
  3942. *
  3943. * \include Controller_policyFlags.txt
  3944. *
  3945. * @returns The current policy flags.
  3946. * @since 1.0
  3947. */
  3948. LEAP_EXPORT PolicyFlag policyFlags() const;
  3949. /**
  3950. * Requests a change in policy.
  3951. *
  3952. * A request to change a policy is subject to user approval and a policy
  3953. * can be changed by the user at any time (using the Leap Motion settings dialog).
  3954. * The desired policy flags must be set every time an application runs.
  3955. *
  3956. * Policy changes are completed asynchronously and, because they are subject
  3957. * to user approval, may not complete successfully. Call
  3958. * Controller::policyFlags() after a suitable interval to test whether
  3959. * the change was accepted.
  3960. *
  3961. * Currently, the background frames policy is the only policy supported.
  3962. * The background frames policy determines whether an application
  3963. * receives frames of tracking data while in the background. By
  3964. * default, the Leap Motion software only sends tracking data to the foreground application.
  3965. * Only applications that need this ability should request the background
  3966. * frames policy.
  3967. *
  3968. * At this time, you can use the Leap Motion Settings dialog to
  3969. * globally enable or disable the background frames policy. However,
  3970. * each application that needs tracking data while in the background
  3971. * must also set the policy flag using this function.
  3972. *
  3973. * This function can be called before the Controller object is connected,
  3974. * but the request will be sent to the Leap Motion software after the Controller connects.
  3975. *
  3976. * \include Controller_setPolicyFlags.txt
  3977. *
  3978. * @param flags A PolicyFlag value indicating the policies to request.
  3979. * @since 1.0
  3980. */
  3981. LEAP_EXPORT void setPolicyFlags(PolicyFlag flags) const;
  3982. /**
  3983. * Adds a listener to this Controller.
  3984. *
  3985. * The Controller dispatches Leap Motion events to each associated listener. The
  3986. * order in which listener callback functions are invoked is arbitrary. If
  3987. * you pass a listener to the Controller's constructor function, it is
  3988. * automatically added to the list and can be removed with the
  3989. * Controller::removeListener() function.
  3990. *
  3991. * \include Controller_addListener.txt
  3992. *
  3993. * @param listener A subclass of Leap::Listener implementing the callback
  3994. * functions for the Leap Motion events you want to handle in your application.
  3995. * @returns Whether or not the listener was successfully added to the list
  3996. * of listeners.
  3997. * @since 1.0
  3998. */
  3999. LEAP_EXPORT bool addListener(Listener& listener);
  4000. /**
  4001. * Remove a listener from the list of listeners that will receive Leap Motion
  4002. * events. A listener must be removed if its lifetime is shorter than the
  4003. * controller to which it is listening.
  4004. *
  4005. * \include Controller_removeListener.txt
  4006. *
  4007. * @param listener The listener to remove.
  4008. * @returns Whether or not the listener was successfully removed from the
  4009. * list of listeners.
  4010. * @since 1.0
  4011. */
  4012. LEAP_EXPORT bool removeListener(Listener& listener);
  4013. /**
  4014. * Returns a frame of tracking data from the Leap Motion software. Use the optional
  4015. * history parameter to specify which frame to retrieve. Call frame() or
  4016. * frame(0) to access the most recent frame; call frame(1) to access the
  4017. * previous frame, and so on. If you use a history value greater than the
  4018. * number of stored frames, then the controller returns an invalid frame.
  4019. *
  4020. * \include Controller_Frame_1.txt
  4021. *
  4022. * You can call this function in your Listener implementation to get frames at the
  4023. * Leap Motion frame rate:
  4024. *
  4025. * \include Controller_Listener_onFrame.txt
  4026. * @param history The age of the frame to return, counting backwards from
  4027. * the most recent frame (0) into the past and up to the maximum age (59).
  4028. * @returns The specified frame; or, if no history parameter is specified,
  4029. * the newest frame. If a frame is not available at the specified history
  4030. * position, an invalid Frame is returned.
  4031. * @since 1.0
  4032. */
  4033. LEAP_EXPORT Frame frame(int history = 0) const;
  4034. /**
  4035. * Returns a Config object, which you can use to query the Leap Motion system for
  4036. * configuration information.
  4037. *
  4038. * \include Controller_config.txt
  4039. *
  4040. * @since 1.0
  4041. */
  4042. LEAP_EXPORT Config config() const;
  4043. /**
  4044. * The list of currently attached and recognized Leap Motion controller devices.
  4045. *
  4046. * The Device objects in the list describe information such as the range and
  4047. * tracking volume.
  4048. *
  4049. * \include Controller_devices.txt
  4050. *
  4051. * Currently, the Leap Motion Controller only recognizes a single device at a time.
  4052. * @since 1.0
  4053. */
  4054. LEAP_EXPORT DeviceList devices() const;
  4055. /*
  4056. * The Screen and ScreenList classes are currently unsupported.
  4057. *
  4058. * We are re-evaluating this feature due to the cumbersome location process
  4059. * required to use it and the amount of confusion about the feature's purpose.
  4060. *
  4061. * The list of screens whose positions have been identified by using the
  4062. * Leap Motion Screen Locator.
  4063. *
  4064. * The list always contains at least one entry representing the default
  4065. * screen. If the user has not registered the location of this default
  4066. * screen, then the coordinates, directions, and other values reported by
  4067. * the functions in its Screen object will not be accurate. Other monitor
  4068. * screens only appear in the list if their positions have been registered
  4069. * using the Leap Motion Screen Locator.
  4070. *
  4071. * A Screen object represents the position and orientation of a display
  4072. * monitor screen within the Leap Motion coordinate system.
  4073. * For example, if the screen location is known, you can get Leap Motion coordinates
  4074. * for the bottom-left corner of the screen. Registering the screen
  4075. * location also allows the Leap Motion software to calculate the point on the screen at
  4076. * which a finger or tool is pointing.
  4077. *
  4078. * A user can run the Screen Locator tool from the Leap Motion
  4079. * Settings dialog. Avoid assuming that a screen location is known or that
  4080. * an existing position is still correct. The registered position is only
  4081. * valid as long as the relative position of the Leap Motion Controller and the
  4082. * monitor screen remain constant.
  4083. *
  4084. * \include Screen_Closest_1.txt
  4085. *
  4086. * @returns ScreenList A list containing the screens whose positions have
  4087. * been registered by the user using the Screen Locator tool.
  4088. * The list always contains at least one entry representing the default
  4089. * monitor. If the user has not run the Screen Locator or has moved the Leap
  4090. * Motion device or screen since running it, the Screen object for this entry
  4091. * only contains default values.
  4092. * @since 1.0
  4093. */
  4094. LEAP_EXPORT ScreenList locatedScreens() const;
  4095. /**
  4096. * Enables or disables reporting of a specified gesture type.
  4097. *
  4098. * By default, all gesture types are disabled. When disabled, gestures of the
  4099. * disabled type are never reported and will not appear in the frame
  4100. * gesture list.
  4101. *
  4102. * \include Controller_enableGesture.txt
  4103. *
  4104. * As a performance optimization, only enable recognition for the types
  4105. * of movements that you use in your application.
  4106. *
  4107. * @param type The type of gesture to enable or disable. Must be a
  4108. * member of the Gesture::Type enumeration.
  4109. * @param enable True, to enable the specified gesture type; False,
  4110. * to disable.
  4111. * @see Controller::isGestureEnabled()
  4112. * @since 1.0
  4113. */
  4114. LEAP_EXPORT void enableGesture(Gesture::Type type, bool enable = true) const;
  4115. /**
  4116. * Reports whether the specified gesture type is enabled.
  4117. *
  4118. * \include Controller_isGestureEnabled.txt
  4119. *
  4120. * @return True, if the specified type is enabled; false, otherwise.
  4121. * @see Controller::enableGesture()
  4122. * @since 1.0
  4123. */
  4124. LEAP_EXPORT bool isGestureEnabled(Gesture::Type type) const;
  4125. };
  4126. /**
  4127. * The Listener class defines a set of callback functions that you can
  4128. * override in a subclass to respond to events dispatched by the Controller object.
  4129. *
  4130. * To handle Leap Motion events, create an instance of a Listener subclass and assign
  4131. * it to the Controller instance. The Controller calls the relevant Listener
  4132. * callback function when an event occurs, passing in a reference to itself.
  4133. * You do not have to implement callbacks for events you do not want to handle.
  4134. *
  4135. * The Controller object calls these Listener functions from a thread created
  4136. * by the Leap Motion library, not the thread used to create or set the Listener instance.
  4137. * @since 1.0
  4138. */
  4139. class Listener {
  4140. public:
  4141. /**
  4142. * Constructs a Listener object.
  4143. * @since 1.0
  4144. */
  4145. LEAP_EXPORT Listener() {}
  4146. /**
  4147. * Destroys this Listener object.
  4148. */
  4149. LEAP_EXPORT virtual ~Listener() {}
  4150. /**
  4151. * Called once, when this Listener object is newly added to a Controller.
  4152. *
  4153. * \include Listener_onInit.txt
  4154. *
  4155. * @param controller The Controller object invoking this callback function.
  4156. * @since 1.0
  4157. */
  4158. LEAP_EXPORT virtual void onInit(const Controller&) {}
  4159. /**
  4160. * Called when the Controller object connects to the Leap Motion software and
  4161. * the Leap Motion hardware device is plugged in,
  4162. * or when this Listener object is added to a Controller that is already connected.
  4163. *
  4164. * \include Listener_onConnect.txt
  4165. *
  4166. * @param controller The Controller object invoking this callback function.
  4167. * @since 1.0
  4168. */
  4169. LEAP_EXPORT virtual void onConnect(const Controller&) {}
  4170. /**
  4171. * Called when the Controller object disconnects from the Leap Motion software or
  4172. * the Leap Motion hardware is unplugged.
  4173. * The controller can disconnect when the Leap Motion device is unplugged, the
  4174. * user shuts the Leap Motion software down, or the Leap Motion software encounters an
  4175. * unrecoverable error.
  4176. *
  4177. * \include Listener_onDisconnect.txt
  4178. *
  4179. * Note: When you launch a Leap-enabled application in a debugger, the
  4180. * Leap Motion library does not disconnect from the application. This is to allow
  4181. * you to step through code without losing the connection because of time outs.
  4182. *
  4183. * @param controller The Controller object invoking this callback function.
  4184. * @since 1.0
  4185. */
  4186. LEAP_EXPORT virtual void onDisconnect(const Controller&) {}
  4187. /**
  4188. * Called when this Listener object is removed from the Controller
  4189. * or the Controller instance is destroyed.
  4190. *
  4191. * \include Listener_onExit.txt
  4192. *
  4193. * @param controller The Controller object invoking this callback function.
  4194. * @since 1.0
  4195. */
  4196. LEAP_EXPORT virtual void onExit(const Controller&) {}
  4197. /**
  4198. * Called when a new frame of hand and finger tracking data is available.
  4199. * Access the new frame data using the Controller::frame() function.
  4200. *
  4201. * \include Listener_onFrame.txt
  4202. *
  4203. * Note, the Controller skips any pending onFrame events while your
  4204. * onFrame handler executes. If your implementation takes too long to return,
  4205. * one or more frames can be skipped. The Controller still inserts the skipped
  4206. * frames into the frame history. You can access recent frames by setting
  4207. * the history parameter when calling the Controller::frame() function.
  4208. * You can determine if any pending onFrame events were skipped by comparing
  4209. * the ID of the most recent frame with the ID of the last received frame.
  4210. *
  4211. * @param controller The Controller object invoking this callback function.
  4212. * @since 1.0
  4213. */
  4214. LEAP_EXPORT virtual void onFrame(const Controller&) {}
  4215. /**
  4216. * Called when this application becomes the foreground application.
  4217. *
  4218. * Only the foreground application receives tracking data from the Leap
  4219. * Motion Controller. This function is only called when the controller
  4220. * object is in a connected state.
  4221. *
  4222. * \include Listener_onFocusGained.txt
  4223. *
  4224. * @param controller The Controller object invoking this callback function.
  4225. * @since 1.0
  4226. */
  4227. LEAP_EXPORT virtual void onFocusGained(const Controller&) {}
  4228. /**
  4229. * Called when this application loses the foreground focus.
  4230. *
  4231. * Only the foreground application receives tracking data from the Leap
  4232. * Motion Controller. This function is only called when the controller
  4233. * object is in a connected state.
  4234. *
  4235. * \include Listener_onFocusLost.txt
  4236. *
  4237. * @param controller The Controller object invoking this callback function.
  4238. * @since 1.0
  4239. */
  4240. LEAP_EXPORT virtual void onFocusLost(const Controller&) {}
  4241. };
  4242. }
  4243. #endif // __Leap_h__