Leviathan  0.8.0.0
Leviathan game engine
Leviathan::LeapManager Class Reference

#include <LeapManager.h>

Public Member Functions

DLLEXPORT LeapManager (Engine *engineinstance)
 
virtual DLLEXPORT ~LeapManager ()
 
virtual DLLEXPORT bool Init ()
 
virtual DLLEXPORT void Release ()
 
DLLEXPORT void OnTick (const int &mspassed)
 

Protected Attributes

int TimeSinceReset
 
EngineEngineAccess
 

Detailed Description

Definition at line 19 of file LeapManager.h.

Constructor & Destructor Documentation

◆ LeapManager()

DLLEXPORT Leviathan::LeapManager::LeapManager ( Engine engineinstance)

Definition at line 11 of file LeapManager.cpp.

11  :
12  EngineAccess(engineinstance), MainController(NULL), MainListener(NULL)
13 {
14 #ifndef LEAP_USE_ASYNC
15  LastFrameID = 0;
16 #endif //LEAP_USE_ASYNC
17 
18  // Default values to gesture variables //
19  TimeSinceReset = 0;
20 }

◆ ~LeapManager()

DLLEXPORT Leviathan::LeapManager::~LeapManager ( )
virtual

Definition at line 22 of file LeapManager.cpp.

22  {
23 }

Member Function Documentation

◆ Init()

DLLEXPORT bool Leviathan::LeapManager::Init ( )
virtual

Definition at line 25 of file LeapManager.cpp.

25  {
26  // Initialize leap interface //
27  MainController = new Controller();
28 
29  // Create listener //
30  MainListener = new LeapListener(this);
31 
32 #ifdef LEAP_USE_ASYNC
33  // Start listening //
34  if(!MainController->addListener(*MainListener)){
35 
36  // No leap controller! //
37  Logger::Get()->Warning("LeapManager: Failed to start listening for Leap motion controller");
38  }
39 #endif //LEAP_USE_ASYNC
40 
41  return true;
42 }
DLLEXPORT void Warning(const std::string &data) override
Definition: Logger.cpp:190
static DLLEXPORT Logger * Get()
Definition: Logger.cpp:106

◆ OnTick()

DLLEXPORT void Leviathan::LeapManager::OnTick ( const int &  mspassed)

Definition at line 58 of file LeapManager.cpp.

58  {
59  // Add to time //
60  TimeSinceReset += mspassed;
61 
62 #ifndef LEAP_USE_ASYNC
63  // Poll frame //
64  const auto frame = MainController->frame();
65 
66  auto id = frame.id();
67 
68  if(id != LastFrameID){
69 
70  LastFrameID = id;
71  MainListener->HandleFrame(frame, *MainController);
72  }
73 
74 #endif //LEAP_USE_ASYNC
75 
76  // Check for action //
77 
78 
79 
81  // Reset time //
82  TimeSinceReset = 0;
83 
84  }
85 }
void HandleFrame(const Leap::Frame &frame, const Leap::Controller &control)
Handles a frame retrieved from the Leap or notified by frame event.
#define GESTURESTATERESETTIME
Definition: LeapManager.h:9

◆ Release()

DLLEXPORT void Leviathan::LeapManager::Release ( )
virtual

Definition at line 44 of file LeapManager.cpp.

44  {
45  // We need to unregister listener //
46  if(MainListener){
47 #ifdef LEAP_USE_ASYNC
48  MainController->removeListener(*MainListener);
49  Logger::Get()->Info("LeapManager: unconnected from Leap");
50 #endif //LEAP_USE_ASYNC
51  }
52 
53  // Unallocate //
54  SAFE_DELETE(MainListener);
55  SAFE_DELETE(MainController);
56 }
DLLEXPORT void Info(const std::string &data) override
Definition: Logger.cpp:164
static DLLEXPORT Logger * Get()
Definition: Logger.cpp:106
#define SAFE_DELETE(x)
Definition: Define.h:116

Member Data Documentation

◆ EngineAccess

Engine* Leviathan::LeapManager::EngineAccess
protected

Definition at line 48 of file LeapManager.h.

◆ TimeSinceReset

int Leviathan::LeapManager::TimeSinceReset
protected

Definition at line 38 of file LeapManager.h.


The documentation for this class was generated from the following files: