Simulated Reality SDK 7500c78d v1.30.2.51085 2024-04-26T11:23:03Z
Stable
handtracker.h
Go to the documentation of this file.
1
10#pragma once
11
13
14#include <map>
15#include <thread>
16#include <mutex>
17#include <string>
18
19#include "handpose.h"
20#include "handposestream.h"
21#include "handevent.h"
22#include "handeventstream.h"
23
24#ifdef WIN32
25# ifdef COMPILING_DLL_SimulatedRealityHandTrackers
26# define DIMENCOSR_API __declspec(dllexport)
27# else
28# define DIMENCOSR_API __declspec(dllimport)
29# endif
30#else
31# define DIMENCOSR_API
32#endif
33
34namespace SR {
35
47
48public:
55 static HandTracker* create(SRContext &context);
56
61 virtual std::shared_ptr<HandPoseStream> openHandPoseStream(HandPoseListener* listener) = 0;
67 virtual std::shared_ptr<HandPoseStream> openHandPoseStream(HandPoseListener* listener, uint64_t handIdentifier) = 0;
74 virtual std::shared_ptr<HandEventStream> openHandEventStream(HandEventListener* listener) = 0;
79 virtual void streamClosed(HandPoseStream* stream) = 0;
84 virtual void streamClosed(HandEventStream* stream) = 0;
85
94 static std::shared_ptr<HandPoseStream> openDynamicHandPoseStream(SR_handEvent createEvent, HandPoseListener* listener) {
95 if (createEvent.eventType == CreateHand) {
96 HandTracker* sender = (HandTracker*)createEvent.sender;
97 return sender->openHandPoseStream(listener, createEvent.handId);
98 }
99 else {
100 return nullptr;
101 }
102 }
103
112 static void closeDynamicHandPoseStream(SR_handEvent destroyEvent, HandPoseListener* listener) {
113 if (destroyEvent.eventType == DestroyHand) {
114 HandTracker* sender = (HandTracker*)destroyEvent.sender;
115 // Do stuff
116 }
117 }
118};
119
120}
121
122#undef DIMENCOSR_API
Interface for listening to SR_handEvent updates.
Definition: handposelistener.h:21
Stream of SR_handEvent objects.
Definition: handeventstream.h:36
Interface for listening to SR_handPose updates.
Definition: handposelistener.h:39
Stream of SR_handPose objects.
Definition: handposestream.h:36
Sense class which provides hand tracking functionality to the SR system.
Definition: handtracker.h:46
virtual std::shared_ptr< HandPoseStream > openHandPoseStream(HandPoseListener *listener)=0
Creates a HandPoseStream for listener to be connected to.
static void closeDynamicHandPoseStream(SR_handEvent destroyEvent, HandPoseListener *listener)
Closes a specific HandPoseStream referenced by destroyEvent.
Definition: handtracker.h:112
virtual std::shared_ptr< HandEventStream > openHandEventStream(HandEventListener *listener)=0
Creates a HandEventStream for listener to be connected to.
virtual void streamClosed(HandPoseStream *stream)=0
Closes a specific HandPoseStream.
virtual std::shared_ptr< HandPoseStream > openHandPoseStream(HandPoseListener *listener, uint64_t handIdentifier)=0
Creates a HandPoseStream specific for handIdentifier for listener to be connected to.
virtual void streamClosed(HandEventStream *stream)=0
Closes a specific HandEventStream.
static std::shared_ptr< HandPoseStream > openDynamicHandPoseStream(SR_handEvent createEvent, HandPoseListener *listener)
Creates a HandPoseStream specific for createEvent for listener to be connected to.
Definition: handtracker.h:94
static HandTracker * create(SRContext &context)
Creates a functional HandTracker instance.
Maintains WorldObject and Sense objects during the application lifetime.
Definition: srcontext.h:80
Class of objects dealing with Streams of data.
Definition: sense.h:42
@ CreateHand
Definition: handevent.h:16
@ DestroyHand
Definition: handevent.h:17
#define DIMENCOSR_API
Definition: handtracker.h:31
Namespace containing all C++ Simulated Reality classes.
Definition: srconfiguration.h:25
C-compatible struct notifying the listener that the state of a hand has changed.
Definition: handevent.h:28
uint64_t sender
SR::HandTracker* Is valid while the event is being handled.
Definition: handevent.h:34
uint64_t handId
Hand identifier.
Definition: handevent.h:31
SR_handEventType eventType
Type of hand event.
Definition: handevent.h:33