Browse Source

Initial integration with SDL 2.0.10 (WIP) for Web platform.
Additional credit to Bantukul Olarn for pointing out the offending bits.

Yao Wei Tjong 姚伟忠 6 years ago
parent
commit
9b1d683556
2 changed files with 4 additions and 4 deletions
  1. 2 2
      CMake/Modules/UrhoCommon.cmake
  2. 2 2
      Source/Urho3D/Input/Input.cpp

+ 2 - 2
CMake/Modules/UrhoCommon.cmake

@@ -1135,7 +1135,7 @@ macro (add_html_shell)
             # Create Urho3D custom HTML shell that also embeds our own project logo
             # Create Urho3D custom HTML shell that also embeds our own project logo
             if (NOT EXISTS ${CMAKE_BINARY_DIR}/Source/shell.html)
             if (NOT EXISTS ${CMAKE_BINARY_DIR}/Source/shell.html)
                 file (READ ${EMSCRIPTEN_ROOT_PATH}/src/shell.html HTML_SHELL)
                 file (READ ${EMSCRIPTEN_ROOT_PATH}/src/shell.html HTML_SHELL)
-                string (REPLACE "<!doctype html>" "#!/usr/bin/env ${EMSCRIPTEN_EMRUN_BROWSER}\n<!-- This is a generated file. DO NOT EDIT!-->\n\n<!doctype html>" HTML_SHELL "${HTML_SHELL}")     # Stringify to preserve semicolons
+                string (REPLACE "<!doctype html>" "<!-- This is a generated file. DO NOT EDIT!-->\n\n<!doctype html>" HTML_SHELL "${HTML_SHELL}")     # Stringify to preserve semicolons
                 string (REPLACE "<body>" "<body>\n<script>document.body.innerHTML=document.body.innerHTML.replace(/^#!.*\\n/, '');</script>\n<a href=\"https://urho3d.github.io\" title=\"Urho3D Homepage\"><img src=\"https://urho3d.github.io/assets/images/logo.png\" alt=\"link to https://urho3d.github.io\" height=\"80\" width=\"160\" /></a>\n" HTML_SHELL "${HTML_SHELL}")
                 string (REPLACE "<body>" "<body>\n<script>document.body.innerHTML=document.body.innerHTML.replace(/^#!.*\\n/, '');</script>\n<a href=\"https://urho3d.github.io\" title=\"Urho3D Homepage\"><img src=\"https://urho3d.github.io/assets/images/logo.png\" alt=\"link to https://urho3d.github.io\" height=\"80\" width=\"160\" /></a>\n" HTML_SHELL "${HTML_SHELL}")
                 file (WRITE ${CMAKE_BINARY_DIR}/Source/shell.html "${HTML_SHELL}")
                 file (WRITE ${CMAKE_BINARY_DIR}/Source/shell.html "${HTML_SHELL}")
             endif ()
             endif ()
@@ -1778,7 +1778,7 @@ macro (_setup_target)
         if ((URHO3D_LIB_TYPE STREQUAL MODULE AND ${TARGET_NAME} STREQUAL Urho3D) OR (NOT URHO3D_LIB_TYPE STREQUAL MODULE AND NOT LIB_TYPE))
         if ((URHO3D_LIB_TYPE STREQUAL MODULE AND ${TARGET_NAME} STREQUAL Urho3D) OR (NOT URHO3D_LIB_TYPE STREQUAL MODULE AND NOT LIB_TYPE))
             list (APPEND LINK_FLAGS "-s TOTAL_MEMORY=${EMSCRIPTEN_TOTAL_MEMORY}")
             list (APPEND LINK_FLAGS "-s TOTAL_MEMORY=${EMSCRIPTEN_TOTAL_MEMORY}")
             if (EMSCRIPTEN_ALLOW_MEMORY_GROWTH)
             if (EMSCRIPTEN_ALLOW_MEMORY_GROWTH)
-                list (APPEND LINK_FLAGS "-s ALLOW_MEMORY_GROWTH=1")
+                list (APPEND LINK_FLAGS "-s ALLOW_MEMORY_GROWTH=1 --no-heap-copy")
             endif ()
             endif ()
             if (EMSCRIPTEN_SHARE_DATA)      # MODULE lib type always have this variable enabled
             if (EMSCRIPTEN_SHARE_DATA)      # MODULE lib type always have this variable enabled
                 list (APPEND LINK_FLAGS "--pre-js \"${CMAKE_BINARY_DIR}/Source/pak-loader.js\"")
                 list (APPEND LINK_FLAGS "--pre-js \"${CMAKE_BINARY_DIR}/Source/pak-loader.js\"")

+ 2 - 2
Source/Urho3D/Input/Input.cpp

@@ -51,7 +51,7 @@
 
 
 #include "../DebugNew.h"
 #include "../DebugNew.h"
 
 
-extern "C" int SDL_AddTouch(SDL_TouchID touchID, const char* name);
+extern "C" int SDL_AddTouch(SDL_TouchID touchID, SDL_TouchDeviceType type, const char* name);
 
 
 // Use a "click inside window to focus" mechanism on desktop platforms when the mouse cursor is hidden
 // Use a "click inside window to focus" mechanism on desktop platforms when the mouse cursor is hidden
 #if defined(_WIN32) || (defined(__APPLE__) && !defined(IOS) && !defined(TVOS)) || (defined(__linux__) && !defined(__ANDROID__))
 #if defined(_WIN32) || (defined(__APPLE__) && !defined(IOS) && !defined(TVOS)) || (defined(__linux__) && !defined(__ANDROID__))
@@ -1199,7 +1199,7 @@ void Input::SetTouchEmulation(bool enable)
 
 
             // Add a virtual touch device the first time we are enabling emulated touch
             // Add a virtual touch device the first time we are enabling emulated touch
             if (!SDL_GetNumTouchDevices())
             if (!SDL_GetNumTouchDevices())
-                SDL_AddTouch(0, "Emulated Touch");
+                SDL_AddTouch(0, SDL_TOUCH_DEVICE_INDIRECT_RELATIVE, "Emulated Touch");
         }
         }
         else
         else
             ResetTouches();
             ResetTouches();