diff --git a/conf.lua b/conf.lua index cfb02767..817ef0ea 100644 --- a/conf.lua +++ b/conf.lua @@ -78,6 +78,14 @@ function love.conf(t) -- player to copy their ROM there instead of needing a native file -- picker (LOVE 11.5 on Android has none -- see src/import/RomImporter.lua). t.externalstorage = osName == "Android" + -- LOVE 11.x exposes the phone's accelerometer as a 3-axis joystick by + -- default. Gravity keeps one axis pinned near +/-1.0 whenever the phone + -- is held upright, so it streams past-deadzone joystickaxis events that + -- both hid the touch overlay every instant (it reads as "a controller is + -- in use") and, via the generic-joystick axis mapping (#459), walked the + -- player around by tilt. Nothing in the game reads the accelerometer, + -- so drop the device entirely (#468). + t.accelerometerjoystick = false else t.window.resizable = true end diff --git a/src/core/Game.lua b/src/core/Game.lua index 85324748..694e5c72 100644 --- a/src/core/Game.lua +++ b/src/core/Game.lua @@ -491,21 +491,36 @@ function Game:gamepadaxis(joystick, axis, value) Input:gamepadaxis(joystick, axis, value) end +-- conf.lua turns the mobile accelerometer-joystick off (#468), but guard the +-- generic joystick path anyway: any sensor-style device that still reaches us +-- has gravity pinning an axis past the deadzone, which would hide the touch +-- overlay every instant and steer the player by tilt through the axis-1/2 +-- mapping (#459). Real controllers arrive as SDL gamepads or named sticks, +-- never as "* Accelerometer". +local function isAccelerometer(joystick) + local name = joystick and joystick.getName and joystick:getName() + return name ~= nil and name:lower():find("accelerometer", 1, true) ~= nil +end + function Game:joystickpressed(joystick, button) + if isAccelerometer(joystick) then return end TouchControls:noteGamepad() Input:joystickpressed(joystick, button) end function Game:joystickreleased(joystick, button) + if isAccelerometer(joystick) then return end Input:joystickreleased(joystick, button) end function Game:joystickaxis(joystick, axis, value) + if isAccelerometer(joystick) then return end if math.abs(value) > 0.5 then TouchControls:noteGamepad() end Input:joystickaxis(joystick, axis, value) end function Game:joystickhat(joystick, hat, direction) + if isAccelerometer(joystick) then return end if direction ~= "c" then TouchControls:noteGamepad() end Input:joystickhat(joystick, hat, direction) end