mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 11:48:55 +01:00
inpututil: Optimization
This commit is contained in:
parent
40e662d672
commit
2b77b57b75
@ -97,18 +97,24 @@ func (i *inputState) update() {
|
|||||||
// Gamepads
|
// Gamepads
|
||||||
|
|
||||||
// Copy the gamepad IDs.
|
// Copy the gamepad IDs.
|
||||||
i.prevGamepadIDs = map[ebiten.GamepadID]struct{}{}
|
for id := range i.prevGamepadIDs {
|
||||||
|
delete(i.prevGamepadIDs, id)
|
||||||
|
}
|
||||||
for id := range i.gamepadIDs {
|
for id := range i.gamepadIDs {
|
||||||
i.prevGamepadIDs[id] = struct{}{}
|
i.prevGamepadIDs[id] = struct{}{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy the gamepad button durations.
|
// Copy the gamepad button durations.
|
||||||
i.prevGamepadButtonDurations = map[ebiten.GamepadID][]int{}
|
for id := range i.prevGamepadButtonDurations {
|
||||||
|
delete(i.prevGamepadButtonDurations, id)
|
||||||
|
}
|
||||||
for id, ds := range i.gamepadButtonDurations {
|
for id, ds := range i.gamepadButtonDurations {
|
||||||
i.prevGamepadButtonDurations[id] = append([]int{}, ds...)
|
i.prevGamepadButtonDurations[id] = append([]int{}, ds...)
|
||||||
}
|
}
|
||||||
|
|
||||||
i.gamepadIDs = map[ebiten.GamepadID]struct{}{}
|
for id := range i.gamepadIDs {
|
||||||
|
delete(i.gamepadIDs, id)
|
||||||
|
}
|
||||||
for _, id := range ebiten.GamepadIDs() {
|
for _, id := range ebiten.GamepadIDs() {
|
||||||
i.gamepadIDs[id] = struct{}{}
|
i.gamepadIDs[id] = struct{}{}
|
||||||
if _, ok := i.gamepadButtonDurations[id]; !ok {
|
if _, ok := i.gamepadButtonDurations[id]; !ok {
|
||||||
@ -123,15 +129,11 @@ func (i *inputState) update() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gamepadIDsToDelete := []ebiten.GamepadID{}
|
|
||||||
for id := range i.gamepadButtonDurations {
|
for id := range i.gamepadButtonDurations {
|
||||||
if _, ok := i.gamepadIDs[id]; !ok {
|
if _, ok := i.gamepadIDs[id]; !ok {
|
||||||
gamepadIDsToDelete = append(gamepadIDsToDelete, id)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for _, id := range gamepadIDsToDelete {
|
|
||||||
delete(i.gamepadButtonDurations, id)
|
delete(i.gamepadButtonDurations, id)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Touches
|
// Touches
|
||||||
ids := map[ebiten.TouchID]struct{}{}
|
ids := map[ebiten.TouchID]struct{}{}
|
||||||
|
Loading…
Reference in New Issue
Block a user