Changes

Jump to: navigation, search

Implementing the Mouse Lock API in Firefox

958 bytes added, 20:57, 23 November 2011
High-Level Mouse Lock Implementation Tasks
# No mouse cursor is displayed when the mouse is locked
## Completed
# MouseLockable DOM Implementation, navigator.pointer ([[Notes on MouseLock DOM Implementation Nov 13, 2011]])
## [[void lock (in Element target, optional in VoidCallback successCallback, optional in VoidCallback failureCallback);]]
### Callback implementation
## void unlock ();
### Needs to reset the mouse position back to the original position
## bool islocked ();
### Completed
# Mouse Lock Platform Implementations
## Windows: [http://msdn.microsoft.com/en-us/library/windows/desktop/ms648394%28v=vs.85%29.aspx SetCursorPos(x, y)]
## Mobile?
# mouselocklost event DOM Implementation
## Completed
# Extend MouseEvent DOM implementation with movementX, movementY
## [[Stack Trace for nsDOMMouseEvent::nsDOMMouseEvent ctor]] (created on mouse move)
## [[Stack Trace for nsDOMMouseEvent::GetScreenX]]
## [[Where to store the state info (e.g., previous position) between mouse events?]]
## Completed
# The browser must exit the mouse lock state if the user agent, window, or tab loses focus
## Completed - Full screen is lost during the above action, losing full screen automatically triggers the mouselock's unlock()
# The ESC key should exit mouse lock
## Completed - Same as above
# Mouse lock should only work when in Full Screen Mode
## Completed
# [[Refactor nsIDOMNavigator changes for pointer attribute to be in separate interface]]
# Do we need to add a user pref to enable/disable mouse lock?
# Do we need to do conditional compilation for mouse lock?
# When mouse lock is enabled clientX, clientY, screenX, and screenY must hold constant values as if the mouse did not move at all once mouse lock was entered.
## Needs work - Feel free to work on this one!
# Freeze mouse pointer in centre of window when mouse lock is enabled (e.g., moving the mouse causes an event, but forces the mouse to go back to the original position).
## Almost complete - Awaiting patch
# Proper IDL documentation for navigator.pointer (see example in https://mxr.mozilla.org/mozilla-central/source/dom/interfaces/html/nsIDOMHTMLElement.idl#103), MouseLockable and its methods, MouseLockLost event, etc.
## Needs work - Feel free to work on this one!
# Write a JavaScript library to somehow combine element.mozRequestFullScreen() and navigator.pointer.lock(). It would be good to hide the complexities of doing fullscreen then locking in a single API call.
## Needs work - Feel free to work on this one!
# Convert Rescue Fox to use Mouse Lock, see https://github.com/mozilla/rescuefox
## Needs work - Feel free to work on this one!
# Convert http://cjcliffe.github.com/CubicVR.js/cubicvr/samples/fps_demo/level1.html to use Mouse Lock
## Needs work - Feel free to work on this one!
# Tests, tests, tests. We need tests for all aspects of the spec. List tests we need below:
## Check the mouse cursor during mouse lock and after mouse lock.(Needs content scripts?)## Check that after unlock mouse is reset to original positions.## Test to make sure that mouse lock only occurs when an element is in full screen mode (not F11 or done via the menus). This includes:### Pressing the ESC key### Switching focus to another window## Tests for mouselocklost event
## <test cases go here...>
# Create a tutorial on how to use Mouse Lock, with code examples
## Needs work - Feel free to work on this one!
==Resources==
1
edit

Navigation menu