mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-12 20:18:59 +01:00
internal/gamepaddb, mobile/ebitenmobileview: refactoring
This commit is contained in:
parent
e1c65d395c
commit
d2afbd43cc
@ -594,7 +594,7 @@ func addAndroidDefaultMappings(id string) bool {
|
||||
Type: mappingTypeButton,
|
||||
Index: SDLControllerButtonBack,
|
||||
}
|
||||
buttonMask &= ^(uint16(1) << SDLControllerButtonBack)
|
||||
buttonMask &^= uint16(1) << SDLControllerButtonBack
|
||||
}
|
||||
if buttonMask&(1<<SDLControllerButtonX) != 0 {
|
||||
gamepadButtonMappings[id][driver.StandardGamepadButtonRightLeft] = &mapping{
|
||||
|
@ -299,23 +299,23 @@ func OnGamepadAxesOrHatsChanged(deviceID int, axisID int, value float32) {
|
||||
hatX := int(math.Round(float64(value)))
|
||||
if hatX < 0 {
|
||||
v |= hatLeft
|
||||
v &= ^hatRight
|
||||
v &^= hatRight
|
||||
} else if hatX > 0 {
|
||||
v &= ^hatLeft
|
||||
v &^= hatLeft
|
||||
v |= hatRight
|
||||
} else {
|
||||
v &= ^(hatLeft | hatRight)
|
||||
v &^= (hatLeft | hatRight)
|
||||
}
|
||||
} else {
|
||||
hatY := int(math.Round(float64(value)))
|
||||
if hatY < 0 {
|
||||
v |= hatUp
|
||||
v &= ^hatDown
|
||||
v &^= hatDown
|
||||
} else if hatY > 0 {
|
||||
v &= ^hatUp
|
||||
v &^= hatUp
|
||||
v |= hatDown
|
||||
} else {
|
||||
v &= ^(hatUp | hatDown)
|
||||
v &^= (hatUp | hatDown)
|
||||
}
|
||||
}
|
||||
g.Hats[hid] = v
|
||||
|
Loading…
Reference in New Issue
Block a user