https://github.com/raspberrypi-go-drivers/switchprocontroller
Allows to read inputs from a Nintendo Switch Pro controller connected using Bluetooth
https://github.com/raspberrypi-go-drivers/switchprocontroller
driver go golang raspberrypi raspberrypi-drivers robotics
Last synced: about 1 month ago
JSON representation
Allows to read inputs from a Nintendo Switch Pro controller connected using Bluetooth
- Host: GitHub
- URL: https://github.com/raspberrypi-go-drivers/switchprocontroller
- Owner: raspberrypi-go-drivers
- License: mit
- Created: 2020-12-18T14:57:22.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-12-18T16:15:15.000Z (over 5 years ago)
- Last Synced: 2025-05-18T14:48:43.639Z (about 1 year ago)
- Topics: driver, go, golang, raspberrypi, raspberrypi-drivers, robotics
- Language: Go
- Homepage:
- Size: 9.77 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Nintendo Switch Pro Controller
[](https://pkg.go.dev/github.com/raspberrypi-go-drivers/switchprocontroller)

[](https://goreportcard.com/report/github.com/raspberrypi-go-drivers/switchprocontroller)
[](https://opensource.org/licenses/MIT)
This drivers allows to read inputs from a Nintendo Switch Pro Controller
connected using Bluetooth
## Requirements
- a Nintendo Switch Pro Controller connected to a Raspberry Pi using Bluetooth
## Documentation
For full documentation, please visit [](https://pkg.go.dev/github.com/raspberrypi-go-drivers/switchprocontroller)
## Quick start
```go
import (
"fmt"
"github.com/raspberrypi-go-drivers/switchprocontroller"
)
func main() {
controller := switchprocontroller.NewSwitchProController()
controller.StartListener(0)
for {
select {
case event := <-controller.Events:
if event.Button != nil {
fmt.Printf("%s:%d\n", event.Button.Name, event.Button.State)
} else if event.Stick != nil {
fmt.Printf("%s - Y:%f X:%f\n", event.Stick.Name, event.Stick.Y, event.Stick.X)
}
case <-time.After(60 * time.Second):
fmt.Println("timeout")
return
}
}
}
```
## Raspberry Pi compatibility
This driver has has only been tested on an Raspberry Pi Zero WH using integrated bluetooth but may work well on other Raspberry Pi having integrated Bluetooth
## License
MIT License