Skip to content

Commit

Permalink
joystick: add xbox360 rock band drums controller
Browse files Browse the repository at this point in the history
Signed-off-by: morfeo8marc <[email protected]>
  • Loading branch information
toffentoffen committed May 7, 2018
1 parent 0fd6cf4 commit f661393
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 0 deletions.
70 changes: 70 additions & 0 deletions examples/joystick_xbox360_rock_band_drums.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// +build example
//
// Do not build by default.

package main

import (
"fmt"

"gobot.io/x/gobot"
"gobot.io/x/gobot/platforms/joystick"
)

func main() {
joystickAdaptor := joystick.NewAdaptor()
stick := joystick.NewDriver(joystickAdaptor, "xbox360RockBandDrums")

work := func() {
stick.On(joystick.RedPress, func(data interface{}) {
fmt.Println("red_press")
})
stick.On(joystick.RedRelease, func(data interface{}) {
fmt.Println("red_release")
})
stick.On(joystick.YellowPress, func(data interface{}) {
fmt.Println("yellow_press")
})
stick.On(joystick.YellowRelease, func(data interface{}) {
fmt.Println("yellow_release")
})
stick.On(joystick.BluePress, func(data interface{}) {
fmt.Println("blue_press")
})
stick.On(joystick.BlueRelease, func(data interface{}) {
fmt.Println("blue_release")
})
stick.On(joystick.GreenPress, func(data interface{}) {
fmt.Println("green_press")
})
stick.On(joystick.GreenRelease, func(data interface{}) {
fmt.Println("blue_release")
})
stick.On(joystick.PedalPress, func(data interface{}) {
fmt.Println("pedal_press")
})
stick.On(joystick.PedalRelease, func(data interface{}) {
fmt.Println("pedal_release")
})
stick.On(joystick.UpPress, func(data interface{}) {
fmt.Println("up", data)
})
stick.On(joystick.DownPress, func(data interface{}) {
fmt.Println("down", data)
})
stick.On(joystick.LeftPress, func(data interface{}) {
fmt.Println("left", data)
})
stick.On(joystick.RightPress, func(data interface{}) {
fmt.Println("right", data)
})
}

robot := gobot.NewRobot("joystickBot",
[]gobot.Connection{joystickAdaptor},
[]gobot.Device{stick},
work,
)

robot.Start()
}
20 changes: 20 additions & 0 deletions platforms/joystick/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,24 @@ const (
BackPress = "back_press"
// back button release event
BackRelease = "back_release"
// red pad press event
RedPress = "red_press"
// red pad release event
RedRelease = "red_release"
// yellow pad press event
YellowPress = "yellow_press"
// yellow pad release event
YellowRelease = "yellow_release"
// blue pad press event
BluePress = "blue_press"
// blue pad release event
BlueRelease = "blue_release"
// green pad press event
GreenPress = "green_press"
// green pad release event
GreenRelease = "green_release"
// pedal press event
PedalPress = "pedal_press"
// pedal release event
PedalRelease = "pedal_release"
)
2 changes: 2 additions & 0 deletions platforms/joystick/joystick_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ func (j *Driver) Start() (err error) {
j.config = dualshock4Config
case "xbox360":
j.config = xbox360Config
case "xbox360RockBandDrums":
j.config = xbox360RockBandDrumsConfig
default:
j.loadFile()
}
Expand Down
58 changes: 58 additions & 0 deletions platforms/joystick/joystick_xbox360_rock_band_drums.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package joystick

var xbox360RockBandDrumsConfig = joystickConfig{
Name: "XBox 360 Rock Band Drums Controller",
GUID: "4444",
Axis: []pair{},
Buttons: []pair{
pair{
Name: "green",
ID: 0,
},
pair{
Name: "red",
ID: 1,
},
pair{
Name: "blue",
ID: 2,
},
pair{
Name: "yellow",
ID: 3,
},
pair{
Name: "pedal",
ID: 4,
},
pair{
Name: "back",
ID: 6,
},
pair{
Name: "start",
ID: 7,
},
pair{
Name: "home",
ID: 8,
},
pair{
Name: "left",
ID: 11,
},
pair{
Name: "right",
ID: 12,
},
pair{
Name: "up",
ID: 13,
},
pair{
Name: "down",
ID: 14,
},
},
Hats: []hat{},
}

0 comments on commit f661393

Please sign in to comment.