VaKeR CYBER ARMY
Logo of a company Server : Apache/2.4.41 (Ubuntu)
System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Directory :  /usr/share/emscripten/src/experimental/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/share/emscripten/src/experimental/sdl_key_forwarding.diff
diff --git a/src/library_sdl.js b/src/library_sdl.js
index 8cb8db7..d46a089 100644
--- a/src/library_sdl.js
+++ b/src/library_sdl.js
@@ -43,6 +43,7 @@ var LibrarySDL = {
     DOMButtons: [0, 0, 0],
 
     DOMEventToSDLEvent: {},
+    forwardedDOMKeys: {},
 
     keyCodes: { // DOM code ==> SDL code. See https://developer.mozilla.org/en/Document_Object_Model_%28DOM%29/KeyboardEvent and SDL_keycode.h
       46: 127, // SDLK_DEL == '\177'
@@ -372,6 +373,11 @@ var LibrarySDL = {
             if (!SDL.DOMButtons[event.button]) return false; // ignore extra ups, can happen if we leave the canvas while pressing down, then return,
                                                              // since we add a mouseup in that case
             SDL.DOMButtons[event.button] = 0;
+          } else if (event.type == 'keydown' || event.type == 'keyup') {
+            // whitelist a few keycodes that we do want to let the browser handle
+            if (event.keyCode in SDL.forwardedDOMKeys) {
+              return true;
+            }
           }
 
           SDL.events.push(event);
@@ -399,6 +405,10 @@ var LibrarySDL = {
           // Force-run a main event loop, since otherwise this event will never be caught!
           Browser.mainLoop.runner();
           return true;
+        case 'keypress':
+          if (event.ctrlKey) {
+            return true; // forward control-X events, see SDL.forwardedDOMKeys
+          }
       }
       return false;
     },
@@ -569,13 +579,20 @@ var LibrarySDL = {
     window.onunload = SDL.receiveEvent;
     SDL.keyboardState = _malloc(0x10000);
     _memset(SDL.keyboardState, 0, 0x10000);
-    // Initialize this structure carefully for closure
+    // Initialize these structures carefully for closure
     SDL.DOMEventToSDLEvent['keydown'] = 0x300 /* SDL_KEYDOWN */;
     SDL.DOMEventToSDLEvent['keyup'] = 0x301 /* SDL_KEYUP */;
     SDL.DOMEventToSDLEvent['mousedown'] = 0x401 /* SDL_MOUSEBUTTONDOWN */;
     SDL.DOMEventToSDLEvent['mouseup'] = 0x402 /* SDL_MOUSEBUTTONUP */;
     SDL.DOMEventToSDLEvent['mousemove'] = 0x400 /* SDL_MOUSEMOTION */;
     SDL.DOMEventToSDLEvent['unload'] = 0x100 /* SDL_QUIT */;
+    SDL.forwardedDOMKeys[17] = 1; // control - forward control-X to keep the page responsive
+    SDL.forwardedDOMKeys[173] = 1; // minus (shrink view)
+    SDL.forwardedDOMKeys[61] = 1; // plus (expand view)
+    SDL.forwardedDOMKeys[48] = 1; // 0 (return view to normal)
+    SDL.forwardedDOMKeys[84] = 1; // t (new tab)
+    SDL.forwardedDOMKeys[87] = 1; // w (close tab)
+    SDL.forwardedDOMKeys[82] = 1; // r (reload)
     return 0; // success
   },
 

VaKeR 2022