Skip to content

Commit

Permalink
Add configuration for Nintendo Switch controllers (hybridgroup#903)
Browse files Browse the repository at this point in the history
  • Loading branch information
adregner authored Mar 23, 2023
1 parent dae7a13 commit c9a9172
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 0 deletions.
1 change: 1 addition & 0 deletions platforms/joystick/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Current configurations included:
- Thrustmaster T-Flight Hotas X Joystick
- XBox360 game controller
- XBox360 "Rock Band" drum controller
- Nintendo Switch Joy-Con controller pair

## How to Install

Expand Down
File renamed without changes.
10 changes: 10 additions & 0 deletions platforms/joystick/joystick_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ const (

// Configuration for the Xbox One controller.
XboxOne = "xboxOne"

// Nvidia Shield TV Controller
Shield = "shield"

// Nintendo Switch Joycon Controller Pair
NintendoSwitchPair = "joyconPair"
)

// Driver represents a joystick
Expand Down Expand Up @@ -135,6 +141,10 @@ func (j *Driver) Start() (err error) {
j.config = xbox360RockBandDrumsConfig
case XboxOne:
j.config = xboxOneConfig
case Shield:
j.config = shieldConfig
case NintendoSwitchPair:
j.config = joyconPairConfig
default:
err := j.loadFile()
if err != nil {
Expand Down
115 changes: 115 additions & 0 deletions platforms/joystick/joystick_nintendo_joycon.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
package joystick

var joyconPairConfig = joystickConfig{
Name: "Nintendo Switch Joycon Controller Pair",
GUID: "5555",
Axis: []pair{
pair{
Name: "left_x",
ID: 0,
},
pair{
Name: "left_y",
ID: 1,
},
pair{
Name: "right_x",
ID: 2,
},
pair{
Name: "right_y",
ID: 3,
},
pair{
Name: "lt",
ID: 4,
},
pair{
Name: "rt",
ID: 5,
},
},
Buttons: []pair{
pair{
Name: "a",
ID: 0,
},
pair{
Name: "b",
ID: 1,
},
pair{
Name: "x",
ID: 2,
},
pair{
Name: "y",
ID: 3,
},
pair{
Name: "up",
ID: 11,
},
pair{
Name: "down",
ID: 12,
},
pair{
Name: "left",
ID: 13,
},
pair{
Name: "right",
ID: 14,
},
pair{
Name: "lb",
ID: 9,
},
pair{
Name: "rb",
ID: 10,
},
pair{
Name: "right_stick",
ID: 8,
},
pair{
Name: "left_stick",
ID: 7,
},
pair{
Name: "options",
ID: 15,
},
pair{
Name: "home",
ID: 5,
},
pair{
Name: "sr_left",
ID: 17,
},
pair{
Name: "sl_left",
ID: 19,
},
pair{
Name: "sr_right",
ID: 16,
},
pair{
Name: "sl_right",
ID: 18,
},
pair{
Name: "minus",
ID: 4,
},
pair{
Name: "plus",
ID: 6,
},
},
Hats: []hat{},
}

0 comments on commit c9a9172

Please sign in to comment.