mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-14 23:17:27 +01:00
inpututil: refactoring: use clear
This commit is contained in:
parent
a6b278d0e5
commit
d6427d63ca
@ -107,31 +107,23 @@ func (i *inputState) update() {
|
|||||||
// Gamepads
|
// Gamepads
|
||||||
|
|
||||||
// Copy the gamepad IDs.
|
// Copy the gamepad IDs.
|
||||||
for id := range i.prevGamepadIDs {
|
clear(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.
|
||||||
for id := range i.prevGamepadButtonDurations {
|
clear(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...)
|
||||||
}
|
}
|
||||||
|
|
||||||
for id := range i.prevStandardGamepadButtonDurations {
|
clear(i.prevStandardGamepadButtonDurations)
|
||||||
delete(i.prevStandardGamepadButtonDurations, id)
|
|
||||||
}
|
|
||||||
for id, ds := range i.standardGamepadButtonDurations {
|
for id, ds := range i.standardGamepadButtonDurations {
|
||||||
i.prevStandardGamepadButtonDurations[id] = append([]int{}, ds...)
|
i.prevStandardGamepadButtonDurations[id] = append([]int{}, ds...)
|
||||||
}
|
}
|
||||||
|
|
||||||
for id := range i.gamepadIDs {
|
clear(i.gamepadIDs)
|
||||||
delete(i.gamepadIDs, id)
|
|
||||||
}
|
|
||||||
i.gamepadIDsBuf = ebiten.AppendGamepadIDs(i.gamepadIDsBuf[:0])
|
i.gamepadIDsBuf = ebiten.AppendGamepadIDs(i.gamepadIDsBuf[:0])
|
||||||
for _, id := range i.gamepadIDsBuf {
|
for _, id := range i.gamepadIDsBuf {
|
||||||
i.gamepadIDs[id] = struct{}{}
|
i.gamepadIDs[id] = struct{}{}
|
||||||
@ -159,35 +151,25 @@ func (i *inputState) update() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for id := range i.gamepadButtonDurations {
|
for id := range i.gamepadButtonDurations {
|
||||||
if _, ok := i.gamepadIDs[id]; !ok {
|
clear(i.gamepadButtonDurations[id])
|
||||||
delete(i.gamepadButtonDurations, id)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
for id := range i.standardGamepadButtonDurations {
|
for id := range i.standardGamepadButtonDurations {
|
||||||
if _, ok := i.gamepadIDs[id]; !ok {
|
clear(i.standardGamepadButtonDurations[id])
|
||||||
delete(i.standardGamepadButtonDurations, id)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Touches
|
// Touches
|
||||||
|
|
||||||
// Copy the touch durations and positions.
|
// Copy the touch durations and positions.
|
||||||
for id := range i.prevTouchDurations {
|
clear(i.prevTouchDurations)
|
||||||
delete(i.prevTouchDurations, id)
|
|
||||||
}
|
|
||||||
for id := range i.touchDurations {
|
for id := range i.touchDurations {
|
||||||
i.prevTouchDurations[id] = i.touchDurations[id]
|
i.prevTouchDurations[id] = i.touchDurations[id]
|
||||||
}
|
}
|
||||||
for id := range i.prevTouchPositions {
|
clear(i.prevTouchPositions)
|
||||||
delete(i.prevTouchPositions, id)
|
|
||||||
}
|
|
||||||
for id := range i.touchPositions {
|
for id := range i.touchPositions {
|
||||||
i.prevTouchPositions[id] = i.touchPositions[id]
|
i.prevTouchPositions[id] = i.touchPositions[id]
|
||||||
}
|
}
|
||||||
|
|
||||||
for id := range i.touchIDs {
|
clear(i.touchIDs)
|
||||||
delete(i.touchIDs, id)
|
|
||||||
}
|
|
||||||
i.touchIDsBuf = ebiten.AppendTouchIDs(i.touchIDsBuf[:0])
|
i.touchIDsBuf = ebiten.AppendTouchIDs(i.touchIDsBuf[:0])
|
||||||
for _, id := range i.touchIDsBuf {
|
for _, id := range i.touchIDsBuf {
|
||||||
i.touchIDs[id] = struct{}{}
|
i.touchIDs[id] = struct{}{}
|
||||||
|
Loading…
Reference in New Issue
Block a user