Skip to content

RFC: Have OpenTTD *not* lock the cursor position when dragging viewports by default #9150

embeddedt started this conversation in Features
RFC: Have OpenTTD *not* lock the cursor position when dragging viewports by default #9150
Apr 30, 2021 · 1 comment

OpenTTD has historically locked the mouse cursor position when the viewport is being dragged. This feature works on many systems without problems. However, on some platforms (e.g. Emscripten), pointer locking is difficult to implement without drawbacks. In particular, interacting with the Emscripten port currently requires the pointer to be locked inside the browser window all the time, which prevents moving to other applications easily and swiftly.

I explored a workaround for Emscripten in #8654 but the solution there had its own problems.

In that PR, @TrueBrain noted that there is actually an option to allow dragging the viewport without locking the mouse position. It seems that this option was added in #6756 to solve precisely the kind of issue that the Emscripten port is currently having.

The simplest solution would therefore be to make the non-locking option the default - this would make the Emscripten port work intuitively out-of-box, while still retaining legacy behavior for those who find it important.

Some alternatives:

  • Remove support for locking the cursor altogether.
  • Make this mode default, but only on the Emscripten port.



In order to have a proof-of-concept for this change, I've opened #9191.

0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
1 participant