-
Notifications
You must be signed in to change notification settings - Fork 0
/
joystick_xbox360.go
62 lines (56 loc) · 1.44 KB
/
joystick_xbox360.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
package main
import (
"fmt"
"gobot.io/x/gobot"
"gobot.io/x/gobot/platforms/joystick"
)
func main() {
joystickAdaptor := joystick.NewAdaptor()
stick := joystick.NewDriver(joystickAdaptor,
"./platforms/joystick/configs/joystick/configs/xbox360_power_a_mini_proex.json",
)
work := func() {
stick.On(joystick.APress, func(data interface{}) {
fmt.Println("a_press")
})
stick.On(joystick.ARelease, func(data interface{}) {
fmt.Println("a_release")
})
stick.On(joystick.BPress, func(data interface{}) {
fmt.Println("b_press")
})
stick.On(joystick.BRelease, func(data interface{}) {
fmt.Println("b_release")
})
stick.On(joystick.Up, func(data interface{}) {
fmt.Println("up", data)
})
stick.On(joystick.Down, func(data interface{}) {
fmt.Println("down", data)
})
stick.On(joystick.Left, func(data interface{}) {
fmt.Println("left", data)
})
stick.On(joystick.Right, func(data interface{}) {
fmt.Println("right", data)
})
stick.On(joystick.LeftX, func(data interface{}) {
fmt.Println("left_x", data)
})
stick.On(joystick.LeftY, func(data interface{}) {
fmt.Println("left_y", data)
})
stick.On(joystick.RightX, func(data interface{}) {
fmt.Println("right_x", data)
})
stick.On(joystick.RightY, func(data interface{}) {
fmt.Println("right_y", data)
})
}
robot := gobot.NewRobot("joystickBot",
[]gobot.Connection{joystickAdaptor},
[]gobot.Device{stick},
work,
)
robot.Start()
}