I've looked around for a bit and it seems that the best bet currently is to do it in Javascript. The best way would be to do it via a port (or sneakily in the JS if you're the hacker type). I can't figure out a good design for a native library function yet.
That said, given the upcoming promises feature that seems to be around the corner, you'll be able to do the following:
requestPointerLock : Html -> Promise error ()
This function'll do what you think and request to lock the pointer around a given Html element. If it succeeds great, if it fails it'll return some error.
Given how useful this thing is for games, I'll personally add this function myself and publish it to the package manager. Mainly cuz I really want it.
As for the mouse stuff, if you can work around the problem for the moment that would be great. That said, I think that an interesting project would be to fully wrap all of the html5 input apis, including the Gamepad API. That would be done almost entirely via Signals.
About your last observation about the bigger story, I see it as follows:
- Stuff that I consider to be continuously part of my app (like, mouse clicks, keyboard presses, time deltas, etc...) should be Signals. They're basically streams of continuous (or near-continuous) input. This is the stuff that is instantly responsive. This can be implemented via native modules.
- Stuff that I call once in a while and have a feel of like "go do this and return whenever you can... someday..." those I see as Promises. The sort of stuff here is like, "fetch this data from the cache", "send this via http", "ask the gps about my current position", etc... These things take time and run asynchronously. This too can be implemented via native modules. (I admit that certain things fall in the middle: are they Signals or are they Promises... but most things are clear cut)
- Anything else, ports (There's not much left to be honest). I see ports as mostly used to interact with other code in your codebase.
This would be especially useful if you intend to sprinkle just a tiny bit of Elm into a mostly JS codebase and I believe that this was the goal of the design (although Evan should confirm this).
That said, while we're talking about games, ports have another big use : interface with JS code that came from C++/Fortran. You're probably familiar with this, but if you arent, basically there's this thing called Emscripten which allows you to compile C++/Fortran (or anything that can target LLVM) to Javascript. Why do such a thing? Well, game engines and physics engines are mostly written in C++ and super intensive Math for scientific computing is mostly written in Fortran. But these codebases are not at all written with functional programming in mind. This is code written that is really highly optimized, like every bit and cycle is carefully optimized. So it's super imperative. It would be way too much of a headache (trust me, I tried) to wrap these libraries in Elm. Your best bet is simply to communicate with them via ports.
I hope this has answered a bit your question.