mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +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,
|
Type: mappingTypeButton,
|
||||||
Index: SDLControllerButtonBack,
|
Index: SDLControllerButtonBack,
|
||||||
}
|
}
|
||||||
buttonMask &= ^(uint16(1) << SDLControllerButtonBack)
|
buttonMask &^= uint16(1) << SDLControllerButtonBack
|
||||||
}
|
}
|
||||||
if buttonMask&(1<<SDLControllerButtonX) != 0 {
|
if buttonMask&(1<<SDLControllerButtonX) != 0 {
|
||||||
gamepadButtonMappings[id][driver.StandardGamepadButtonRightLeft] = &mapping{
|
gamepadButtonMappings[id][driver.StandardGamepadButtonRightLeft] = &mapping{
|
||||||
|
@ -299,23 +299,23 @@ func OnGamepadAxesOrHatsChanged(deviceID int, axisID int, value float32) {
|
|||||||
hatX := int(math.Round(float64(value)))
|
hatX := int(math.Round(float64(value)))
|
||||||
if hatX < 0 {
|
if hatX < 0 {
|
||||||
v |= hatLeft
|
v |= hatLeft
|
||||||
v &= ^hatRight
|
v &^= hatRight
|
||||||
} else if hatX > 0 {
|
} else if hatX > 0 {
|
||||||
v &= ^hatLeft
|
v &^= hatLeft
|
||||||
v |= hatRight
|
v |= hatRight
|
||||||
} else {
|
} else {
|
||||||
v &= ^(hatLeft | hatRight)
|
v &^= (hatLeft | hatRight)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
hatY := int(math.Round(float64(value)))
|
hatY := int(math.Round(float64(value)))
|
||||||
if hatY < 0 {
|
if hatY < 0 {
|
||||||
v |= hatUp
|
v |= hatUp
|
||||||
v &= ^hatDown
|
v &^= hatDown
|
||||||
} else if hatY > 0 {
|
} else if hatY > 0 {
|
||||||
v &= ^hatUp
|
v &^= hatUp
|
||||||
v |= hatDown
|
v |= hatDown
|
||||||
} else {
|
} else {
|
||||||
v &= ^(hatUp | hatDown)
|
v &^= (hatUp | hatDown)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g.Hats[hid] = v
|
g.Hats[hid] = v
|
||||||
|
Loading…
Reference in New Issue
Block a user