internal/gamepaddb, mobile/ebitenmobileview: refactoring

This commit is contained in:
Hajime Hoshi 2022-02-03 04:35:55 +09:00
parent e1c65d395c
commit d2afbd43cc
2 changed files with 7 additions and 7 deletions

View File

@ -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{

View File

@ -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