From edff1f0dd9e5b31e524bcaabbfb1a02cba34ffde Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sun, 9 Jan 2022 17:56:54 +0900 Subject: [PATCH] internal/gamepaddb: enable mappings for iOS Updates #1557 Closes #1722 --- internal/gamepaddb/gamepaddb.go | 6 ------ internal/uidriver/mobile/gamepad_ios.go | 5 +++++ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/internal/gamepaddb/gamepaddb.go b/internal/gamepaddb/gamepaddb.go index cd1c9c099..f6db4b9d8 100644 --- a/internal/gamepaddb/gamepaddb.go +++ b/internal/gamepaddb/gamepaddb.go @@ -499,12 +499,6 @@ func Update(mapping []byte) (bool, error) { return false, nil } - // TODO: Implement this (#1722) - if currentPlatform == platformIOS { - // Note: NOT returning an error, as mappings also do not matter right now. - return false, nil - } - mappingsM.Lock() defer mappingsM.Unlock() diff --git a/internal/uidriver/mobile/gamepad_ios.go b/internal/uidriver/mobile/gamepad_ios.go index 027bae2f7..f47a96358 100644 --- a/internal/uidriver/mobile/gamepad_ios.go +++ b/internal/uidriver/mobile/gamepad_ios.go @@ -452,6 +452,7 @@ func (i *Input) updateGamepads() { Name: string(name), ButtonNum: int(property.nButtons), AxisNum: int(property.nAxes), + HatNum: int(property.nHats), } var state C.struct_ControllerState @@ -476,6 +477,10 @@ func (i *Input) updateGamepads() { gamepad.Axes[j] = float32(state.axes[j]) } + if gamepad.HatNum > 0 { + gamepad.Hats[0] = int(state.hat) + } + i.gamepads = append(i.gamepads, gamepad) } }