-
Notifications
You must be signed in to change notification settings - Fork 7
/
FREEventObserver.h
executable file
·119 lines (85 loc) · 2.64 KB
/
FREEventObserver.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#pragma once
#include "FlashRuntimeExtensions.h"
#include "stdafx.h"
#include "Observer.h"
#include "ActionSource.h"
// CAEMode
class FREEventObserver : public Observer, public ActionSource
{
private:
BOOL active;
EdsFocusInfo m_focusInfo;
EdsBool m_bDrawZoomFrame;
protected:
// context
FREContext _ctx;
public:
// set context
void setContext( FREContext ctx) {_ctx = ctx;}
// observer
void update( Observable* from, CameraEvent *e)
{
std::string event = e->getEvent();
if( event == "DeviceBusy" )
{
FREDispatchStatusEventAsync( _ctx, (const uint8_t*) "", (const uint8_t*) event.c_str() );
}
else if( event == "error" )
{
EdsInt32 error = *static_cast<EdsInt32 *>( e->getArg());
char error_str[8] = "";
_itoa_s( error, error_str, 16 );
FREDispatchStatusEventAsync( _ctx, ( uint8_t*) error_str, (const uint8_t*) event.c_str() );
}
else if( event == "EvfDataChanged")
{
// dispatch event to AIR runtime
FREDispatchStatusEventAsync( _ctx, ( uint8_t*) "" , (const uint8_t*) event.c_str() );
// Download image data.
fireEvent( "downloadEVF" , 0);
}
else if (event == "PropertyChanged")
{
EdsInt32 proeprtyID = *static_cast<EdsInt32 *>(e->getArg());
if(proeprtyID == kEdsPropID_Evf_OutputDevice)
{
CameraModel* model = (CameraModel *)from;
EdsUInt32 device = model->getEvfOutputDevice();
// PC live view has started.
if (!active && (device & kEdsEvfOutputDevice_PC) != 0)
{
active = TRUE;
// Start download of image data.
fireEvent("downloadEVF", 0);
}
// PC live view has ended.
if(active && (device & kEdsEvfOutputDevice_PC) == 0)
{
active = FALSE;
}
}
if( proeprtyID==kEdsPropID_Evf_AFMode )
{
CameraModel* model = (CameraModel *)from;
m_bDrawZoomFrame = model->getEvfAFMode()!=2;
}
char propertyID_str[8];
_itoa_s( proeprtyID, propertyID_str, 16 );
// dispatch event to AIR runtime
FREDispatchStatusEventAsync( _ctx, (const uint8_t*) propertyID_str, (const uint8_t*) event.c_str() );
}
else if ( event == "PropertyDescChanged" )
{
EdsInt32 proeprtyID = *static_cast<EdsInt32 *>(e->getArg());
char propertyID_str[8];
_itoa_s( proeprtyID, propertyID_str, 16 );
// dispatch event to AIR runtime
FREDispatchStatusEventAsync( _ctx, (const uint8_t*) propertyID_str, (const uint8_t*) event.c_str() );
}
else
{
// dispatch event to AIR runtime
FREDispatchStatusEventAsync( _ctx, (const uint8_t*) event.c_str(), (const uint8_t*) "info" );
}
}
};