-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAccelerometerFilter.h
45 lines (33 loc) · 1.15 KB
/
AccelerometerFilter.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
//
// AccelerometerManager.h
// FuguGame
//
// Created by lucar on 06/07/15.
//
//
#ifndef __FuguGame__AccelerometerFilter__
#define __FuguGame__AccelerometerFilter__
#include <stdio.h>
#include "cocos2d.h"
using namespace cocos2d;
double clampAbsolute(double v, double min, double max);
class AccelerometerFilter:public cocos2d::Node
{
public:
AccelerometerFilter(cocos2d::Node* mainScen,float cutOffFreq=5.0f);
void onAcceleration(cocos2d::Acceleration *acc, cocos2d::Event *event);
const cocos2d::Acceleration& getAcceleration(void) { return clampedAcc; };
void setAdaptive(bool val){adaptive=val;}
void setMinThreshold(double x,double y,double z);
void setMaxThreshold(double x,double y,double z);
const cocos2d::Acceleration& getMinThreshold(void) {return minThreshold;}
const cocos2d::Acceleration& getMaxThreshold(void) {return maxThreshold;}
private:
cocos2d::Acceleration minThreshold;
cocos2d::Acceleration maxThreshold;
bool adaptive;
cocos2d::Acceleration filterAcc;
cocos2d::Acceleration clampedAcc;
float filterConstant;
};
#endif /* defined(__FuguGame__AccelerometerManager__) */