mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 10:48:53 +01:00
internal/gamepaddb: fix hat assignments for Android
Now Ebitengine's original mapping works, but the database doesn't work due to differences of button assignments. Fix this later. Updates #2309
This commit is contained in:
parent
521ec6f09b
commit
a9653d1e7a
@ -341,26 +341,30 @@ func toStandardGamepadAxis(str string) (StandardAxis, bool) {
|
||||
}
|
||||
|
||||
func buttonMappings(id string) map[StandardButton]*mapping {
|
||||
if m, ok := gamepadButtonMappings[id]; ok {
|
||||
return m
|
||||
}
|
||||
// TODO: Use the database instead of the original mapping (#2308).
|
||||
// The buttons and axes assignments should be fixed.
|
||||
if currentPlatform == platformAndroid {
|
||||
if addAndroidDefaultMappings(id) {
|
||||
return gamepadButtonMappings[id]
|
||||
}
|
||||
}
|
||||
if m, ok := gamepadButtonMappings[id]; ok {
|
||||
return m
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func axisMappings(id string) map[StandardAxis]*mapping {
|
||||
if m, ok := gamepadAxisMappings[id]; ok {
|
||||
return m
|
||||
}
|
||||
// TODO: Use the database instead of the original mapping (#2308).
|
||||
// The buttons and axes assignments should be fixed.
|
||||
if currentPlatform == platformAndroid {
|
||||
if addAndroidDefaultMappings(id) {
|
||||
return gamepadAxisMappings[id]
|
||||
}
|
||||
}
|
||||
if m, ok := gamepadAxisMappings[id]; ok {
|
||||
return m
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -711,30 +715,32 @@ func addAndroidDefaultMappings(id string) bool {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Assign DPAD buttons correctly (#2308).
|
||||
|
||||
if buttonMask&(1<<SDLControllerButtonDpadUp) != 0 {
|
||||
gamepadButtonMappings[id][StandardButtonLeftTop] = &mapping{
|
||||
Type: mappingTypeButton,
|
||||
Index: SDLControllerButtonDpadUp,
|
||||
Type: mappingTypeHat,
|
||||
Index: 0,
|
||||
HatState: HatUp,
|
||||
}
|
||||
}
|
||||
if buttonMask&(1<<SDLControllerButtonDpadDown) != 0 {
|
||||
gamepadButtonMappings[id][StandardButtonLeftBottom] = &mapping{
|
||||
Type: mappingTypeButton,
|
||||
Index: SDLControllerButtonDpadDown,
|
||||
Type: mappingTypeHat,
|
||||
Index: 0,
|
||||
HatState: HatDown,
|
||||
}
|
||||
}
|
||||
if buttonMask&(1<<SDLControllerButtonDpadLeft) != 0 {
|
||||
gamepadButtonMappings[id][StandardButtonLeftLeft] = &mapping{
|
||||
Type: mappingTypeButton,
|
||||
Index: SDLControllerButtonDpadLeft,
|
||||
Type: mappingTypeHat,
|
||||
Index: 0,
|
||||
HatState: HatLeft,
|
||||
}
|
||||
}
|
||||
if buttonMask&(1<<SDLControllerButtonDpadRight) != 0 {
|
||||
gamepadButtonMappings[id][StandardButtonLeftRight] = &mapping{
|
||||
Type: mappingTypeButton,
|
||||
Index: SDLControllerButtonDpadRight,
|
||||
Type: mappingTypeHat,
|
||||
Index: 0,
|
||||
HatState: HatRight,
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user