mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
input: Add GamepadButtonMax
This commit is contained in:
parent
623fa5cd24
commit
d62a90dfca
@ -28,7 +28,7 @@ var gamepadAbstractButtons = []abstractButton{
|
|||||||
|
|
||||||
type Input struct {
|
type Input struct {
|
||||||
keyStates [256]int
|
keyStates [256]int
|
||||||
gamepadButtonStates [256]int
|
gamepadButtonStates map[ebiten.GamepadButton]int
|
||||||
gamepadAbstractButtonStates map[abstractButton]int
|
gamepadAbstractButtonStates map[abstractButton]int
|
||||||
gamepadConfig gamepadConfig
|
gamepadConfig gamepadConfig
|
||||||
}
|
}
|
||||||
@ -38,6 +38,9 @@ func (i *Input) StateForKey(key ebiten.Key) int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (i *Input) StateForGamepadButton(b ebiten.GamepadButton) int {
|
func (i *Input) StateForGamepadButton(b ebiten.GamepadButton) int {
|
||||||
|
if i.gamepadButtonStates == nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
return i.gamepadButtonStates[b]
|
return i.gamepadButtonStates[b]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,8 +61,11 @@ func (i *Input) Update() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const gamepadID = 0
|
const gamepadID = 0
|
||||||
for b := range i.gamepadButtonStates {
|
if i.gamepadButtonStates == nil {
|
||||||
if !ebiten.IsGamepadButtonPressed(gamepadID, ebiten.GamepadButton(b)) {
|
i.gamepadButtonStates = map[ebiten.GamepadButton]int{}
|
||||||
|
}
|
||||||
|
for b := ebiten.GamepadButton(0); b <= ebiten.GamepadButtonMax; b++ {
|
||||||
|
if !ebiten.IsGamepadButtonPressed(gamepadID, b) {
|
||||||
i.gamepadButtonStates[b] = 0
|
i.gamepadButtonStates[b] = 0
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
33
gamepad.go
33
gamepad.go
@ -23,20 +23,21 @@ type GamepadButton int
|
|||||||
|
|
||||||
// GamepadButtons
|
// GamepadButtons
|
||||||
const (
|
const (
|
||||||
GamepadButton0 = GamepadButton(ui.GamepadButton0)
|
GamepadButton0 = GamepadButton(ui.GamepadButton0)
|
||||||
GamepadButton1 = GamepadButton(ui.GamepadButton1)
|
GamepadButton1 = GamepadButton(ui.GamepadButton1)
|
||||||
GamepadButton2 = GamepadButton(ui.GamepadButton2)
|
GamepadButton2 = GamepadButton(ui.GamepadButton2)
|
||||||
GamepadButton3 = GamepadButton(ui.GamepadButton3)
|
GamepadButton3 = GamepadButton(ui.GamepadButton3)
|
||||||
GamepadButton4 = GamepadButton(ui.GamepadButton4)
|
GamepadButton4 = GamepadButton(ui.GamepadButton4)
|
||||||
GamepadButton5 = GamepadButton(ui.GamepadButton5)
|
GamepadButton5 = GamepadButton(ui.GamepadButton5)
|
||||||
GamepadButton6 = GamepadButton(ui.GamepadButton6)
|
GamepadButton6 = GamepadButton(ui.GamepadButton6)
|
||||||
GamepadButton7 = GamepadButton(ui.GamepadButton7)
|
GamepadButton7 = GamepadButton(ui.GamepadButton7)
|
||||||
GamepadButton8 = GamepadButton(ui.GamepadButton8)
|
GamepadButton8 = GamepadButton(ui.GamepadButton8)
|
||||||
GamepadButton9 = GamepadButton(ui.GamepadButton9)
|
GamepadButton9 = GamepadButton(ui.GamepadButton9)
|
||||||
GamepadButton10 = GamepadButton(ui.GamepadButton10)
|
GamepadButton10 = GamepadButton(ui.GamepadButton10)
|
||||||
GamepadButton11 = GamepadButton(ui.GamepadButton11)
|
GamepadButton11 = GamepadButton(ui.GamepadButton11)
|
||||||
GamepadButton12 = GamepadButton(ui.GamepadButton12)
|
GamepadButton12 = GamepadButton(ui.GamepadButton12)
|
||||||
GamepadButton13 = GamepadButton(ui.GamepadButton13)
|
GamepadButton13 = GamepadButton(ui.GamepadButton13)
|
||||||
GamepadButton14 = GamepadButton(ui.GamepadButton14)
|
GamepadButton14 = GamepadButton(ui.GamepadButton14)
|
||||||
GamepadButton15 = GamepadButton(ui.GamepadButton15)
|
GamepadButton15 = GamepadButton(ui.GamepadButton15)
|
||||||
|
GamepadButtonMax = GamepadButton15
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user