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 {}

Member Function Documentation

◆ Init()

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

Definition at line 24 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! //
38  "LeapManager: Failed to start listening for Leap motion controller");
39  }
40 #endif // LEAP_USE_ASYNC
41 
42  return true;
43 }
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 60 of file LeapManager.cpp.

61 {
62  // Add to time //
63  TimeSinceReset += mspassed;
64 
65 #ifndef LEAP_USE_ASYNC
66  // Poll frame //
67  const auto frame = MainController->frame();
68 
69  auto id = frame.id();
70 
71  if(id != LastFrameID) {
72 
73  LastFrameID = id;
74  MainListener->HandleFrame(frame, *MainController);
75  }
76 
77 #endif // LEAP_USE_ASYNC
78 
79  // Check for action //
80 
81 
82 
84  // Reset time //
85  TimeSinceReset = 0;
86  }
87 }
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 45 of file LeapManager.cpp.

46 {
47  // We need to unregister listener //
48  if(MainListener) {
49 #ifdef LEAP_USE_ASYNC
50  MainController->removeListener(*MainListener);
51  Logger::Get()->Info("LeapManager: disconnected from Leap");
52 #endif // LEAP_USE_ASYNC
53  }
54 
55  // Unallocate //
56  SAFE_DELETE(MainListener);
57  SAFE_DELETE(MainController);
58 }
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:141

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: