forked from hybridgroup/gobot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request hybridgroup#523 from morfeo8marc/dev
joystick: add xbox360 rock band drums controller
- Loading branch information
Showing
4 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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{}, | ||
} |