internal/gamepaddb: move driver.StandardGamepadButton to gamepaddb.StandardButton

This commit is contained in:
Hajime Hoshi 2022-02-05 23:11:09 +09:00
parent 627509e974
commit 67663795fd
5 changed files with 135 additions and 138 deletions

View File

@ -15,8 +15,8 @@
package ebiten package ebiten
import ( import (
"github.com/hajimehoshi/ebiten/v2/internal/driver"
"github.com/hajimehoshi/ebiten/v2/internal/gamepad" "github.com/hajimehoshi/ebiten/v2/internal/gamepad"
"github.com/hajimehoshi/ebiten/v2/internal/gamepaddb"
) )
// GamepadButton represents a gamepad button. // GamepadButton represents a gamepad button.
@ -63,27 +63,27 @@ const (
// //
// The layout and the button values are based on the web standard. // The layout and the button values are based on the web standard.
// See https://www.w3.org/TR/gamepad/#remapping. // See https://www.w3.org/TR/gamepad/#remapping.
type StandardGamepadButton = driver.StandardGamepadButton type StandardGamepadButton = gamepaddb.StandardButton
// StandardGamepadButtons // StandardGamepadButtons
const ( const (
StandardGamepadButtonRightBottom StandardGamepadButton = driver.StandardGamepadButtonRightBottom StandardGamepadButtonRightBottom StandardGamepadButton = gamepaddb.StandardButtonRightBottom
StandardGamepadButtonRightRight StandardGamepadButton = driver.StandardGamepadButtonRightRight StandardGamepadButtonRightRight StandardGamepadButton = gamepaddb.StandardButtonRightRight
StandardGamepadButtonRightLeft StandardGamepadButton = driver.StandardGamepadButtonRightLeft StandardGamepadButtonRightLeft StandardGamepadButton = gamepaddb.StandardButtonRightLeft
StandardGamepadButtonRightTop StandardGamepadButton = driver.StandardGamepadButtonRightTop StandardGamepadButtonRightTop StandardGamepadButton = gamepaddb.StandardButtonRightTop
StandardGamepadButtonFrontTopLeft StandardGamepadButton = driver.StandardGamepadButtonFrontTopLeft StandardGamepadButtonFrontTopLeft StandardGamepadButton = gamepaddb.StandardButtonFrontTopLeft
StandardGamepadButtonFrontTopRight StandardGamepadButton = driver.StandardGamepadButtonFrontTopRight StandardGamepadButtonFrontTopRight StandardGamepadButton = gamepaddb.StandardButtonFrontTopRight
StandardGamepadButtonFrontBottomLeft StandardGamepadButton = driver.StandardGamepadButtonFrontBottomLeft StandardGamepadButtonFrontBottomLeft StandardGamepadButton = gamepaddb.StandardButtonFrontBottomLeft
StandardGamepadButtonFrontBottomRight StandardGamepadButton = driver.StandardGamepadButtonFrontBottomRight StandardGamepadButtonFrontBottomRight StandardGamepadButton = gamepaddb.StandardButtonFrontBottomRight
StandardGamepadButtonCenterLeft StandardGamepadButton = driver.StandardGamepadButtonCenterLeft StandardGamepadButtonCenterLeft StandardGamepadButton = gamepaddb.StandardButtonCenterLeft
StandardGamepadButtonCenterRight StandardGamepadButton = driver.StandardGamepadButtonCenterRight StandardGamepadButtonCenterRight StandardGamepadButton = gamepaddb.StandardButtonCenterRight
StandardGamepadButtonLeftStick StandardGamepadButton = driver.StandardGamepadButtonLeftStick StandardGamepadButtonLeftStick StandardGamepadButton = gamepaddb.StandardButtonLeftStick
StandardGamepadButtonRightStick StandardGamepadButton = driver.StandardGamepadButtonRightStick StandardGamepadButtonRightStick StandardGamepadButton = gamepaddb.StandardButtonRightStick
StandardGamepadButtonLeftTop StandardGamepadButton = driver.StandardGamepadButtonLeftTop StandardGamepadButtonLeftTop StandardGamepadButton = gamepaddb.StandardButtonLeftTop
StandardGamepadButtonLeftBottom StandardGamepadButton = driver.StandardGamepadButtonLeftBottom StandardGamepadButtonLeftBottom StandardGamepadButton = gamepaddb.StandardButtonLeftBottom
StandardGamepadButtonLeftLeft StandardGamepadButton = driver.StandardGamepadButtonLeftLeft StandardGamepadButtonLeftLeft StandardGamepadButton = gamepaddb.StandardButtonLeftLeft
StandardGamepadButtonLeftRight StandardGamepadButton = driver.StandardGamepadButtonLeftRight StandardGamepadButtonLeftRight StandardGamepadButton = gamepaddb.StandardButtonLeftRight
StandardGamepadButtonCenterCenter StandardGamepadButton = driver.StandardGamepadButtonCenterCenter StandardGamepadButtonCenterCenter StandardGamepadButton = gamepaddb.StandardButtonCenterCenter
StandardGamepadButtonMax StandardGamepadButton = StandardGamepadButtonCenterCenter StandardGamepadButtonMax StandardGamepadButton = StandardGamepadButtonCenterCenter
) )
@ -91,13 +91,13 @@ const (
// //
// The layout and the button values are based on the web standard. // The layout and the button values are based on the web standard.
// See https://www.w3.org/TR/gamepad/#remapping. // See https://www.w3.org/TR/gamepad/#remapping.
type StandardGamepadAxis = driver.StandardGamepadAxis type StandardGamepadAxis = gamepaddb.StandardAxis
// StandardGamepadAxes // StandardGamepadAxes
const ( const (
StandardGamepadAxisLeftStickHorizontal StandardGamepadAxis = driver.StandardGamepadAxisLeftStickHorizontal StandardGamepadAxisLeftStickHorizontal StandardGamepadAxis = gamepaddb.StandardAxisLeftStickHorizontal
StandardGamepadAxisLeftStickVertical StandardGamepadAxis = driver.StandardGamepadAxisLeftStickVertical StandardGamepadAxisLeftStickVertical StandardGamepadAxis = gamepaddb.StandardAxisLeftStickVertical
StandardGamepadAxisRightStickHorizontal StandardGamepadAxis = driver.StandardGamepadAxisRightStickHorizontal StandardGamepadAxisRightStickHorizontal StandardGamepadAxis = gamepaddb.StandardAxisRightStickHorizontal
StandardGamepadAxisRightStickVertical StandardGamepadAxis = driver.StandardGamepadAxisRightStickVertical StandardGamepadAxisRightStickVertical StandardGamepadAxis = gamepaddb.StandardAxisRightStickVertical
StandardGamepadAxisMax StandardGamepadAxis = StandardGamepadAxisRightStickVertical StandardGamepadAxisMax StandardGamepadAxis = StandardGamepadAxisRightStickVertical
) )

View File

@ -1,52 +0,0 @@
// Copyright 2015 Hajime Hoshi
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package driver
type StandardGamepadButton int
// https://www.w3.org/TR/gamepad/#remapping
const (
StandardGamepadButtonRightBottom StandardGamepadButton = iota
StandardGamepadButtonRightRight
StandardGamepadButtonRightLeft
StandardGamepadButtonRightTop
StandardGamepadButtonFrontTopLeft
StandardGamepadButtonFrontTopRight
StandardGamepadButtonFrontBottomLeft
StandardGamepadButtonFrontBottomRight
StandardGamepadButtonCenterLeft
StandardGamepadButtonCenterRight
StandardGamepadButtonLeftStick
StandardGamepadButtonRightStick
StandardGamepadButtonLeftTop
StandardGamepadButtonLeftBottom
StandardGamepadButtonLeftLeft
StandardGamepadButtonLeftRight
StandardGamepadButtonCenterCenter
StandardGamepadButtonMax = StandardGamepadButtonCenterCenter
)
type StandardGamepadAxis int
// https://www.w3.org/TR/gamepad/#remapping
const (
StandardGamepadAxisLeftStickHorizontal StandardGamepadAxis = iota
StandardGamepadAxisLeftStickVertical
StandardGamepadAxisRightStickHorizontal
StandardGamepadAxisRightStickVertical
StandardGamepadAxisMax = StandardGamepadAxisRightStickVertical
)

View File

@ -18,7 +18,6 @@ import (
"sync" "sync"
"time" "time"
"github.com/hajimehoshi/ebiten/v2/internal/driver"
"github.com/hajimehoshi/ebiten/v2/internal/gamepaddb" "github.com/hajimehoshi/ebiten/v2/internal/gamepaddb"
) )
@ -242,7 +241,7 @@ func (g *Gamepad) IsStandardLayoutAvailable() bool {
} }
// StandardAxisValue is concurrent-safe. // StandardAxisValue is concurrent-safe.
func (g *Gamepad) StandardAxisValue(axis driver.StandardGamepadAxis) float64 { func (g *Gamepad) StandardAxisValue(axis gamepaddb.StandardAxis) float64 {
if gamepaddb.HasStandardLayoutMapping(g.sdlID) { if gamepaddb.HasStandardLayoutMapping(g.sdlID) {
return gamepaddb.AxisValue(g.sdlID, axis, g) return gamepaddb.AxisValue(g.sdlID, axis, g)
} }
@ -253,7 +252,7 @@ func (g *Gamepad) StandardAxisValue(axis driver.StandardGamepadAxis) float64 {
} }
// StandardButtonValue is concurrent-safe. // StandardButtonValue is concurrent-safe.
func (g *Gamepad) StandardButtonValue(button driver.StandardGamepadButton) float64 { func (g *Gamepad) StandardButtonValue(button gamepaddb.StandardButton) float64 {
if gamepaddb.HasStandardLayoutMapping(g.sdlID) { if gamepaddb.HasStandardLayoutMapping(g.sdlID) {
return gamepaddb.ButtonValue(g.sdlID, button, g) return gamepaddb.ButtonValue(g.sdlID, button, g)
} }
@ -264,7 +263,7 @@ func (g *Gamepad) StandardButtonValue(button driver.StandardGamepadButton) float
} }
// IsStandardButtonPressed is concurrent-safe. // IsStandardButtonPressed is concurrent-safe.
func (g *Gamepad) IsStandardButtonPressed(button driver.StandardGamepadButton) bool { func (g *Gamepad) IsStandardButtonPressed(button gamepaddb.StandardButton) bool {
if gamepaddb.HasStandardLayoutMapping(g.sdlID) { if gamepaddb.HasStandardLayoutMapping(g.sdlID) {
return gamepaddb.IsButtonPressed(g.sdlID, button, g) return gamepaddb.IsButtonPressed(g.sdlID, button, g)
} }

View File

@ -0,0 +1,52 @@
// Copyright 2015 Hajime Hoshi
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package gamepaddb
type StandardButton int
// https://www.w3.org/TR/gamepad/#remapping
const (
StandardButtonRightBottom StandardButton = iota
StandardButtonRightRight
StandardButtonRightLeft
StandardButtonRightTop
StandardButtonFrontTopLeft
StandardButtonFrontTopRight
StandardButtonFrontBottomLeft
StandardButtonFrontBottomRight
StandardButtonCenterLeft
StandardButtonCenterRight
StandardButtonLeftStick
StandardButtonRightStick
StandardButtonLeftTop
StandardButtonLeftBottom
StandardButtonLeftLeft
StandardButtonLeftRight
StandardButtonCenterCenter
StandardButtonMax = StandardButtonCenterCenter
)
type StandardAxis int
// https://www.w3.org/TR/gamepad/#remapping
const (
StandardAxisLeftStickHorizontal StandardAxis = iota
StandardAxisLeftStickVertical
StandardAxisRightStickHorizontal
StandardAxisRightStickVertical
StandardAxisMax = StandardAxisRightStickVertical
)

View File

@ -31,8 +31,6 @@ import (
"strconv" "strconv"
"strings" "strings"
"sync" "sync"
"github.com/hajimehoshi/ebiten/v2/internal/driver"
) )
type platform int type platform int
@ -127,8 +125,8 @@ type mapping struct {
var ( var (
gamepadNames = map[string]string{} gamepadNames = map[string]string{}
gamepadButtonMappings = map[string]map[driver.StandardGamepadButton]*mapping{} gamepadButtonMappings = map[string]map[StandardButton]*mapping{}
gamepadAxisMappings = map[string]map[driver.StandardGamepadAxis]*mapping{} gamepadAxisMappings = map[string]map[StandardAxis]*mapping{}
mappingsM sync.RWMutex mappingsM sync.RWMutex
) )
@ -183,7 +181,7 @@ func processLine(line string, platform platform) error {
if b, ok := toStandardGamepadButton(tks[0]); ok { if b, ok := toStandardGamepadButton(tks[0]); ok {
m, ok := gamepadButtonMappings[id] m, ok := gamepadButtonMappings[id]
if !ok { if !ok {
m = map[driver.StandardGamepadButton]*mapping{} m = map[StandardButton]*mapping{}
gamepadButtonMappings[id] = m gamepadButtonMappings[id] = m
} }
m[b] = gb m[b] = gb
@ -193,7 +191,7 @@ func processLine(line string, platform platform) error {
if a, ok := toStandardGamepadAxis(tks[0]); ok { if a, ok := toStandardGamepadAxis(tks[0]); ok {
m, ok := gamepadAxisMappings[id] m, ok := gamepadAxisMappings[id]
if !ok { if !ok {
m = map[driver.StandardGamepadAxis]*mapping{} m = map[StandardAxis]*mapping{}
gamepadAxisMappings[id] = m gamepadAxisMappings[id] = m
} }
m[a] = gb m[a] = gb
@ -282,63 +280,63 @@ func parseMappingElement(str string) (*mapping, error) {
return nil, fmt.Errorf("gamepaddb: unepxected mapping: %s", str) return nil, fmt.Errorf("gamepaddb: unepxected mapping: %s", str)
} }
func toStandardGamepadButton(str string) (driver.StandardGamepadButton, bool) { func toStandardGamepadButton(str string) (StandardButton, bool) {
switch str { switch str {
case "a": case "a":
return driver.StandardGamepadButtonRightBottom, true return StandardButtonRightBottom, true
case "b": case "b":
return driver.StandardGamepadButtonRightRight, true return StandardButtonRightRight, true
case "x": case "x":
return driver.StandardGamepadButtonRightLeft, true return StandardButtonRightLeft, true
case "y": case "y":
return driver.StandardGamepadButtonRightTop, true return StandardButtonRightTop, true
case "back": case "back":
return driver.StandardGamepadButtonCenterLeft, true return StandardButtonCenterLeft, true
case "start": case "start":
return driver.StandardGamepadButtonCenterRight, true return StandardButtonCenterRight, true
case "guide": case "guide":
return driver.StandardGamepadButtonCenterCenter, true return StandardButtonCenterCenter, true
case "leftshoulder": case "leftshoulder":
return driver.StandardGamepadButtonFrontTopLeft, true return StandardButtonFrontTopLeft, true
case "rightshoulder": case "rightshoulder":
return driver.StandardGamepadButtonFrontTopRight, true return StandardButtonFrontTopRight, true
case "leftstick": case "leftstick":
return driver.StandardGamepadButtonLeftStick, true return StandardButtonLeftStick, true
case "rightstick": case "rightstick":
return driver.StandardGamepadButtonRightStick, true return StandardButtonRightStick, true
case "dpup": case "dpup":
return driver.StandardGamepadButtonLeftTop, true return StandardButtonLeftTop, true
case "dpright": case "dpright":
return driver.StandardGamepadButtonLeftRight, true return StandardButtonLeftRight, true
case "dpdown": case "dpdown":
return driver.StandardGamepadButtonLeftBottom, true return StandardButtonLeftBottom, true
case "dpleft": case "dpleft":
return driver.StandardGamepadButtonLeftLeft, true return StandardButtonLeftLeft, true
case "lefttrigger": case "lefttrigger":
return driver.StandardGamepadButtonFrontBottomLeft, true return StandardButtonFrontBottomLeft, true
case "righttrigger": case "righttrigger":
return driver.StandardGamepadButtonFrontBottomRight, true return StandardButtonFrontBottomRight, true
default: default:
return 0, false return 0, false
} }
} }
func toStandardGamepadAxis(str string) (driver.StandardGamepadAxis, bool) { func toStandardGamepadAxis(str string) (StandardAxis, bool) {
switch str { switch str {
case "leftx": case "leftx":
return driver.StandardGamepadAxisLeftStickHorizontal, true return StandardAxisLeftStickHorizontal, true
case "lefty": case "lefty":
return driver.StandardGamepadAxisLeftStickVertical, true return StandardAxisLeftStickVertical, true
case "rightx": case "rightx":
return driver.StandardGamepadAxisRightStickHorizontal, true return StandardAxisRightStickHorizontal, true
case "righty": case "righty":
return driver.StandardGamepadAxisRightStickVertical, true return StandardAxisRightStickVertical, true
default: default:
return 0, false return 0, false
} }
} }
func buttonMappings(id string) map[driver.StandardGamepadButton]*mapping { func buttonMappings(id string) map[StandardButton]*mapping {
if m, ok := gamepadButtonMappings[id]; ok { if m, ok := gamepadButtonMappings[id]; ok {
return m return m
} }
@ -353,7 +351,7 @@ func buttonMappings(id string) map[driver.StandardGamepadButton]*mapping {
return nil return nil
} }
func axisMappings(id string) map[driver.StandardGamepadAxis]*mapping { func axisMappings(id string) map[StandardAxis]*mapping {
if m, ok := gamepadAxisMappings[id]; ok { if m, ok := gamepadAxisMappings[id]; ok {
return m return m
} }
@ -388,7 +386,7 @@ func Name(id string) string {
return gamepadNames[id] return gamepadNames[id]
} }
func AxisValue(id string, axis driver.StandardGamepadAxis, state GamepadState) float64 { func AxisValue(id string, axis StandardAxis, state GamepadState) float64 {
mappingsM.RLock() mappingsM.RLock()
defer mappingsM.RUnlock() defer mappingsM.RUnlock()
@ -428,14 +426,14 @@ func AxisValue(id string, axis driver.StandardGamepadAxis, state GamepadState) f
return 0 return 0
} }
func ButtonValue(id string, button driver.StandardGamepadButton, state GamepadState) float64 { func ButtonValue(id string, button StandardButton, state GamepadState) float64 {
mappingsM.RLock() mappingsM.RLock()
defer mappingsM.RUnlock() defer mappingsM.RUnlock()
return buttonValue(id, button, state) return buttonValue(id, button, state)
} }
func buttonValue(id string, button driver.StandardGamepadButton, state GamepadState) float64 { func buttonValue(id string, button StandardButton, state GamepadState) float64 {
mappings := buttonMappings(id) mappings := buttonMappings(id)
if mappings == nil { if mappings == nil {
return 0 return 0
@ -471,7 +469,7 @@ func buttonValue(id string, button driver.StandardGamepadButton, state GamepadSt
return 0 return 0
} }
func IsButtonPressed(id string, button driver.StandardGamepadButton, state GamepadState) bool { func IsButtonPressed(id string, button StandardButton, state GamepadState) bool {
// Use XInput's trigger dead zone. // Use XInput's trigger dead zone.
// See https://source.chromium.org/chromium/chromium/src/+/main:device/gamepad/public/cpp/gamepad.h;l=22-23;drc=6997f8a177359bb99598988ed5e900841984d242 // See https://source.chromium.org/chromium/chromium/src/+/main:device/gamepad/public/cpp/gamepad.h;l=22-23;drc=6997f8a177359bb99598988ed5e900841984d242
const threshold = 30.0 / 255.0 const threshold = 30.0 / 255.0
@ -576,40 +574,40 @@ func addAndroidDefaultMappings(id string) bool {
return false return false
} }
gamepadButtonMappings[id] = map[driver.StandardGamepadButton]*mapping{} gamepadButtonMappings[id] = map[StandardButton]*mapping{}
if buttonMask&(1<<SDLControllerButtonA) != 0 { if buttonMask&(1<<SDLControllerButtonA) != 0 {
gamepadButtonMappings[id][driver.StandardGamepadButtonRightBottom] = &mapping{ gamepadButtonMappings[id][StandardButtonRightBottom] = &mapping{
Type: mappingTypeButton, Type: mappingTypeButton,
Index: SDLControllerButtonA, Index: SDLControllerButtonA,
} }
} }
if buttonMask&(1<<SDLControllerButtonB) != 0 { if buttonMask&(1<<SDLControllerButtonB) != 0 {
gamepadButtonMappings[id][driver.StandardGamepadButtonRightRight] = &mapping{ gamepadButtonMappings[id][StandardButtonRightRight] = &mapping{
Type: mappingTypeButton, Type: mappingTypeButton,
Index: SDLControllerButtonB, Index: SDLControllerButtonB,
} }
} else { } else {
// Use the back button as "B" for easy UI navigation with TV remotes. // Use the back button as "B" for easy UI navigation with TV remotes.
gamepadButtonMappings[id][driver.StandardGamepadButtonRightRight] = &mapping{ gamepadButtonMappings[id][StandardButtonRightRight] = &mapping{
Type: mappingTypeButton, Type: mappingTypeButton,
Index: SDLControllerButtonBack, Index: SDLControllerButtonBack,
} }
buttonMask &^= uint16(1) << SDLControllerButtonBack buttonMask &^= uint16(1) << SDLControllerButtonBack
} }
if buttonMask&(1<<SDLControllerButtonX) != 0 { if buttonMask&(1<<SDLControllerButtonX) != 0 {
gamepadButtonMappings[id][driver.StandardGamepadButtonRightLeft] = &mapping{ gamepadButtonMappings[id][StandardButtonRightLeft] = &mapping{
Type: mappingTypeButton, Type: mappingTypeButton,
Index: SDLControllerButtonX, Index: SDLControllerButtonX,
} }
} }
if buttonMask&(1<<SDLControllerButtonY) != 0 { if buttonMask&(1<<SDLControllerButtonY) != 0 {
gamepadButtonMappings[id][driver.StandardGamepadButtonRightTop] = &mapping{ gamepadButtonMappings[id][StandardButtonRightTop] = &mapping{
Type: mappingTypeButton, Type: mappingTypeButton,
Index: SDLControllerButtonY, Index: SDLControllerButtonY,
} }
} }
if buttonMask&(1<<SDLControllerButtonBack) != 0 { if buttonMask&(1<<SDLControllerButtonBack) != 0 {
gamepadButtonMappings[id][driver.StandardGamepadButtonCenterLeft] = &mapping{ gamepadButtonMappings[id][StandardButtonCenterLeft] = &mapping{
Type: mappingTypeButton, Type: mappingTypeButton,
Index: SDLControllerButtonBack, Index: SDLControllerButtonBack,
} }
@ -617,68 +615,68 @@ func addAndroidDefaultMappings(id string) bool {
if buttonMask&(1<<SDLControllerButtonGuide) != 0 { if buttonMask&(1<<SDLControllerButtonGuide) != 0 {
// TODO: If SDKVersion >= 30, add this code: // TODO: If SDKVersion >= 30, add this code:
// //
// gamepadButtonMappings[id][driver.StandardGamepadButtonCenterCenter] = &mapping{ // gamepadButtonMappings[id][StandardButtonCenterCenter] = &mapping{
// Type: mappingTypeButton, // Type: mappingTypeButton,
// Index: SDLControllerButtonGuide, // Index: SDLControllerButtonGuide,
// } // }
} }
if buttonMask&(1<<SDLControllerButtonStart) != 0 { if buttonMask&(1<<SDLControllerButtonStart) != 0 {
gamepadButtonMappings[id][driver.StandardGamepadButtonCenterRight] = &mapping{ gamepadButtonMappings[id][StandardButtonCenterRight] = &mapping{
Type: mappingTypeButton, Type: mappingTypeButton,
Index: SDLControllerButtonStart, Index: SDLControllerButtonStart,
} }
} }
if buttonMask&(1<<SDLControllerButtonLeftStick) != 0 { if buttonMask&(1<<SDLControllerButtonLeftStick) != 0 {
gamepadButtonMappings[id][driver.StandardGamepadButtonLeftStick] = &mapping{ gamepadButtonMappings[id][StandardButtonLeftStick] = &mapping{
Type: mappingTypeButton, Type: mappingTypeButton,
Index: SDLControllerButtonLeftStick, Index: SDLControllerButtonLeftStick,
} }
} }
if buttonMask&(1<<SDLControllerButtonRightStick) != 0 { if buttonMask&(1<<SDLControllerButtonRightStick) != 0 {
gamepadButtonMappings[id][driver.StandardGamepadButtonRightStick] = &mapping{ gamepadButtonMappings[id][StandardButtonRightStick] = &mapping{
Type: mappingTypeButton, Type: mappingTypeButton,
Index: SDLControllerButtonRightStick, Index: SDLControllerButtonRightStick,
} }
} }
if buttonMask&(1<<SDLControllerButtonLeftShoulder) != 0 { if buttonMask&(1<<SDLControllerButtonLeftShoulder) != 0 {
gamepadButtonMappings[id][driver.StandardGamepadButtonFrontTopLeft] = &mapping{ gamepadButtonMappings[id][StandardButtonFrontTopLeft] = &mapping{
Type: mappingTypeButton, Type: mappingTypeButton,
Index: SDLControllerButtonLeftShoulder, Index: SDLControllerButtonLeftShoulder,
} }
} }
if buttonMask&(1<<SDLControllerButtonRightShoulder) != 0 { if buttonMask&(1<<SDLControllerButtonRightShoulder) != 0 {
gamepadButtonMappings[id][driver.StandardGamepadButtonFrontTopRight] = &mapping{ gamepadButtonMappings[id][StandardButtonFrontTopRight] = &mapping{
Type: mappingTypeButton, Type: mappingTypeButton,
Index: SDLControllerButtonRightShoulder, Index: SDLControllerButtonRightShoulder,
} }
} }
if buttonMask&(1<<SDLControllerButtonDpadUp) != 0 { if buttonMask&(1<<SDLControllerButtonDpadUp) != 0 {
gamepadButtonMappings[id][driver.StandardGamepadButtonLeftTop] = &mapping{ gamepadButtonMappings[id][StandardButtonLeftTop] = &mapping{
Type: mappingTypeButton, Type: mappingTypeButton,
Index: SDLControllerButtonDpadUp, Index: SDLControllerButtonDpadUp,
} }
} }
if buttonMask&(1<<SDLControllerButtonDpadDown) != 0 { if buttonMask&(1<<SDLControllerButtonDpadDown) != 0 {
gamepadButtonMappings[id][driver.StandardGamepadButtonLeftBottom] = &mapping{ gamepadButtonMappings[id][StandardButtonLeftBottom] = &mapping{
Type: mappingTypeButton, Type: mappingTypeButton,
Index: SDLControllerButtonDpadDown, Index: SDLControllerButtonDpadDown,
} }
} }
if buttonMask&(1<<SDLControllerButtonDpadLeft) != 0 { if buttonMask&(1<<SDLControllerButtonDpadLeft) != 0 {
gamepadButtonMappings[id][driver.StandardGamepadButtonLeftLeft] = &mapping{ gamepadButtonMappings[id][StandardButtonLeftLeft] = &mapping{
Type: mappingTypeButton, Type: mappingTypeButton,
Index: SDLControllerButtonDpadLeft, Index: SDLControllerButtonDpadLeft,
} }
} }
if buttonMask&(1<<SDLControllerButtonDpadRight) != 0 { if buttonMask&(1<<SDLControllerButtonDpadRight) != 0 {
gamepadButtonMappings[id][driver.StandardGamepadButtonLeftRight] = &mapping{ gamepadButtonMappings[id][StandardButtonLeftRight] = &mapping{
Type: mappingTypeButton, Type: mappingTypeButton,
Index: SDLControllerButtonDpadRight, Index: SDLControllerButtonDpadRight,
} }
} }
if axisMask&(1<<SDLControllerAxisLeftX) != 0 { if axisMask&(1<<SDLControllerAxisLeftX) != 0 {
gamepadAxisMappings[id][driver.StandardGamepadAxisLeftStickHorizontal] = &mapping{ gamepadAxisMappings[id][StandardAxisLeftStickHorizontal] = &mapping{
Type: mappingTypeAxis, Type: mappingTypeAxis,
Index: SDLControllerAxisLeftX, Index: SDLControllerAxisLeftX,
AxisScale: 1, AxisScale: 1,
@ -686,7 +684,7 @@ func addAndroidDefaultMappings(id string) bool {
} }
} }
if axisMask&(1<<SDLControllerAxisLeftY) != 0 { if axisMask&(1<<SDLControllerAxisLeftY) != 0 {
gamepadAxisMappings[id][driver.StandardGamepadAxisLeftStickVertical] = &mapping{ gamepadAxisMappings[id][StandardAxisLeftStickVertical] = &mapping{
Type: mappingTypeAxis, Type: mappingTypeAxis,
Index: SDLControllerAxisLeftY, Index: SDLControllerAxisLeftY,
AxisScale: 1, AxisScale: 1,
@ -694,7 +692,7 @@ func addAndroidDefaultMappings(id string) bool {
} }
} }
if axisMask&(1<<SDLControllerAxisRightX) != 0 { if axisMask&(1<<SDLControllerAxisRightX) != 0 {
gamepadAxisMappings[id][driver.StandardGamepadAxisRightStickHorizontal] = &mapping{ gamepadAxisMappings[id][StandardAxisRightStickHorizontal] = &mapping{
Type: mappingTypeAxis, Type: mappingTypeAxis,
Index: SDLControllerAxisRightX, Index: SDLControllerAxisRightX,
AxisScale: 1, AxisScale: 1,
@ -702,7 +700,7 @@ func addAndroidDefaultMappings(id string) bool {
} }
} }
if axisMask&(1<<SDLControllerAxisRightY) != 0 { if axisMask&(1<<SDLControllerAxisRightY) != 0 {
gamepadAxisMappings[id][driver.StandardGamepadAxisRightStickVertical] = &mapping{ gamepadAxisMappings[id][StandardAxisRightStickVertical] = &mapping{
Type: mappingTypeAxis, Type: mappingTypeAxis,
Index: SDLControllerAxisRightY, Index: SDLControllerAxisRightY,
AxisScale: 1, AxisScale: 1,
@ -710,7 +708,7 @@ func addAndroidDefaultMappings(id string) bool {
} }
} }
if axisMask&(1<<SDLControllerAxisTriggerLeft) != 0 { if axisMask&(1<<SDLControllerAxisTriggerLeft) != 0 {
gamepadButtonMappings[id][driver.StandardGamepadButtonFrontBottomLeft] = &mapping{ gamepadButtonMappings[id][StandardButtonFrontBottomLeft] = &mapping{
Type: mappingTypeAxis, Type: mappingTypeAxis,
Index: SDLControllerAxisTriggerLeft, Index: SDLControllerAxisTriggerLeft,
AxisScale: 1, AxisScale: 1,
@ -718,7 +716,7 @@ func addAndroidDefaultMappings(id string) bool {
} }
} }
if axisMask&(1<<SDLControllerAxisTriggerRight) != 0 { if axisMask&(1<<SDLControllerAxisTriggerRight) != 0 {
gamepadButtonMappings[id][driver.StandardGamepadButtonFrontBottomRight] = &mapping{ gamepadButtonMappings[id][StandardButtonFrontBottomRight] = &mapping{
Type: mappingTypeAxis, Type: mappingTypeAxis,
Index: SDLControllerAxisTriggerRight, Index: SDLControllerAxisTriggerRight,
AxisScale: 1, AxisScale: 1,