aboutsummaryrefslogtreecommitdiff
path: root/src/library_sdl.js
diff options
context:
space:
mode:
authorMichael Riss <Michael.Riss@gmx.de>2013-02-20 01:09:18 +0100
committerMichael Riss <Michael.Riss@gmx.de>2013-03-06 10:43:17 +0100
commitb6032ff72c81c4768ece98f9c31708af95b96863 (patch)
tree9eac01ff624b3e3e97663891c20463f54d2f3a74 /src/library_sdl.js
parent0b364c0894cafda3c925639a9835c67c36bbc882 (diff)
- fixed formatting issues
- bugfix: an existing pointerLockChange handler now gets properly removed before it is installed anew - completed the implementation of the SDL_ShowCursor() function: - can now query the current state of the cursor/pointer - properly delivers adequate return values - added safeguard: when not in fullscreen mode, attempts to lock the pointer are ignored as they would fail due to the security model of the browser and a return value indicating the error is returned Signed-off-by: Michael Riss <Michael.Riss@gmx.de>
Diffstat (limited to 'src/library_sdl.js')
-rw-r--r--src/library_sdl.js27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/library_sdl.js b/src/library_sdl.js
index ec3c5455..99189d8a 100644
--- a/src/library_sdl.js
+++ b/src/library_sdl.js
@@ -661,8 +661,8 @@ var LibrarySDL = {
{{{ makeSetValue('ret+Runtime.QUANTUM_SIZE*0', '0', '0', 'i32') }}} // TODO
{{{ makeSetValue('ret+Runtime.QUANTUM_SIZE*1', '0', '0', 'i32') }}} // TODO
{{{ makeSetValue('ret+Runtime.QUANTUM_SIZE*2', '0', '0', 'void*') }}}
- {{{ makeSetValue('ret+Runtime.QUANTUM_SIZE*3', '0', 'Module[\'canvas\'].width', 'i32') }}}
- {{{ makeSetValue('ret+Runtime.QUANTUM_SIZE*4', '0', 'Module[\'canvas\'].height', 'i32') }}}
+ {{{ makeSetValue('ret+Runtime.QUANTUM_SIZE*3', '0', 'Module["canvas"].width', 'i32') }}}
+ {{{ makeSetValue('ret+Runtime.QUANTUM_SIZE*4', '0', 'Module["canvas"].height', 'i32') }}}
return ret;
},
@@ -919,10 +919,25 @@ var LibrarySDL = {
},
SDL_ShowCursor: function(toggle) {
- if(toggle){
- Module['canvas'].exitPointerLock();
- } else {
- Module['canvas'].requestPointerLock();
+ switch (toggle) {
+ case 0: // SDL_DISABLE
+ if (Browser.isFullScreen) { // only try to lock the pointer when in full screen mode
+ Module['canvas'].requestPointerLock();
+ return 0;
+ } else { // else return SDL_ENABLE to indicate the failure
+ return 1;
+ }
+ break;
+ case 1: // SDL_ENABLE
+ Module['canvas'].exitPointerLock();
+ return 1;
+ break;
+ case -1: // SDL_QUERY
+ return !Browser.pointerLock;
+ break;
+ default:
+ console.log( "SDL_ShowCursor called with unknown toggle parameter value: " + toggle + "." );
+ break;
}
},