@@ -21,10 +21,89 @@ void TutorialDriver::ControllerDevice::update(std::vector<vr::VREvent_t> events)
21
21
double deltaTimeSeconds = std::chrono::duration_cast<std::chrono::milliseconds>(now - m_lastFrameTime).count ()/1000.0 ;
22
22
this ->m_lastFrameTime = now;
23
23
24
+ // A button click
25
+ if (GetAsyncKeyState (0x60 ) != 0 ) {
26
+ vr::VRDriverInput ()->UpdateBooleanComponent (this ->m_compATouch , true , 0 );
27
+ vr::VRDriverInput ()->UpdateBooleanComponent (this ->m_compAClick , true , 0 );
28
+ }
29
+ else {
30
+ vr::VRDriverInput ()->UpdateBooleanComponent (this ->m_compAClick , false , 0 );
31
+ vr::VRDriverInput ()->UpdateBooleanComponent (this ->m_compATouch , false , 0 );
32
+ }
33
+
34
+ // B button click
35
+ if (GetAsyncKeyState (0x61 ) != 0 ) {
36
+ vr::VRDriverInput ()->UpdateBooleanComponent (this ->m_compBTouch , true , 0 );
37
+ vr::VRDriverInput ()->UpdateBooleanComponent (this ->m_compBClick , true , 0 );
38
+ }
39
+ else {
40
+ vr::VRDriverInput ()->UpdateBooleanComponent (this ->m_compBClick , false , 0 );
41
+ vr::VRDriverInput ()->UpdateBooleanComponent (this ->m_compBTouch , false , 0 );
42
+ }
43
+
44
+ // Trigger click
45
+ if (GetAsyncKeyState (0x62 ) != 0 ) {
46
+ vr::VRDriverInput ()->UpdateBooleanComponent (this ->m_compTriggerTouch , true , 0 );
47
+ vr::VRDriverInput ()->UpdateBooleanComponent (this ->m_compTriggerClick , true , 0 );
48
+ vr::VRDriverInput ()->UpdateScalarComponent (this ->m_compTriggerValue , 1 , 0 );
49
+ }
50
+ else {
51
+ vr::VRDriverInput ()->UpdateScalarComponent (this ->m_compTriggerValue , 0 , 0 );
52
+ vr::VRDriverInput ()->UpdateBooleanComponent (this ->m_compTriggerClick , false , 0 );
53
+ vr::VRDriverInput ()->UpdateBooleanComponent (this ->m_compTriggerTouch , false , 0 );
54
+ }
24
55
56
+ // Grip click/force
57
+ if (GetAsyncKeyState (0x63 ) != 0 ) {
58
+ vr::VRDriverInput ()->UpdateBooleanComponent (this ->m_compGripTouch , true , 0 );
59
+ vr::VRDriverInput ()->UpdateBooleanComponent (this ->m_compGripClick , true , 0 );
60
+ vr::VRDriverInput ()->UpdateScalarComponent (this ->m_compGripValue , 1 , 0 );
61
+ vr::VRDriverInput ()->UpdateScalarComponent (this ->m_compGripForce , 1 , 0 );
62
+ }
63
+ else {
64
+ vr::VRDriverInput ()->UpdateScalarComponent (this ->m_compGripForce , 0 , 0 );
65
+ vr::VRDriverInput ()->UpdateScalarComponent (this ->m_compGripValue , 0 , 0 );
66
+ vr::VRDriverInput ()->UpdateBooleanComponent (this ->m_compGripClick , false , 0 );
67
+ vr::VRDriverInput ()->UpdateBooleanComponent (this ->m_compGripTouch , false , 0 );
68
+ }
25
69
70
+ // System button
71
+ if (GetAsyncKeyState (0x64 ) != 0 ) {
72
+ vr::VRDriverInput ()->UpdateBooleanComponent (this ->m_compSysTouch , true , 0 );
73
+ vr::VRDriverInput ()->UpdateBooleanComponent (this ->m_compSysClick , true , 0 );
74
+ }
75
+ else {
76
+ vr::VRDriverInput ()->UpdateBooleanComponent (this ->m_compSysClick , false , 0 );
77
+ vr::VRDriverInput ()->UpdateBooleanComponent (this ->m_compSysTouch , false , 0 );
78
+ }
26
79
80
+ // Trackpad position and touch
81
+ if (GetAsyncKeyState (0x65 ) != 0 ) {
82
+ vr::VRDriverInput ()->UpdateBooleanComponent (this ->m_compTrackpadTouch , true , 0 );
83
+ vr::VRDriverInput ()->UpdateBooleanComponent (this ->m_compTrackpadClick , true , 0 );
84
+ vr::VRDriverInput ()->UpdateScalarComponent (this ->m_compTrackpadX , 1 , 0 );
85
+ vr::VRDriverInput ()->UpdateScalarComponent (this ->m_compTrackpadY , 1 , 0 );
86
+ }
87
+ else {
88
+ vr::VRDriverInput ()->UpdateBooleanComponent (this ->m_compTrackpadClick , false , 0 );
89
+ vr::VRDriverInput ()->UpdateBooleanComponent (this ->m_compTrackpadTouch , false , 0 );
90
+ vr::VRDriverInput ()->UpdateScalarComponent (this ->m_compTrackpadX , 0 , 0 );
91
+ vr::VRDriverInput ()->UpdateScalarComponent (this ->m_compTrackpadY , 0 , 0 );
92
+ }
27
93
94
+ // Joystick position and touch
95
+ if (GetAsyncKeyState (0x66 ) != 0 ) {
96
+ vr::VRDriverInput ()->UpdateBooleanComponent (this ->m_compJoystickTouch , true , 0 );
97
+ vr::VRDriverInput ()->UpdateBooleanComponent (this ->m_compJoystickClick , true , 0 );
98
+ vr::VRDriverInput ()->UpdateScalarComponent (this ->m_compJoystickX , 1 , 0 );
99
+ vr::VRDriverInput ()->UpdateScalarComponent (this ->m_compJoystickY , 1 , 0 );
100
+ }
101
+ else {
102
+ vr::VRDriverInput ()->UpdateBooleanComponent (this ->m_compJoystickClick , false , 0 );
103
+ vr::VRDriverInput ()->UpdateBooleanComponent (this ->m_compJoystickTouch , false , 0 );
104
+ vr::VRDriverInput ()->UpdateScalarComponent (this ->m_compJoystickX , 0 , 0 );
105
+ vr::VRDriverInput ()->UpdateScalarComponent (this ->m_compJoystickY , 0 , 0 );
106
+ }
28
107
29
108
// Post pose
30
109
auto pose = this ->GetPose ();
0 commit comments