-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuttons.go
191 lines (147 loc) · 4.71 KB
/
buttons.go
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
package oscvrc
import (
"errors"
"time"
)
// Buttons expect an int of 1 for 'pressed' and 0 for 'released'.
// They will not function correctly without resetting to 0 first - sending /input/Jump 1 and then /input/Jump 1 will only result in a single jump.
// Number arguments require 32 bit types (f32, int32, bool)
type MoveDirection string
const (
MoveForward MoveDirection = "MoveForward"
MoveBackward MoveDirection = "MoveBackward"
MoveLeft MoveDirection = "MoveLeft"
MoveRight MoveDirection = "MoveRight"
)
// Move sends a move direction and a boolean value to the OSC server.
// It takes a MoveDirection and a boolean value as parameters.
// The boolean value indicates whether to enable or disable the move direction.
// It returns an error if there was a problem sending the message.
func (c *Client) Move(direction MoveDirection, b bool) error {
var address = "/input/" + string(direction)
err := c.SendMessage(address, b)
if err != nil {
return errors.New("failed to send message: " + err.Error())
}
return nil
}
type LookDirection string
const (
LookLeft LookDirection = "LookLeft"
LookRight LookDirection = "LookRight"
)
// Look sends an OSC message to control the look direction.
// It takes a LookDirection and a boolean value as parameters.
// The boolean value indicates whether to enable or disable the look direction.
// It returns an error if there was a problem sending the message.
func (c *Client) Look(direction LookDirection, b bool) error {
var address = "/input/" + string(direction)
err := c.SendMessage(address, b)
if err != nil {
return errors.New("failed to send message: " + err.Error())
}
return nil
}
// Jump if the world supports it.
func (c *Client) Jump() error {
var jumping bool
const address = "/input/Jump"
// Jumping should always return to 0
for i := 0; i < 2; i++ {
jumping = !jumping
err := c.SendMessage(address, jumping)
if err != nil {
return errors.New("failed to send message: " + err.Error())
}
// Sometimes it doesn't work if we don't sleep for a bit
time.Sleep(100 * time.Millisecond)
}
return nil
}
// Run if the world supports it.
func (c *Client) Run(b bool) error {
const address = "/input/Run"
err := c.SendMessage(address, b)
if err != nil {
return errors.New("failed to send message: " + err.Error())
}
return nil
}
type ComfortLookDirection string
const (
ComfortLookLeft ComfortLookDirection = "ComfortLeft"
ComfortLookRight ComfortLookDirection = "ComfortRight"
)
// ComfortLook works the same as Look, but for comfort turning using snap turns. VR Only.
func (c *Client) ComfortLook(direction ComfortLookDirection, b bool) error {
var address = "/input/" + string(direction)
err := c.SendMessage(address, b)
if err != nil {
return errors.New("failed to send message: " + err.Error())
}
return nil
}
type DropHand string
const (
DropLeftHand DropHand = "DropLeft"
DropRightHand DropHand = "DropRight"
)
// DropHand drops the item in the hand of the specified side.
// It takes a DropHand and a boolean value as parameters.
// The boolean value indicates whether to enable or disable the drop hand action.
// VR Only.
func (c *Client) DropHand(hand DropHand, b bool) error {
var address = "/input/" + string(hand)
err := c.SendMessage(address, b)
if err != nil {
return errors.New("failed to send message: " + err.Error())
}
return nil
}
type UseHand string
const (
UseLeftHand UseHand = "UseLeft"
UseRightHand UseHand = "UseRight"
)
// UseHand uses the item in the hand of the specified side.
// It takes a UseHand and a boolean value as parameters.
// The boolean value indicates whether to enable or disable the use hand action.
// VR Only.
func (c *Client) UseHand(hand UseHand, b bool) error {
var address = "/input/" + string(hand)
err := c.SendMessage(address, b)
if err != nil {
return errors.New("failed to send message: " + err.Error())
}
return nil
}
type GrabHand string
const (
GrabLeftHand GrabHand = "GrabLeft"
GrabRightHand GrabHand = "GrabRight"
)
// GrabHand grabs the item in the hand of the specified side.
// It takes a GrabHand and a boolean value as parameters.
// The boolean value indicates whether to enable or disable the grab hand action.
// VR Only.
func (c *Client) GrabHand(hand GrabHand, b bool) error {
var address = "/input/" + string(hand)
err := c.SendMessage(address, b)
if err != nil {
return errors.New("failed to send message: " + err.Error())
}
return nil
}
// Turn off and on Safe Mode.
func (c *Client) PanicButton(b bool) error {
const address = "/input/PanicButton"
err := c.SendMessage(address, b)
if err != nil {
return errors.New("failed to send message: " + err.Error())
}
return nil
}
// TODO: Voice, Quick Menu
func (c *Client) Voice() error {
return nil
}