blob: a1d1936486a9cfd3bd4beab7c120ea850cdb2e48 (
plain)
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
|
/*
*
* SIXENSE CONFIDENTIAL
*
* Copyright (C) 2011 Sixense Entertainment Inc.
* All Rights Reserved
*
*/
#ifndef SIXENSE_UTILS_BUTTON_STATES_HPP
#define SIXENSE_UTILS_BUTTON_STATES_HPP
#pragma warning(push)
#pragma warning( disable:4251 )
#include "sixense_utils/export.hpp"
#include "sixense_utils/interfaces.hpp"
#include <sixense.h>
#include <sixense_math.hpp>
namespace sixenseUtils {
// LaserPointer computes a ray that shoots from the controller and intersects with the screen.
class SIXENSE_UTILS_EXPORT ButtonStates : public IButtonStates {
public:
ButtonStates();
void update( sixenseControllerData *cd );
bool buttonJustPressed( unsigned short which_button );
bool buttonJustReleased( unsigned short which_button );
void setTriggerThreshold( float thresh );
bool triggerJustPressed();
bool triggerJustReleased();
void setStickThreshold( float thresh );
bool stickJustPressed( Direction which );
bool stickJustReleased( Direction which );
void setAbsoluteTiltAngleThresholdInDeg( float thresh );
void setRelativeTiltAngleThresholdInDeg( float thresh );
// Relative tilts are an orientation change relative to the orientation last time setRelativeOrigin() was called
void setRelativeOrigin();
void startPointGesture();
void stopPointGesture();
bool relativeTiltJustStarted( Direction which );
bool relativeTiltJustStopped( Direction which );
// Absolute gestures are just relative to the world
bool absoluteTiltJustStarted( Direction which );
bool absoluteTiltJustStopped( Direction which );
float _trigger_threshold;
bool justStarted( ActionType action, int arg );
bool justStopped( ActionType action, int arg );
protected:
void updateJoystick( sixenseControllerData *cd );
void updateTrigger( sixenseControllerData *cd );
void updateButtons( sixenseControllerData *cd );
void updateTilt( sixenseControllerData *cd );
private:
// buttons
unsigned short _just_pressed;
unsigned short _just_released;
unsigned short _last_buttons;
// trigger
bool _trigger_just_pressed;
bool _trigger_just_released;
float _last_trigger_state;
// joystick
float _joystick_threshold;
float _last_joystick[2];
bool _joystick_just_pressed[4], _joystick_just_released[4]; // 4 stick directions
// tilt
float _absolute_tilt_angle_threshold_in_deg, _relative_tilt_angle_threshold_in_deg;
sixenseMath::Vector3 _last_point_vec;
bool _point_gesture_active;
bool _last_relative_tilt_states[6];
bool _relative_tilt_just_started[6], _relative_tilt_just_stopped[6]; // 6 tilt directions
bool _last_absolute_tilt_states[6];
bool _absolute_tilt_just_started[6], _absolute_tilt_just_stopped[6]; // 6 tilt directions
bool _should_zero_relative_origin;
sixenseMath::Matrix3 _relative_origin;
};
}
#pragma warning(pop)
#endif
|