You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#lockdown Nick.Penwarden ========================== MAJOR FEATURES + CHANGES ========================== Change 3292174 on 2017/02/08 by Nick.Shin HTML5 emscripten: wasm and webgl2 support - Linux toolchain #jira UEPLAT-1437 Switch [to] web assembly Change 3292193 on 2017/02/08 by Nick.Shin HTML5 emscripten: wasm and webgl2 support - ThirdParty libs compiled with new toolchain with wasm support #jira UEPLAT-1437 Switch [to] web assembly Change 3292215 on 2017/02/08 by Nick.Shin HTML5 emscripten: wasm and wbegl2 support - emscripten toolchain #jira UEPLAT-1437 Switch [to] web assembly Change 3292222 on 2017/02/08 by Nick.Shin HTML5 emscripten: wasm support - ENGINE changes (c# & cpp files) #jira UEPLAT-1437 Switch [to] web assembly Change 3292223 on 2017/02/08 by Nick.Shin HTML5 merge ThirdParty lib build scripts from Dev-Platform to Dev-Mobile Change 3292228 on 2017/02/08 by Nick.Shin HTML5 emscripten: webgl support - webgl patches - and a lot of UE4 patches to package HTML5 on LINUX - mostly from mozilla's jukka -- thx jukka! #jira UEPLAT-828 (4.16) Support ES3 / WebGL2 in HTML5 Change 3292285 on 2017/02/08 by Nick.Shin HTML5 emscripten: wasm and webgl2 support - Windows toolchain #jira UEPLAT-1437 Switch [to] web assembly Change 3293994 on 2017/02/09 by Nick.Shin HTML5 emscripten: wasm and webgl2 support - OSX toolchain #jira UEPLAT-1437 Switch [to] web assembly Change 3294391 on 2017/02/09 by Nick.Shin HTML5 "black box issues" revisited - jukka rewrote the window resize handler -- much cleaner and more straightforward #jira UE-36341 HTML5 - View is incorrectly drawn #jira UE-32311 Templates on Firefox/Chrome on HTML5 are not full screen during Launch On Change 3296421 on 2017/02/10 by Jack.Porter Fix landscape spline segment splitting placing when using streaming levels Change 3296587 on 2017/02/10 by Jack.Porter Additional fix for landscape spline segment splitting when using streaming levels Change 3301241 on 2017/02/14 by Mi.Wang Fixed DeviceProfileEditor bug for incorrect clamp the Texture Mip LOD size. #jira UE-36237 #rb jack.porter Change 3301387 on 2017/02/14 by Nick.Shin HTML5 emscripten: webgl support - webgl patches from mozilla's jukka + hardware instancing + glBlitFramebuffer + GL AlaphaBlendOperation #jira UEPLAT-828 (4.16) Support ES3 / WebGL2 in HTML5 Change 3301405 on 2017/02/14 by Nick.Shin HTML5 plugin fix when blueprint projects are promoted to code projects automatically. #jira UE-41710 HTML5 - Package Failure - Failed to Produce item ProjectName-OnlineSubsystemNull.bc Change 3302278 on 2017/02/14 by Omar.Rodriguez UE-36651: Mac Vulkan Android Projects crash on launch. * Glslang library has been built for Mac but flag was not updated * Set GlslangAvailable to true for Mac when building an Android project with vulkan #jira UE-36651 Change 3302773 on 2017/02/14 by Chris.Babcock Add a dropdown with some common console commands on Android (contributed by rafortis) #jira UE-40834 #PR #3143 #ue4 #android Change 3305604 on 2017/02/16 by Nick.Shin HTML5 webgl2 shader- turn on: instance static mesh vertex factory #jira UEPLAT-828 (4.16) Support ES3 / WebGL2 in HTML5 Change 3308154 on 2017/02/16 by Nick.Shin HTML5 GitHub PR #jira UE-42019 GitHub 3258 : Added suport for emscripten --pre-js and --post-js option when building for HTML5 Change 3308510 on 2017/02/16 by Nick.Shin HTML5 webgl2 shader fixes #jria UEMOB-201 Support ES3 / WebGL2 in HTML5 Change 3308971 on 2017/02/17 by Jack.Porter Fix for landscape painting when height<0 in the Ortho viewports Change 3309075 on 2017/02/17 by Allan.Bentham Include static subject meshes when masking out modulated shadow casters. #jira UE-41581 Change 3309531 on 2017/02/17 by Chris.Babcock Handle large OBB files in APK #jira UE-41443 #ue4 #android Change 3311320 on 2017/02/19 by Dmitriy.Dyomin Fixed: Particle Cutout Crashes On Mobile Devices That Don't Support Hardware Instancing (Mali-400 GPU) #jira UE-41970 Change 3311347 on 2017/02/20 by Dmitriy.Dyomin Fixed: Engine Crashes When Previewing ES3_1 With Material Using World Position Offset (Need Custom Stencil) #jira UE-41976 Change 3311398 on 2017/02/20 by Dmitriy.Dyomin Fixed: Landscapes do not render on PowerVR device #jira UE-35530 Change 3311428 on 2017/02/20 by Dmitriy.Dyomin Fixed: Exposure Is More Extreme In High-End Mobile Preview Modes #jira UE-42036 Change 3311448 on 2017/02/20 by Dmitriy.Dyomin Fixed: Packaged game Crashes on android after entering "Help" command twice #jira UE-41956 Change 3311587 on 2017/02/20 by Allan.Bentham ES2 GLSL - Silently swap all uint to ints #jira UE-41548 Change 3313930 on 2017/02/21 by Allan.Bentham Print literal uints as ints when generating ES2 code. #jira UE-41548 Change 3317924 on 2017/02/22 by Nick.Shin HTML5 emscripten: wasm & webgl2 support - RC1 - Linux toolchain #jira UEMOB-263 Switch [to] web assembly #jira UEMOB-201 Support ES3 / WebGL2 in HTML5 Change 3317929 on 2017/02/22 by Nick.Shin HTML5 emscripten: wasm & webgl2 support - RC1 - ThirdParty libs compiled with new toolchain with wasm and webgl2 support #jira UEMOB-263 Switch [to] web assembly #jira UEMOB-201 Support ES3 / WebGL2 in HTML5 Change 3317951 on 2017/02/22 by Nick.Shin HTML5 emscripten: wasm & webgl2 support - RC1 - emscripten toolchain WARNING: emscripten/incoming/source/include/libc/bit (the file) might need to be deleted first #jira UEMOB-263 Switch [to] web assembly #jira UEMOB-201 Support ES3 / WebGL2 in HTML5 Change 3318004 on 2017/02/22 by Nick.Shin HTML5 emscripten: wasm & webgl2 support - RC1 - windows toolchain #jira UEMOB-263 Switch [to] web assembly #jira UEMOB-201 Support ES3 / WebGL2 in HTML5 Change 3318669 on 2017/02/23 by Nick.Shin HTML5 emscripten: wasm & webgl2 support - RC1 - OSX toolchain #jira UEMOB-263 Switch [to] web assembly #jira UEMOB-201 Support ES3 / WebGL2 in HTML5 Change 3318672 on 2017/02/23 by Nick.Shin HTML5 webgl2 shader fixes #jria UEMOB-201 Support ES3 / WebGL2 in HTML5 Change 3318819 on 2017/02/23 by Dmitriy.Dyomin Fixed: Rendering artifacts with bloom on iPhone7 Metal #jira UE-40978 Change 3319702 on 2017/02/23 by Chris.Babcock Disable eglSwapInterval since it can cause issues with some drivers #ue4 #android Change 3320880 on 2017/02/24 by Dmitriy.Dyomin Added r.Mobile.TonemapperFilm cvar which can be used to enable/disable filmic tonemapper on mobile, independently from desktop (disabled by default) #jira UEMOB-195 Change 3321042 on 2017/02/24 by Jack.Porter Fixed incorrect sizeof in Vulkan pipleine cache pointed out here: http://coconutlizard.co.uk/blog/ue4/ue4-its-a-size-jim/ #code_review: rolando.caloca Change 3322383 on 2017/02/24 by Chris.Babcock Fix issue with ad banner on Android 7.0 devices #jira UE-42390 #ue4 #android Change 3322479 on 2017/02/24 by Omar.Rodriguez UEMOB-199 - WEX: Improved virtual keyboard for Android * Calculating the area covered by the virtual keyboard * Calling OnVirtualKeyboardShown and OnVirtualKeyboardHidden events * Passing the Rect of the area covered by the virtual keyboard OnVirtualKeyboardShown event #jira UEMOB-199 Change 3323353 on 2017/02/27 by Allan.Bentham Fix broken mobile scene captures when !mobileHDR and RHINeedsToSwitchVerticalAxis #jira UE-42191 Change 3323431 on 2017/02/27 by Allan.Bentham CIS fix Change 3323687 on 2017/02/27 by Allan.Bentham Disable GRHINeedsUnatlasedCSMDepthsWorkaround for mobile devices. #jira UE-42131 Change 3324652 on 2017/02/28 by Dmitriy.Dyomin Fixed: Canvas elements appear darker on iOS Metal Change 3324885 on 2017/02/28 by Jack.Porter Fixed "Minimum iOS Version" setting display name #jira UE-42270 Change 3324899 on 2017/02/28 by Jack.Porter GitHub 3063 : removed duplicate gc.MaxObjectsInGame setting in IOSEngine.ini #jira UE-40018 #3063 Change 3324932 on 2017/02/28 by Jack.Porter GitHub 3257 : iPhonePackager errors in output log when opening project settings on Windows #jira UE-41984 #3257 #codereview: Peter.Sauerbrei Change 3324956 on 2017/02/28 by Jack.Porter FOpenGLFrontend::GetMaxSamplers incorrect for IOS #jira UE-42038 #3264 Change 3325478 on 2017/02/28 by Allan.Bentham PR # 3188 : Fix far distance bug with cascaded shadows on mobile (Metal) and PC mobile preview (Contributed by ufna) #jira UE-41442 Change 3327300 on 2017/03/01 by Allan.Bentham PR #3175 : Fixes high quality reflection blending seams (Contributed by kallehamalainen) #jira UE-41257 Change 3328917 on 2017/03/02 by Nick.Shin HTML5 project settings expose ini settings to edtior HTML5 project settings panel #jira UE-42331 Project Settings - HTML5 SDK - HTML Device population should be moved to an .ini #jira UE-41584 Editor locks up when adding an element for HTML5 devices on Mac #jira UE-41701 Editor freezes when setting browser filepath for inserted element in project settings Change 3329169 on 2017/03/02 by Allan.Bentham increase render thread timeout to 1 minute for suntemple / android. Prevents low end devices timing out during load. #jira UE-40696 Change 3330849 on 2017/03/02 by Nick.Shin HTML5 project settings expose ini settings to edtior HTML5 project settings panel #jira UE-42331 Project Settings - HTML5 SDK - HTML Device population should be moved to an .ini Change 3331078 on 2017/03/03 by Dmitriy.Dyomin Fixed: Device output log partial lines integrated from WEX (3250488) Change 3331112 on 2017/03/03 by Dmitriy.Dyomin Reduced state setup for slate draw calls (saves about 4ms RT time on mobile) integrated from WEX (3256584) Change 3331117 on 2017/03/03 by Dmitriy.Dyomin Fixed redundant blend state changes in opengl integrated from WEX (3256586) Change 3331173 on 2017/03/03 by Dmitriy.Dyomin Slate pixel shaders will use half precision where possible on mobile integrated from WEX (3256656) Change 3332865 on 2017/03/06 by Dmitriy.Dyomin Better MobileContentScaleFactor defaults for iOS devices #jira UEMOB-330 Change3333129on 2017/03/06 by Peter.Sauerbrei move to Library/Caches instead of documents for saved files re-enable iterative deploy on TVOS #jira UEMOB-284 Change 3334692 on 2017/03/06 by Jack.Porter Allow r.MobileContentScaleFactor to be changed at runtime on Android #jira UEMOB-173 Change 3336255 on 2017/03/07 by Nick.Shin HTML5 project settings marking SIMD and multithreading as experimental - these do not play nice with WASM builds currently... #jira UE-42331 Project Settings - HTML5 SDK - HTML Device population should be moved to an .ini Change 3337094 on 2017/03/08 by Nick.Shin HTML5 project settings marking SIMD and multithreading as experimental - these do not play nice with WASM builds currently... #jira UE-42331 Project Settings - HTML5 SDK - HTML Device population should be moved to an .ini Change 3338800 on 2017/03/08 by Chris.Babcock Update AAR handling to deal with versioning, subproject dependencies for resources, and scope #jira UE-42677 #ue4 #android Change 3338813 on 2017/03/08 by Chris.Babcock Pass build configuration to UPL for access during packaging as $S(Configuration) #jira UE-42678 #ue4 #android #ios Change 3339401 on 2017/03/09 by Alicia.Cano Android runtime permissions - Fix for WRITE_EXTERNAL_STORAGE if it is not granted at time of onCreate for non-shipping builds - Fix for Location Services - Fix for if target sdk is not set to 23+ #jira UE-38512 #android #rb: chris.babcock Change 3340736 on 2017/03/09 by Chris.Babcock Implement support for new controllers (Xbox Wireless, SteelSeries Stratus XL, PS4) (contributed by TRS-justing) #jira UE-41965 #PR #3254 #ue4 #android Change 3340744 on 2017/03/09 by Jack.Porter Expose Custom Depth to Foliage #jira UE-6061 Change 3340849 on 2017/03/09 by Dmitriy.Dyomin Fixed: iOS movie become laggy and crashes when played in iPhone 6/6s. #jira UE-42351 Change 3341268 on 2017/03/10 by Alicia.Cano PR #2894: Initial VoiceModuleAndroid support. (Contributed by devbm) #jira UE-37945 #android #rb: chris.babcock, jack.porter Change 3341303 on 2017/03/10 by Allan.Bentham Remove optimisation that prevents full specular occulsion on mobile. PR #3186 : Specular can't be blocked on high-end mobile. #jira UE-41393 Change 3342304 on 2017/03/10 by Alicia.Cano build fix #rb: chris.babcock Change 3343344 on 2017/03/13 by Alicia.Cano build fix #rb: chris.babcock Change 3343591 on 2017/03/13 by Brent.Pease iOS multiplayer fix part 1. Correct byte ordering. #jira UE-34875 Change 3343669 on 2017/03/13 by Chris.Babcock Update carefullyredist script version #jira UE-42832 Change 3344212 on 2017/03/13 by Will.Fissler Various compile fixes for Xcode 8.3. These fixes must also be added to //UE4/Release-4.15. #jira UE-41313 Change 3344396 on 2017/03/13 by Chris.Babcock Fix Java 1.5 obsolete warnings #jira UE-42851 #ue4 #android Change 3345132 on 2017/03/14 by Will.Fissler Added ifdef wrapper to check clang version for presentDrawable. Change 3345336 on 2017/03/14 by Will.Fissler Moved #if (__clang_major__ > 8) || (__clang_major__ == 8 && __clang_minor__ >= 1) check inside of the presentDrawable method. Change 3345460 on 2017/03/14 by Will.Fissler ifdef changes for presentDrawable. The last submission duped the changes, instead of merging. #rb none Change 3346046 on 2017/03/14 by Will.Fissler Fixed MetalCommandBuffer.cpp [again] after last submission duped changes instead of merging. Change 3346367 on 2017/03/14 by Chris.Babcock Fix issue with GoogleVR ARMv7 libraries included for other architectures in link #ue4 #android Change 3347682 on 2017/03/15 by Allan.Bentham Enable HW sRGB correction with retainer widget's render target. Use slate's gamma correction for mobile (where no such support exists) Render retainer box RT content with gamma correction. #jira UE-40967 Change 3348712 on 2017/03/15 by Nick.Shin HTML5 - upload to S3 updated to AWS "signature version 4" authentication #jira UE-42525 HTML5 Upload to Amazon S3 fails with Incorrect Configuration error Change 3349254 on 2017/03/16 by Jack.Porter Fix for crash using the mobile previewer when the LQ lightmap shader permutation is disabled. #jira UE-42971 Change 3349739 on 2017/03/16 by Nick.Shin HTML5 - upload to S3 better error message feedback on upload failures #jira UE-42525 HTML5 Upload to Amazon S3 fails with Incorrect Configuration error Change 3349765 on 2017/03/16 by Alicia.Cano Disable mouseover events in Mobile Previewer #jira UE-19903 #mobile #rb: Jack.Porter Change 3350049 on 2017/03/16 by Nick.Shin HTML5 - upload to S3 folder in bucket is optional #jira UE-42525 HTML5 Upload to Amazon S3 fails with Incorrect Configuration error Change 3350153 on 2017/03/16 by Nick.Shin HTML5 - upload to S3 updated S3 public link generator #jira UE-42525 HTML5 Upload to Amazon S3 fails with Incorrect Configuration error Change 3351582 on 2017/03/17 by Will.Fissler Reverting the attempted fix for Xcode 8.3: Result += " -mcpu=cortex-a9"; Currently we cannot build arm64 for iOS with this change. Change 3352085 on 2017/03/17 by Alicia.Cano iOS doesn't honor request to close the virtual keyboard leading to a crash #jira UE-36447 #ios #rb:Peter.Sauerbrei Change 3353313 on 2017/03/19 by Ben.Marsh Always allow large *.js files in Github. Change 3354444 on 2017/03/20 by Nick.Shin HTML5 - upload to S3 to help make it obvious that "upload to S3" checkbox is set/or not -- disable S3 details if checkbox for "uploading to S3" is not set #jira UE-42525 HTML5 Upload to Amazon S3 fails with Incorrect Configuration error Change 3355618 on 2017/03/20 by Nick.Shin HTML5 Save Game System - ripped out HTML5 code [from Engine's SaveGameSystem.h] and placed it in HTML5Platform.cpp - cleaned up HTML5PlatformFile.cpp (make it match as clost to linux's version) - created HTML5's own PlatformFeature & SaveGameSystem files -- and updated HTML5PlatformMisc to make use of the the new HTML5 SaveGame code #jira UE-42081 Remove heinous HTML5 code from engine Change 3355621 on 2017/03/20 by Nick.Shin remove temp debugging code #jira UE-42081 Remove heinous HTML5 code from engine Change 3356937 on 2017/03/21 by Chris.Babcock Add "stat vulkanrhi" to new console dropdown #jira UE-43149 #ue4 #android Change 3357652 on 2017/03/21 by Nick.Shin HTML5 performance speed ups added "use fixed timestep" setting option for HTML5 builds (this has been separated from Engine - General Settings - Framerate) - this is slightly different to smooth framerate and fixed framerate - thus, the timestep option was put in the HTML5 specific panel this option is based on the suggestions by jukka's post: - https://answers.unrealengine.com/questions/409629/smooth-frame-rate-and-use-fixed-frame-rate-should.html however, using this option will make the player "run faster" on (for example) thirdperson blueprint template -- but, it has no effect on other (for example) zen garden... #jira UE-30214 - Implement a warning message for fps settings Change 3360415 on 2017/03/23 by Allan.Bentham Fix crash that occurs when ES3.1 preview is used with r.MobileHDR32bppMode modes. Change 3360418 on 2017/03/23 by Allan.Bentham Disable filmic tonemapper if r.MobileHDR32bppMode is in use. #jira UE-40913 Change 3360557 on 2017/03/23 by Allan.Bentham Better fix for mobile CSM shadow flickering (UE-42131), now works for PC OpenGL based mobile preview. #jira UE-42131 Change 3362258 on 2017/03/23 by Dmitriy.Dyomin Fixed: Canvas texture element gamma issues on iOS Metal Change 3362321 on 2017/03/24 by Dmitriy.Dyomin GitHub 3173 : MaterialAO support for mobile rendering path (contributed by kallehamalainen) #3173 Change 3363550 on 2017/03/24 by Alicia.Cano build fix for devices < Android 5.0 #jira UE-43299 #android #rb: chris.babcock Change 3363687 on 2017/03/24 by Chris.Babcock Fix Android password hiding in input dialog #jira WEX-5159 #ue4 #android Change 3365280 on 2017/03/27 by Dmitriy.Dyomin Fix for GL_EXT_shader_framebuffer_fetch on Zenfone5. Use UE_EXT_shader_framebuffer_fetch define on all devices to enable extension Change 3365291 on 2017/03/27 by Dmitriy.Dyomin Copied form WEX CL# 3308653 Fixed: Enabling shader cache causes crash on NVIDIA Shield #jira UE-41639 Change 3365293 on 2017/03/27 by Dmitriy.Dyomin GitHub 3411 : Fix crash in patching utils mount method (contributed by nverenik) #jira UE-43247 #3411 Change 3365340 on 2017/03/27 by Dmitriy.Dyomin Fixed: Moving sublevel in world composition browser does not appear in Undo History #jira UE-35535 Change 3365564 on 2017/03/27 by Allan.Bentham SkyLightComponent now serializes IrradianceMap SH values. clicking Recapture sky button in mobile preview switches back to SM4/5 to update captures. Skylights that are dirty from load will trigger reflection capture update once shaders are rebuilt. #jira UE-42436 Change 3366282 on 2017/03/27 by Nick.Shin remove dead links these files to not exist anywhere in the make-3.81 subfolders #UDN-354501 #jira none Change 3366306 on 2017/03/27 by Nick.Shin HTML5 - disable multi-threading for wasm #jira UE-43219 - HTML5 disable multi-threading for wasm Change 3366307 on 2017/03/27 by Nick.Shin HTML5 packaging Shipping builds big cleanup / additions to *gz file support for amazon s3 * both, uploading to s3 * and allowing s3 to host the games there #jira UE-43002 HTML5 in Shipping fails downloading symbols files #jria UE-43001 HTML5 Shipping Projects fail looking for compressed files when "Compress files during shipping packaging" is not selected. Change 3367385 on 2017/03/28 by Allan.Bentham Display skylight serialization warning only when cooking for mobile platforms. #jira UE-42436 Change 3368583 on 2017/03/28 by Chris.Babcock Expose JAVA_HOME setting in Android SDK project settings on Mac #jira UE-43418 #ue4 #android Change 3368803 on 2017/03/28 by Chris.Babcock Fix features requested in manifest for "Daydream and Cardboard" mode #jira UE-43314 #ue4 #android Change 3369087 on 2017/03/28 by Jack.Porter Changed tooltip and added supported devices in paretheses for Android Mobile Deferred / ES31+AEP #jira UE-42438 Change 3369372 on 2017/03/29 by Allan.Bentham Fix disappearing meshes when r.mobile.allowdistancefieldshadows is disabled. #jira UE-43366 Change 3369381 on 2017/03/29 by Jack.Porter Show warnings when mobile shader permutations required for rendering are disbaled Made FReadOnlyCVARCache a singleton and added mobile CVars, used for MobileBasePassRendering. #jira UE-43050 Change 3369430 on 2017/03/29 by Allan.Bentham fix CIS build Change 3369740 on 2017/03/29 by Allan.Bentham Added Android option to enable builds with hidden symbol visbility by default. (bBuildWithHiddenSymbolVisibility) Android links with -gc-sections to remove unused code/data Add JNI_METHOD for java accessible native functions, fixed up existing JNI functions to use macro. Add support for map file generation with android. Add 'bBuildWithHiddenSymbolVisibility' to AndroidPlatform.HasDefaultBuildConfig() bBuildWithHiddenSymbolVisibility defaults to false in BaseEngine.ini #jira UEMOB-168 Change 3369975 on 2017/03/29 by Nick.Shin HTML5 - AWS S3 shareable link for shipping builds corrected #jira UE-43379 Amazon S3 Shareable link does not generate correct filepath. Change 3369998 on 2017/03/29 by Nick.Shin HTML5 python build scripts PR:1cb836d43c#jira none Change 3370214 on 2017/03/29 by Nick.Shin HTML5 - default bUseFixedTimeStep to false... #jira UE-43380 - Default HTML5 gamespeed is faster than equivalent platforms Change 3370762 on 2017/03/29 by Chris.Babcock Fixes to new keyboard for Android - Ensure the local scope ScreenRect passed into OnVirtualKeyboardShown in AndroidJNI is captured by value instead of by reference. - Moved ShowVirtualKeyboardInput's bKeyboardShowing early-out checks into the UI thread task. This allows the keyboard to continue showing when changing focus between multiple EditableTextBox widgets. #ue4 #android Change 3371344 on 2017/03/30 by Jack.Porter Fixed issue where Vulkan screenshot R/B channels were reversed on Android #jira UE-43479 Change 3372926 on 2017/03/30 by Peter.Sauerbrei start the process of sunsetting 32-bit and GLES2 on iOS #jira UE-42266 Change 3372970 on 2017/03/30 by Nick.Shin HTML5 - 1.37.9 emscripten: wasm & webgl2 support - windows toolchain #jira UEMOB-263 Switch [to] web assembly #jira UEMOB-201 Support ES3 / WebGL2 in HTML5 #rn Change 3372989 on 2017/03/30 by Peter.Sauerbrei fix for Xcode 8.3 build with 32-bit Change 3373007 on 2017/03/30 by Peter.Sauerbrei fix for crash when online subsystem is disabled on IOS Change 3373108 on 2017/03/30 by Nick.Shin HTML5 - 1.37.9 emscripten: wasm & webgl2 support - emscripten toolchain WARNING: emscripten/incoming/source/include/libc/bit (the file) might need to be deleted first #jira UEMOB-263 Switch [to] web assembly #jira UEMOB-201 Support ES3 / WebGL2 in HTML5 #rn Change 3373163 on 2017/03/30 by Nick.Shin HTML5 - 1.37.9 emscripten: wasm & webgl2 support - OSX toolchain #jira UEMOB-263 Switch [to] web assembly #jira UEMOB-201 Support ES3 / WebGL2 in HTML5 #rn Change 3373169 on 2017/03/30 by Nick.Shin HTML5 - 1.37.9 emscripten: wasm & webgl2 support license file updated #jira UEMOB-263 Switch [to] web assembly #jira UEMOB-201 Support ES3 / WebGL2 in HTML5 #rnx Change 3373287 on 2017/03/30 by Nick.Shin HTML5 - 1.36.11 emscripten - remove old SDK #jira none #rnx Change 3373289 on 2017/03/30 by Nick.Shin HTML5 - 1.37.9 emscripten: wasm & webgl2 support - Linux toolchain #jira UEMOB-263 Switch [to] web assembly #jira UEMOB-201 Support ES3 / WebGL2 in HTML5 #rn Change 3373595 on 2017/03/30 by Chris.Babcock Reenable GooglePlay for ARM64 now that it doesn't crash #jira UE-36198 #ue4 #android Change 3373606 on 2017/03/30 by Chris.Babcock Submitting Allan's shelved EXT_shader_framebuffer_fetch fix #ue4 #android Change 3375456 on 2017/03/31 by Chris.Babcock Add missing keycodes for Android keyboard (@ and #) #jira WEX-5777 #ue4 #android Change 3376309 on 2017/04/03 by Allan.Bentham Fix overflow issues with mobile DoF. Change 3377041 on 2017/04/03 by Will.Fissler Adding Testbed content for PlatformShowcase. Change 3377582 on 2017/04/03 by Alicia.Cano adding back in GET_ACCOUNTS permission as it is required for Reset Achievements #jira: UE-43265 #android #rb: Chris.Babcock Change 3377643 on 2017/04/03 by Peter.Sauerbrei fix for memory leak in MallocBinned #jira UE-43008 Change 3378033 on 2017/04/04 by Nick.Shin HTML5 - 1.37.9 emscripten: wasm & webgl2 support - ThirdParty libs compiled with new toolchain with wasm and webgl2 support #jira UEMOB-263 Switch [to] web assembly #jira UEMOB-201 Support ES3 / WebGL2 in HTML5 #rn Change 3378034 on 2017/04/04 by Nick.Shin HTML5 - 1.37.9 emscripten: wasm & webgl2 support - ThirdParty build scripts #jira UEMOB-263 Switch [to] web assembly #jira UEMOB-201 Support ES3 / WebGL2 in HTML5 Change 3378035 on 2017/04/04 by Nick.Shin HTML5 - Update GameX template to make it work with trunk Emscripten PRdc2b26f452 (commitcomment-21454978)#jira none #rn Change 3378044 on 2017/04/04 by Nick.Shin HTML5 harfbuzz - double checking recompiled with NO multithreading wasm currently does not support pthreads *** THIS IS STILL WIP *** checking in to match 3rd party libs compiled configuration #jira UE-28588 - Build HarfBuzz for HTML5 #rnx Change 3378264 on 2017/04/04 by Allan.Bentham Fix crash when using consolas font on android sdk 24 #jira UE-43464 Change 3379097 on 2017/04/04 by Nick.Shin CIS HTML5 build warning fix #jria none #rnx Change 3379333 on 2017/04/04 by Chris.Babcock Prevent inserting extra permissions into manifest multiple times #jira UE-43583 #ue4 #android Change 3380870 on 2017/04/05 by Chris.Babcock Fix merge issue Change 3380898 on 2017/04/05 by Chris.Babcock Fixed again Change 3381443 on 2017/04/05 by Chris.Babcock Fix for GearVR non-unity build #ue4 #android Change 3381941 on 2017/04/05 by Chris.Babcock Fix HTTPChunkInstaller texture format checks and missing #define warning #jira UE-43706 #ue4 #android Change 3382056 on 2017/04/05 by Chris.Babcock Updates to Android AARs needed for Facebook plugin Change 3382097 on 2017/04/05 by Chris.Babcock Disable java console cmd receiver only in shipping builds #jira UE-43710 #ue4 #android Change 3382497 on 2017/04/06 by Allan.Bentham Fix Fortnite Cooked Server crashes when joining game from lobby. #jira UE-43695 Change 3383227 on 2017/04/06 by Will.Fissler Reverted case sensitive change, from yesterday, and implemented a pragma instead. #jira UE-41313 [CL 3383473 by Jack Porter in Main branch]
1118 lines
36 KiB
C++
1118 lines
36 KiB
C++
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "Misc/App.h"
|
|
#include "Misc/OutputDeviceError.h"
|
|
#include "LaunchEngineLoop.h"
|
|
#include <string.h>
|
|
#include <jni.h>
|
|
#include <pthread.h>
|
|
#include "AndroidJNI.h"
|
|
#include "AndroidEventManager.h"
|
|
#include "AndroidInputInterface.h"
|
|
#include <android/log.h>
|
|
#include <android_native_app_glue.h>
|
|
#include <cstdio>
|
|
#include <sys/resource.h>
|
|
#include <dlfcn.h>
|
|
#include "AndroidWindow.h"
|
|
#include <android/sensor.h>
|
|
#include "AndroidApplication.h"
|
|
#include "IHeadMountedDisplayModule.h"
|
|
#include "ISessionServicesModule.h"
|
|
#include "ISessionService.h"
|
|
#include "Engine/Engine.h"
|
|
#include "HAL/PlatformFile.h"
|
|
#include "HAL/PlatformAffinity.h"
|
|
#include "Modules/ModuleManager.h"
|
|
#include "IMessagingModule.h"
|
|
|
|
// Function pointer for retrieving joystick events
|
|
// Function has been part of the OS since Honeycomb, but only appeared in the
|
|
// NDK in r19. Querying via dlsym allows its use without tying to the newest
|
|
// NDK.
|
|
typedef float(*GetAxesType)(const AInputEvent*, int32_t axis, size_t pointer_index);
|
|
static GetAxesType GetAxes = NULL;
|
|
|
|
// List of default axes to query for each controller
|
|
// Ideal solution is to call out to Java and enumerate the list of axes.
|
|
static const int32_t AxisList[] =
|
|
{
|
|
AMOTION_EVENT_AXIS_X,
|
|
AMOTION_EVENT_AXIS_Y,
|
|
AMOTION_EVENT_AXIS_Z,
|
|
AMOTION_EVENT_AXIS_RX,
|
|
AMOTION_EVENT_AXIS_RY,
|
|
AMOTION_EVENT_AXIS_RZ,
|
|
|
|
//These are DPAD analogs
|
|
AMOTION_EVENT_AXIS_HAT_X,
|
|
AMOTION_EVENT_AXIS_HAT_Y,
|
|
};
|
|
|
|
// map of all supported keycodes
|
|
static TSet<uint32> MappedKeyCodes;
|
|
|
|
// List of desired gamepad keycodes
|
|
static const uint32 ValidGamepadKeyCodesList[] =
|
|
{
|
|
AKEYCODE_BUTTON_A,
|
|
AKEYCODE_DPAD_CENTER,
|
|
AKEYCODE_BUTTON_B,
|
|
AKEYCODE_BUTTON_C,
|
|
AKEYCODE_BUTTON_X,
|
|
AKEYCODE_BUTTON_Y,
|
|
AKEYCODE_BUTTON_Z,
|
|
AKEYCODE_BUTTON_L1,
|
|
AKEYCODE_BUTTON_R1,
|
|
AKEYCODE_BUTTON_START,
|
|
AKEYCODE_MENU,
|
|
AKEYCODE_BUTTON_SELECT,
|
|
AKEYCODE_BACK,
|
|
AKEYCODE_BUTTON_THUMBL,
|
|
AKEYCODE_BUTTON_THUMBR,
|
|
AKEYCODE_BUTTON_L2,
|
|
AKEYCODE_BUTTON_R2,
|
|
AKEYCODE_DPAD_UP,
|
|
AKEYCODE_DPAD_DOWN,
|
|
AKEYCODE_DPAD_LEFT,
|
|
AKEYCODE_DPAD_RIGHT
|
|
};
|
|
|
|
// map of gamepad keycodes that should be passed forward
|
|
static TSet<uint32> ValidGamepadKeyCodes;
|
|
|
|
// -nostdlib means no crtbegin_so.o, so we have to provide our own __dso_handle and atexit()
|
|
extern "C"
|
|
{
|
|
int atexit(void (*func)(void)) { return 0; }
|
|
|
|
extern void *__dso_handle __attribute__((__visibility__ ("hidden")));
|
|
void *__dso_handle;
|
|
}
|
|
|
|
extern void AndroidThunkCpp_InitHMDs();
|
|
extern void AndroidThunkCpp_ShowConsoleWindow();
|
|
|
|
// Base path for file accesses
|
|
extern FString GFilePathBase;
|
|
|
|
/** The global EngineLoop instance */
|
|
FEngineLoop GEngineLoop;
|
|
|
|
bool GShowConsoleWindowNextTick = false;
|
|
|
|
static void AndroidProcessEvents(struct android_app* state);
|
|
|
|
//Event thread stuff
|
|
static void* AndroidEventThreadWorker(void* param);
|
|
|
|
// How often to process (read & dispatch) events, in seconds.
|
|
static const float EventRefreshRate = 1.0f / 20.0f;
|
|
|
|
//Android event callback functions
|
|
static int32_t HandleInputCB(struct android_app* app, AInputEvent* event); //Touch and key input events
|
|
static void OnAppCommandCB(struct android_app* app, int32_t cmd); //Lifetime events
|
|
static int HandleSensorEvents(int fd, int events, void* data); // Sensor events
|
|
|
|
bool GHasInterruptionRequest = false;
|
|
bool GIsInterrupted = false;
|
|
|
|
// Android sensor data management
|
|
static ASensorManager * SensorManager = NULL;
|
|
// Accelerometer (includes gravity), i.e. FMotionEvent::GetAcceleration.
|
|
static const ASensor * SensorAccelerometer = NULL;
|
|
// Gyroscope, i.e. FMotionEvent::GetRotationRate.
|
|
static const ASensor * SensorGyroscope = NULL;
|
|
// Magnetometer
|
|
static const ASensor* SensorMagnetometer = NULL;
|
|
static ASensorEventQueue * SensorQueue = NULL;
|
|
// android.hardware.SensorManager.SENSOR_DELAY_GAME
|
|
static const int32_t SensorDelayGame = 1;
|
|
// Time decay sampling rate.
|
|
static const float SampleDecayRate = 0.85f;
|
|
// Event for coordinating pausing of the main and event handling threads to prevent background spinning
|
|
static FEvent* EventHandlerEvent = NULL;
|
|
|
|
// Wait for Java onCreate to complete before resume main init
|
|
static volatile bool GResumeMainInit = false;
|
|
volatile bool GEventHandlerInitialized = false;
|
|
JNI_METHOD void Java_com_epicgames_ue4_GameActivity_nativeResumeMainInit(JNIEnv* jenv, jobject thiz)
|
|
{
|
|
GResumeMainInit = true;
|
|
|
|
// now wait for event handler to be set up before returning
|
|
while (!GEventHandlerInitialized)
|
|
{
|
|
FPlatformProcess::Sleep(0.01f);
|
|
FPlatformMisc::MemoryBarrier();
|
|
}
|
|
}
|
|
|
|
static volatile bool GHMDsInitialized = false;
|
|
static TArray<IHeadMountedDisplayModule*> GHMDImplementations;
|
|
void InitHMDs()
|
|
{
|
|
if (FParse::Param(FCommandLine::Get(), TEXT("nohmd")) || FParse::Param(FCommandLine::Get(), TEXT("emulatestereo")))
|
|
{
|
|
return;
|
|
}
|
|
|
|
// Get a list of plugins that implement this feature
|
|
GHMDImplementations = IModularFeatures::Get().GetModularFeatureImplementations<IHeadMountedDisplayModule>(IHeadMountedDisplayModule::GetModularFeatureName());
|
|
|
|
AndroidThunkCpp_InitHMDs();
|
|
|
|
while (!GHMDsInitialized)
|
|
{
|
|
FPlatformProcess::Sleep(0.01f);
|
|
FPlatformMisc::MemoryBarrier();
|
|
}
|
|
}
|
|
|
|
static void InitCommandLine()
|
|
{
|
|
static const uint32 CMD_LINE_MAX = 16384u;
|
|
|
|
// initialize the command line to an empty string
|
|
FCommandLine::Set(TEXT(""));
|
|
|
|
// read in the command line text file from the sdcard if it exists
|
|
FString CommandLineFilePath = GFilePathBase + FString("/UE4Game/") + (!FApp::IsGameNameEmpty() ? FApp::GetGameName() : FPlatformProcess::ExecutableName()) + FString("/UE4CommandLine.txt");
|
|
FILE* CommandLineFile = fopen(TCHAR_TO_UTF8(*CommandLineFilePath), "r");
|
|
if(CommandLineFile == NULL)
|
|
{
|
|
// if that failed, try the lowercase version
|
|
CommandLineFilePath = CommandLineFilePath.Replace(TEXT("UE4CommandLine.txt"), TEXT("ue4commandline.txt"));
|
|
CommandLineFile = fopen(TCHAR_TO_UTF8(*CommandLineFilePath), "r");
|
|
}
|
|
|
|
if(CommandLineFile)
|
|
{
|
|
char CommandLine[CMD_LINE_MAX];
|
|
fgets(CommandLine, ARRAY_COUNT(CommandLine) - 1, CommandLineFile);
|
|
|
|
fclose(CommandLineFile);
|
|
|
|
// chop off trailing spaces
|
|
while (*CommandLine && isspace(CommandLine[strlen(CommandLine) - 1]))
|
|
{
|
|
CommandLine[strlen(CommandLine) - 1] = 0;
|
|
}
|
|
|
|
FCommandLine::Append(UTF8_TO_TCHAR(CommandLine));
|
|
}
|
|
}
|
|
|
|
extern void AndroidThunkCpp_DismissSplashScreen();
|
|
|
|
//Main function called from the android entry point
|
|
int32 AndroidMain(struct android_app* state)
|
|
{
|
|
FPlatformMisc::LowLevelOutputDebugString(L"Entered AndroidMain()");
|
|
|
|
// Force the first call to GetJavaEnv() to happen on the game thread, allowing subsequent calls to occur on any thread
|
|
FAndroidApplication::GetJavaEnv();
|
|
|
|
// Set window format to 8888
|
|
ANativeActivity_setWindowFormat(state->activity, WINDOW_FORMAT_RGBA_8888);
|
|
|
|
// adjust the file descriptor limits to allow as many open files as possible
|
|
rlimit cur_fd_limit;
|
|
{
|
|
int result = getrlimit(RLIMIT_NOFILE, & cur_fd_limit);
|
|
//FPlatformMisc::LowLevelOutputDebugStringf(TEXT("(%d) Current fd limits: soft = %lld, hard = %lld"), result, cur_fd_limit.rlim_cur, cur_fd_limit.rlim_max);
|
|
}
|
|
{
|
|
rlimit new_limit = cur_fd_limit;
|
|
new_limit.rlim_cur = cur_fd_limit.rlim_max;
|
|
new_limit.rlim_max = cur_fd_limit.rlim_max;
|
|
int result = setrlimit(RLIMIT_NOFILE, &new_limit);
|
|
//FPlatformMisc::LowLevelOutputDebugStringf(TEXT("(%d) Setting fd limits: soft = %lld, hard = %lld"), result, new_limit.rlim_cur, new_limit.rlim_max);
|
|
}
|
|
{
|
|
int result = getrlimit(RLIMIT_NOFILE, & cur_fd_limit);
|
|
//FPlatformMisc::LowLevelOutputDebugStringf(TEXT("(%d) Current fd limits: soft = %lld, hard = %lld"), result, cur_fd_limit.rlim_cur, cur_fd_limit.rlim_max);
|
|
}
|
|
|
|
// setup joystick support
|
|
// r19 is the first NDK to include AMotionEvent_getAxisValue in the headers
|
|
// However, it has existed in the so since Honeycomb, query for the symbol
|
|
// to determine whether to try controller support
|
|
{
|
|
void* Lib = dlopen("libandroid.so",0);
|
|
if (Lib != NULL)
|
|
{
|
|
GetAxes = (GetAxesType)dlsym(Lib, "AMotionEvent_getAxisValue");
|
|
}
|
|
|
|
if (GetAxes != NULL)
|
|
{
|
|
FPlatformMisc::LowLevelOutputDebugStringf(TEXT("Controller interface supported\n"));
|
|
}
|
|
else
|
|
{
|
|
FPlatformMisc::LowLevelOutputDebugStringf(TEXT("Controller interface UNsupported\n"));
|
|
}
|
|
}
|
|
|
|
// setup key filtering
|
|
static const uint32 MAX_KEY_MAPPINGS(256);
|
|
uint32 KeyCodes[MAX_KEY_MAPPINGS];
|
|
uint32 NumKeyCodes = FPlatformMisc::GetKeyMap(KeyCodes, nullptr, MAX_KEY_MAPPINGS);
|
|
|
|
for (int i = 0; i < NumKeyCodes; ++i)
|
|
{
|
|
MappedKeyCodes.Add(KeyCodes[i]);
|
|
}
|
|
|
|
const int ValidGamepadKeyCodeCount = sizeof(ValidGamepadKeyCodesList)/sizeof(uint32);
|
|
for (int i = 0; i < ValidGamepadKeyCodeCount; ++i)
|
|
{
|
|
ValidGamepadKeyCodes.Add(ValidGamepadKeyCodesList[i]);
|
|
}
|
|
|
|
// wait for java activity onCreate to finish
|
|
while (!GResumeMainInit)
|
|
{
|
|
FPlatformProcess::Sleep(0.01f);
|
|
FPlatformMisc::MemoryBarrier();
|
|
}
|
|
|
|
// read the command line file
|
|
InitCommandLine();
|
|
FPlatformMisc::LowLevelOutputDebugStringf(TEXT("Final commandline: %s\n"), FCommandLine::Get());
|
|
|
|
EventHandlerEvent = FPlatformProcess::GetSynchEventFromPool(false);
|
|
FPlatformMisc::LowLevelOutputDebugString(L"Created sync event");
|
|
FAppEventManager::GetInstance()->SetEventHandlerEvent(EventHandlerEvent);
|
|
|
|
// ready for onCreate to complete
|
|
GEventHandlerInitialized = true;
|
|
|
|
// Initialize file system access (i.e. mount OBBs, etc.).
|
|
// We need to do this really early for Android so that files in the
|
|
// OBBs and APK are found.
|
|
IPlatformFile::GetPlatformPhysical().Initialize(nullptr, FCommandLine::Get());
|
|
|
|
// initialize the engine
|
|
GEngineLoop.PreInit(0, NULL, FCommandLine::Get());
|
|
|
|
// initialize HMDs
|
|
InitHMDs();
|
|
|
|
UE_LOG(LogAndroid, Display, TEXT("Passed PreInit()"));
|
|
|
|
GLog->SetCurrentThreadAsMasterThread();
|
|
|
|
GEngineLoop.Init();
|
|
|
|
UE_LOG(LogAndroid, Log, TEXT("Passed GEngineLoop.Init()"));
|
|
|
|
AndroidThunkCpp_DismissSplashScreen();
|
|
|
|
FAppEventManager::GetInstance()->SetEmptyQueueHandlerEvent(FPlatformProcess::GetSynchEventFromPool(false));
|
|
|
|
#if !UE_BUILD_SHIPPING
|
|
if (FParse::Param(FCommandLine::Get(), TEXT("Messaging")))
|
|
{
|
|
// initialize messaging subsystem
|
|
FModuleManager::LoadModuleChecked<IMessagingModule>("Messaging");
|
|
TSharedPtr<ISessionService> SessionService = FModuleManager::LoadModuleChecked<ISessionServicesModule>("SessionServices").GetSessionService();
|
|
SessionService->Start();
|
|
|
|
// Initialize functional testing
|
|
FModuleManager::Get().LoadModule("FunctionalTesting");
|
|
}
|
|
#endif
|
|
|
|
// tick until done
|
|
while (!GIsRequestingExit)
|
|
{
|
|
FAppEventManager::GetInstance()->Tick();
|
|
if(!FAppEventManager::GetInstance()->IsGamePaused())
|
|
{
|
|
GEngineLoop.Tick();
|
|
}
|
|
else
|
|
{
|
|
// use less CPU when paused
|
|
FPlatformProcess::Sleep(0.10f);
|
|
}
|
|
|
|
#if !UE_BUILD_SHIPPING
|
|
// show console window on next game tick
|
|
if (GShowConsoleWindowNextTick)
|
|
{
|
|
GShowConsoleWindowNextTick = false;
|
|
AndroidThunkCpp_ShowConsoleWindow();
|
|
}
|
|
#endif
|
|
}
|
|
FAppEventManager::GetInstance()->TriggerEmptyQueue();
|
|
|
|
UE_LOG(LogAndroid, Log, TEXT("Exiting"));
|
|
|
|
// exit out!
|
|
GEngineLoop.Exit();
|
|
|
|
UE_LOG(LogAndroid, Log, TEXT("Exiting is over"));
|
|
|
|
FPlatformMisc::RequestExit(1);
|
|
return 0;
|
|
}
|
|
|
|
|
|
|
|
static void* AndroidEventThreadWorker( void* param )
|
|
{
|
|
struct android_app* state = (struct android_app*)param;
|
|
|
|
FPlatformProcess::SetThreadAffinityMask(FPlatformAffinity::GetMainGameMask());
|
|
|
|
FPlatformMisc::LowLevelOutputDebugString(L"Entering event processing thread engine entry point");
|
|
|
|
ALooper* looper = ALooper_prepare(ALOOPER_PREPARE_ALLOW_NON_CALLBACKS);
|
|
ALooper_addFd(looper, state->msgread, LOOPER_ID_MAIN, ALOOPER_EVENT_INPUT, NULL,
|
|
&state->cmdPollSource);
|
|
state->looper = looper;
|
|
|
|
FPlatformMisc::LowLevelOutputDebugString(L"Prepared looper for event thread");
|
|
|
|
//Assign the callbacks
|
|
state->onAppCmd = OnAppCommandCB;
|
|
state->onInputEvent = HandleInputCB;
|
|
|
|
FPlatformMisc::LowLevelOutputDebugString(L"Passed callback initialization");
|
|
|
|
// Acquire sensors
|
|
SensorManager = ASensorManager_getInstance();
|
|
if (NULL != SensorManager)
|
|
{
|
|
// Register for the various sensor events we want. Some
|
|
// may return NULL indicating that the sensor data is not
|
|
// available in the device. For those empty data will eventually
|
|
// get fed into the motion events.
|
|
SensorAccelerometer = ASensorManager_getDefaultSensor(
|
|
SensorManager, ASENSOR_TYPE_ACCELEROMETER);
|
|
SensorGyroscope = ASensorManager_getDefaultSensor(
|
|
SensorManager, ASENSOR_TYPE_GYROSCOPE);
|
|
SensorMagnetometer = ASensorManager_getDefaultSensor(
|
|
SensorManager, ASENSOR_TYPE_MAGNETIC_FIELD);
|
|
// Create the queue for events to arrive.
|
|
SensorQueue = ASensorManager_createEventQueue(
|
|
SensorManager, state->looper, LOOPER_ID_USER, HandleSensorEvents, NULL);
|
|
}
|
|
|
|
FPlatformMisc::LowLevelOutputDebugString(L"Passed sensor initialization");
|
|
|
|
//continue to process events until the engine is shutting down
|
|
while (!GIsRequestingExit)
|
|
{
|
|
// FPlatformMisc::LowLevelOutputDebugString(L"AndroidEventThreadWorker");
|
|
|
|
AndroidProcessEvents(state);
|
|
|
|
sleep(EventRefreshRate); // this is really 0 since it takes int seconds.
|
|
}
|
|
|
|
UE_LOG(LogAndroid, Log, TEXT("Exiting"));
|
|
|
|
return NULL;
|
|
}
|
|
|
|
//Called from the separate event processing thread
|
|
static void AndroidProcessEvents(struct android_app* state)
|
|
{
|
|
int ident;
|
|
int fdesc;
|
|
int events;
|
|
struct android_poll_source* source;
|
|
|
|
while((ident = ALooper_pollAll(-1, &fdesc, &events, (void**)&source)) >= 0)
|
|
{
|
|
// process this event
|
|
if (source)
|
|
{
|
|
source->process(state, source);
|
|
}
|
|
}
|
|
}
|
|
|
|
pthread_t G_AndroidEventThread;
|
|
|
|
struct android_app* GNativeAndroidApp = NULL;
|
|
|
|
void android_main(struct android_app* state)
|
|
{
|
|
FPlatformMisc::LowLevelOutputDebugString(L"Entering native app glue main function");
|
|
|
|
GNativeAndroidApp = state;
|
|
check(GNativeAndroidApp);
|
|
|
|
pthread_attr_t otherAttr;
|
|
pthread_attr_init(&otherAttr);
|
|
pthread_attr_setdetachstate(&otherAttr, PTHREAD_CREATE_DETACHED);
|
|
pthread_create(&G_AndroidEventThread, &otherAttr, AndroidEventThreadWorker, state);
|
|
|
|
FPlatformMisc::LowLevelOutputDebugString(L"Created event thread");
|
|
|
|
// Make sure glue isn't stripped.
|
|
app_dummy();
|
|
|
|
//@todo android: replace with native activity, main loop off of UI thread, etc.
|
|
AndroidMain(state);
|
|
}
|
|
|
|
extern bool GAndroidGPUInfoReady;
|
|
|
|
//Called from the event process thread
|
|
static int32_t HandleInputCB(struct android_app* app, AInputEvent* event)
|
|
{
|
|
// FPlatformMisc::LowLevelOutputDebugStringf(L"INPUT - type: %x, action: %x, source: %x, keycode: %x, buttons: %x", AInputEvent_getType(event),
|
|
// AMotionEvent_getAction(event), AInputEvent_getSource(event), AKeyEvent_getKeyCode(event), AMotionEvent_getButtonState(event));
|
|
|
|
int32 EventType = AInputEvent_getType(event);
|
|
int32 EventSource = AInputEvent_getSource(event);
|
|
|
|
if (EventType == AINPUT_EVENT_TYPE_MOTION)
|
|
{
|
|
int action = AMotionEvent_getAction(event);
|
|
int actionType = action & AMOTION_EVENT_ACTION_MASK;
|
|
size_t actionPointer = (size_t)((action & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT);
|
|
bool isActionTargeted = (actionType == AMOTION_EVENT_ACTION_POINTER_DOWN || actionType == AMOTION_EVENT_ACTION_POINTER_UP);
|
|
int32 device = AInputEvent_getDeviceId(event);
|
|
|
|
// trap Joystick events first, with fallthrough if there is no joystick support
|
|
if (((EventSource & AINPUT_SOURCE_CLASS_JOYSTICK) == AINPUT_SOURCE_CLASS_JOYSTICK) &&
|
|
(GetAxes != NULL) &&
|
|
(actionType == AMOTION_EVENT_ACTION_MOVE))
|
|
{
|
|
const int axisCount = sizeof(AxisList)/sizeof(int32_t);
|
|
|
|
// poll all the axes and forward to update controller state
|
|
for (int axis = 0; axis < axisCount; axis++)
|
|
{
|
|
float val = GetAxes( event, AxisList[axis], 0);
|
|
FAndroidInputInterface::JoystickAxisEvent(device, AxisList[axis], val);
|
|
}
|
|
|
|
// handle L/R trigger and Brake/Gas special (all in 0..1 range)
|
|
// LTRIGGER will either be LTRIGGER or BRAKE, whichever is larger
|
|
// RTRIGGER will either be RTRIGGER or GAS, whichever is larger
|
|
float ltrigger = GetAxes(event, AMOTION_EVENT_AXIS_LTRIGGER, 0);
|
|
float rtrigger = GetAxes(event, AMOTION_EVENT_AXIS_RTRIGGER, 0);
|
|
float brake = GetAxes(event, AMOTION_EVENT_AXIS_BRAKE, 0);
|
|
float gas = GetAxes(event, AMOTION_EVENT_AXIS_GAS, 0);
|
|
FAndroidInputInterface::JoystickAxisEvent(device, AMOTION_EVENT_AXIS_LTRIGGER, ltrigger > brake ? ltrigger : brake);
|
|
FAndroidInputInterface::JoystickAxisEvent(device, AMOTION_EVENT_AXIS_RTRIGGER, rtrigger > gas ? rtrigger : gas);
|
|
|
|
return 1;
|
|
}
|
|
else
|
|
{
|
|
TArray<TouchInput> TouchesArray;
|
|
|
|
TouchType type = TouchEnded;
|
|
|
|
switch (actionType)
|
|
{
|
|
case AMOTION_EVENT_ACTION_DOWN:
|
|
case AMOTION_EVENT_ACTION_POINTER_DOWN:
|
|
type = TouchBegan;
|
|
break;
|
|
case AMOTION_EVENT_ACTION_MOVE:
|
|
type = TouchMoved;
|
|
break;
|
|
case AMOTION_EVENT_ACTION_UP:
|
|
case AMOTION_EVENT_ACTION_POINTER_UP:
|
|
case AMOTION_EVENT_ACTION_CANCEL:
|
|
case AMOTION_EVENT_ACTION_OUTSIDE:
|
|
type = TouchEnded;
|
|
break;
|
|
case AMOTION_EVENT_ACTION_SCROLL:
|
|
case AMOTION_EVENT_ACTION_HOVER_ENTER:
|
|
case AMOTION_EVENT_ACTION_HOVER_MOVE:
|
|
case AMOTION_EVENT_ACTION_HOVER_EXIT:
|
|
return 0;
|
|
default:
|
|
UE_LOG(LogAndroid, Verbose, TEXT("Unknown AMOTION_EVENT %d ignored"), actionType);
|
|
return 0;
|
|
}
|
|
|
|
size_t pointerCount = AMotionEvent_getPointerCount(event);
|
|
|
|
if (pointerCount == 0)
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
ANativeWindow* Window = (ANativeWindow*)FPlatformMisc::GetHardwareWindow();
|
|
if (!Window)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
int32_t Width = 0 ;
|
|
int32_t Height = 0 ;
|
|
|
|
if(Window)
|
|
{
|
|
FAndroidWindow::CalculateSurfaceSize(Window, Width, Height);
|
|
}
|
|
|
|
// make sure OpenGL context created before accepting touch events.. FAndroidWindow::GetScreenRect() may try to create it early from wrong thread if this is the first call
|
|
if (!GAndroidGPUInfoReady)
|
|
{
|
|
return 1;
|
|
}
|
|
FPlatformRect ScreenRect = FAndroidWindow::GetScreenRect();
|
|
|
|
if(isActionTargeted)
|
|
{
|
|
if(actionPointer < 0 || pointerCount < (int)actionPointer)
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
int pointerId = AMotionEvent_getPointerId(event, actionPointer);
|
|
float x = FMath::Min<float>(AMotionEvent_getX(event, actionPointer) / Width, 1.f);
|
|
x *= (ScreenRect.Right - 1);
|
|
float y = FMath::Min<float>(AMotionEvent_getY(event, actionPointer) / Height, 1.f);
|
|
y *= (ScreenRect.Bottom - 1);
|
|
|
|
UE_LOG(LogAndroid, Verbose, TEXT("Received targeted motion event from pointer %u (id %d) action %d: (%.2f, %.2f)"), actionPointer, pointerId, action, x, y);
|
|
|
|
TouchInput TouchMessage;
|
|
TouchMessage.DeviceId = device;
|
|
TouchMessage.Handle = pointerId;
|
|
TouchMessage.Type = type;
|
|
TouchMessage.Position = FVector2D(x, y);
|
|
TouchMessage.LastPosition = FVector2D(x, y); //@todo android: AMotionEvent_getHistoricalRawX
|
|
TouchesArray.Add(TouchMessage);
|
|
}
|
|
else
|
|
{
|
|
for (size_t i = 0; i < pointerCount; ++i)
|
|
{
|
|
int pointerId = AMotionEvent_getPointerId(event, i);
|
|
|
|
float x = FMath::Min<float>(AMotionEvent_getX(event, i) / Width, 1.f);
|
|
x *= (ScreenRect.Right - 1);
|
|
float y = FMath::Min<float>(AMotionEvent_getY(event, i) / Height, 1.f);
|
|
y *= (ScreenRect.Bottom - 1);
|
|
|
|
UE_LOG(LogAndroid, Verbose, TEXT("Received motion event from index %u (id %d) action %d: (%.2f, %.2f)"), i, pointerId, action, x, y);
|
|
|
|
TouchInput TouchMessage;
|
|
TouchMessage.DeviceId= device;
|
|
TouchMessage.Handle = pointerId;
|
|
TouchMessage.Type = type;
|
|
TouchMessage.Position = FVector2D(x, y);
|
|
TouchMessage.LastPosition = FVector2D(x, y); //@todo android: AMotionEvent_getHistoricalRawX
|
|
TouchesArray.Add(TouchMessage);
|
|
}
|
|
}
|
|
|
|
FAndroidInputInterface::QueueTouchInput(TouchesArray);
|
|
|
|
#if !UE_BUILD_SHIPPING
|
|
if ((pointerCount >= 4) && (type == TouchBegan))
|
|
{
|
|
bool bShowConsole = true;
|
|
GConfig->GetBool(TEXT("/Script/Engine.InputSettings"), TEXT("bShowConsoleOnFourFingerTap"), bShowConsole, GInputIni);
|
|
|
|
if (bShowConsole)
|
|
{
|
|
GShowConsoleWindowNextTick = true;
|
|
}
|
|
}
|
|
#endif
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
if (EventType == AINPUT_EVENT_TYPE_KEY)
|
|
{
|
|
int keyCode = AKeyEvent_getKeyCode(event);
|
|
|
|
FPlatformMisc::LowLevelOutputDebugStringf(L"Received keycode: %d", keyCode);
|
|
|
|
//Trap codes handled as possible gamepad events
|
|
if (ValidGamepadKeyCodes.Contains(keyCode))
|
|
{
|
|
//Only pass on the device id if really a gamepad, joystick or dpad (allows menu and back to be treated as gamepad events)
|
|
int32 device = 0;
|
|
if ( (((EventSource & AINPUT_SOURCE_JOYSTICK) == AINPUT_SOURCE_JOYSTICK) && (GetAxes != NULL)) ||
|
|
((EventSource & AINPUT_SOURCE_GAMEPAD) == AINPUT_SOURCE_GAMEPAD) ||
|
|
((EventSource & AINPUT_SOURCE_DPAD) == AINPUT_SOURCE_DPAD) )
|
|
{
|
|
device = AInputEvent_getDeviceId(event);
|
|
}
|
|
bool down = AKeyEvent_getAction(event) != AKEY_EVENT_ACTION_UP;
|
|
FAndroidInputInterface::JoystickButtonEvent(device, keyCode, down);
|
|
FPlatformMisc::LowLevelOutputDebugStringf(L"Received gamepad button: %d", keyCode);
|
|
}
|
|
else
|
|
{
|
|
FPlatformMisc::LowLevelOutputDebugStringf(L"Received key event: %d", keyCode);
|
|
|
|
// only handle mapped key codes
|
|
if (!MappedKeyCodes.Contains(keyCode))
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
FDeferredAndroidMessage Message;
|
|
|
|
Message.messageType = AKeyEvent_getAction(event) == AKEY_EVENT_ACTION_UP ? MessageType_KeyUp : MessageType_KeyDown;
|
|
Message.KeyEventData.unichar = keyCode;
|
|
Message.KeyEventData.keyId = keyCode;
|
|
Message.KeyEventData.modifier = AKeyEvent_getMetaState(event);
|
|
Message.KeyEventData.isRepeat = AKeyEvent_getAction(event) == AKEY_EVENT_ACTION_MULTIPLE;
|
|
FAndroidInputInterface::DeferMessage(Message);
|
|
|
|
// allow event to be generated for volume up and down, but conditionally allow system to handle it, too
|
|
if (keyCode == AKEYCODE_VOLUME_UP || keyCode == AKEYCODE_VOLUME_DOWN)
|
|
{
|
|
if (FPlatformMisc::GetVolumeButtonsHandledBySystem())
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
return 1;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
//Called from the event process thread
|
|
static void OnAppCommandCB(struct android_app* app, int32_t cmd)
|
|
{
|
|
bool bNeedToSync = false;
|
|
//FPlatformMisc::LowLevelOutputDebugStringf(L"OnAppCommandCB cmd: %u, tid = %d", cmd, gettid());
|
|
|
|
switch (cmd)
|
|
{
|
|
case APP_CMD_SAVE_STATE:
|
|
/**
|
|
* Command from main thread: the app should generate a new saved state
|
|
* for itself, to restore from later if needed. If you have saved state,
|
|
* allocate it with malloc and place it in android_app.savedState with
|
|
* the size in android_app.savedStateSize. The will be freed for you
|
|
* later.
|
|
*/
|
|
// the OS asked us to save the state of the app
|
|
UE_LOG(LogAndroid, Log, TEXT("Case APP_CMD_SAVE_STATE"));
|
|
FAppEventManager::GetInstance()->EnqueueAppEvent(APP_EVENT_STATE_SAVE_STATE);
|
|
break;
|
|
case APP_CMD_INIT_WINDOW:
|
|
/**
|
|
* Command from main thread: a new ANativeWindow is ready for use. Upon
|
|
* receiving this command, android_app->window will contain the new window
|
|
* surface.
|
|
*/
|
|
// get the window ready for showing
|
|
FPlatformMisc::LowLevelOutputDebugStringf(TEXT("Case APP_CMD_INIT_WINDOW"));
|
|
UE_LOG(LogAndroid, Log, TEXT("Case APP_CMD_INIT_WINDOW"));
|
|
FAppEventManager::GetInstance()->HandleWindowCreated(app->pendingWindow);
|
|
|
|
bNeedToSync = true;
|
|
break;
|
|
case APP_CMD_TERM_WINDOW:
|
|
/**
|
|
* Command from main thread: the existing ANativeWindow needs to be
|
|
* terminated. Upon receiving this command, android_app->window still
|
|
* contains the existing window; after calling android_app_exec_cmd
|
|
* it will be set to NULL.
|
|
*/
|
|
FPlatformMisc::LowLevelOutputDebugStringf(TEXT("Case APP_CMD_TERM_WINDOW, tid = %d"), gettid());
|
|
// clean up the window because it is being hidden/closed
|
|
UE_LOG(LogAndroid, Log, TEXT("Case APP_CMD_TERM_WINDOW"));
|
|
FAppEventManager::GetInstance()->HandleWindowClosed();
|
|
|
|
bNeedToSync = true;
|
|
break;
|
|
case APP_CMD_LOST_FOCUS:
|
|
/**
|
|
* Command from main thread: the app's activity window has lost
|
|
* input focus.
|
|
*/
|
|
// if the app lost focus, avoid unnecessary processing (like monitoring the accelerometer)
|
|
UE_LOG(LogAndroid, Log, TEXT("Case APP_CMD_LOST_FOCUS"));
|
|
FAppEventManager::GetInstance()->EnqueueAppEvent(APP_EVENT_STATE_WINDOW_LOST_FOCUS, NULL);
|
|
if (NULL != SensorQueue)
|
|
{
|
|
if (NULL != SensorAccelerometer)
|
|
ASensorEventQueue_disableSensor(SensorQueue, SensorAccelerometer);
|
|
if (NULL != SensorGyroscope)
|
|
ASensorEventQueue_disableSensor(SensorQueue, SensorGyroscope);
|
|
if (NULL != SensorMagnetometer)
|
|
ASensorEventQueue_disableSensor(SensorQueue, SensorMagnetometer);
|
|
}
|
|
break;
|
|
case APP_CMD_GAINED_FOCUS:
|
|
/**
|
|
* Command from main thread: the app's activity window has gained
|
|
* input focus.
|
|
*/
|
|
// bring back a certain functionality, like monitoring the accelerometer
|
|
UE_LOG(LogAndroid, Log, TEXT("Case APP_CMD_GAINED_FOCUS"));
|
|
FAppEventManager::GetInstance()->EnqueueAppEvent(APP_EVENT_STATE_WINDOW_GAINED_FOCUS, NULL);
|
|
if (NULL != SensorQueue)
|
|
{
|
|
if (NULL != SensorAccelerometer)
|
|
{
|
|
ASensorEventQueue_enableSensor(SensorQueue, SensorAccelerometer);
|
|
ASensorEventQueue_setEventRate(SensorQueue, SensorAccelerometer, SensorDelayGame);
|
|
}
|
|
if (NULL != SensorGyroscope)
|
|
{
|
|
ASensorEventQueue_enableSensor(SensorQueue, SensorGyroscope);
|
|
ASensorEventQueue_setEventRate(SensorQueue, SensorGyroscope, SensorDelayGame);
|
|
}
|
|
if (NULL != SensorMagnetometer)
|
|
{
|
|
ASensorEventQueue_enableSensor(SensorQueue, SensorMagnetometer);
|
|
ASensorEventQueue_setEventRate(SensorQueue, SensorMagnetometer, SensorDelayGame);
|
|
}
|
|
}
|
|
break;
|
|
case APP_CMD_INPUT_CHANGED:
|
|
UE_LOG(LogAndroid, Log, TEXT("Case APP_CMD_INPUT_CHANGED"));
|
|
break;
|
|
case APP_CMD_WINDOW_RESIZED:
|
|
/**
|
|
* Command from main thread: the current ANativeWindow has been resized.
|
|
* Please redraw with its new size.
|
|
*/
|
|
UE_LOG(LogAndroid, Log, TEXT("Case APP_CMD_WINDOW_RESIZED"));
|
|
FAppEventManager::GetInstance()->EnqueueAppEvent(APP_EVENT_STATE_WINDOW_RESIZED );
|
|
break;
|
|
case APP_CMD_WINDOW_REDRAW_NEEDED:
|
|
/**
|
|
* Command from main thread: the system needs that the current ANativeWindow
|
|
* be redrawn. You should redraw the window before handing this to
|
|
* android_app_exec_cmd() in order to avoid transient drawing glitches.
|
|
*/
|
|
UE_LOG(LogAndroid, Log, TEXT("Case APP_CMD_WINDOW_REDRAW_NEEDED"));
|
|
FAppEventManager::GetInstance()->EnqueueAppEvent(APP_EVENT_STATE_WINDOW_REDRAW_NEEDED );
|
|
break;
|
|
case APP_CMD_CONTENT_RECT_CHANGED:
|
|
/**
|
|
* Command from main thread: the content area of the window has changed,
|
|
* such as from the soft input window being shown or hidden. You can
|
|
* find the new content rect in android_app::contentRect.
|
|
*/
|
|
UE_LOG(LogAndroid, Log, TEXT("Case APP_CMD_CONTENT_RECT_CHANGED"));
|
|
break;
|
|
case APP_CMD_CONFIG_CHANGED:
|
|
{
|
|
/**
|
|
* Command from main thread: the current device configuration has changed.
|
|
*/
|
|
UE_LOG(LogAndroid, Log, TEXT("Case APP_CMD_CONFIG_CHANGED"));
|
|
|
|
bool bPortrait = (AConfiguration_getOrientation(app->config) == ACONFIGURATION_ORIENTATION_PORT);
|
|
if (FAndroidWindow::OnWindowOrientationChanged(bPortrait))
|
|
{
|
|
FAppEventManager::GetInstance()->EnqueueAppEvent(APP_EVENT_STATE_WINDOW_CHANGED, nullptr);
|
|
}
|
|
}
|
|
break;
|
|
case APP_CMD_LOW_MEMORY:
|
|
/**
|
|
* Command from main thread: the system is running low on memory.
|
|
* Try to reduce your memory use.
|
|
*/
|
|
UE_LOG(LogAndroid, Log, TEXT("Case APP_CMD_LOW_MEMORY"));
|
|
break;
|
|
case APP_CMD_START:
|
|
/**
|
|
* Command from main thread: the app's activity has been started.
|
|
*/
|
|
UE_LOG(LogAndroid, Log, TEXT("Case APP_CMD_START"));
|
|
FAppEventManager::GetInstance()->EnqueueAppEvent(APP_EVENT_STATE_ON_START);
|
|
|
|
break;
|
|
case APP_CMD_RESUME:
|
|
/**
|
|
* Command from main thread: the app's activity has been resumed.
|
|
*/
|
|
FPlatformMisc::LowLevelOutputDebugStringf(TEXT("Case APP_CMD_RESUME"));
|
|
UE_LOG(LogAndroid, Log, TEXT("Case APP_CMD_RESUME"));
|
|
|
|
FAppEventManager::GetInstance()->EnqueueAppEvent(APP_EVENT_STATE_ON_RESUME);
|
|
|
|
break;
|
|
case APP_CMD_PAUSE:
|
|
/**
|
|
* Command from main thread: the app's activity has been paused.
|
|
*/
|
|
FPlatformMisc::LowLevelOutputDebugStringf(TEXT("Case APP_CMD_PAUSE"));
|
|
UE_LOG(LogAndroid, Log, TEXT("Case APP_CMD_PAUSE"));
|
|
FAppEventManager::GetInstance()->EnqueueAppEvent(APP_EVENT_STATE_ON_PAUSE);
|
|
|
|
bNeedToSync = true;
|
|
break;
|
|
case APP_CMD_STOP:
|
|
/**
|
|
* Command from main thread: the app's activity has been stopped.
|
|
*/
|
|
UE_LOG(LogAndroid, Log, TEXT("Case APP_CMD_STOP"));
|
|
FAppEventManager::GetInstance()->EnqueueAppEvent(APP_EVENT_STATE_ON_STOP);
|
|
|
|
break;
|
|
case APP_CMD_DESTROY:
|
|
/**
|
|
* Command from main thread: the app's activity is being destroyed,
|
|
* and waiting for the app thread to clean up and exit before proceeding.
|
|
*/
|
|
UE_LOG(LogAndroid, Log, TEXT("Case APP_CMD_DESTROY"));
|
|
FAppEventManager::GetInstance()->EnqueueAppEvent(APP_EVENT_STATE_ON_DESTROY);
|
|
break;
|
|
}
|
|
|
|
if ( EventHandlerEvent )
|
|
EventHandlerEvent->Trigger();
|
|
|
|
if (bNeedToSync)
|
|
FAppEventManager::GetInstance()->WaitForEmptyQueue();
|
|
//FPlatformMisc::LowLevelOutputDebugStringf(L"#### END OF OnAppCommandCB cmd: %u, tid = %d", cmd, gettid());
|
|
}
|
|
|
|
static void GetRotationMatrix(FVector gravityVec, FVector magneticVec, float outRotationMatrix[])
|
|
{
|
|
// the the cross product of magnetic vector and gravity to derive a basis
|
|
// vector pointing East.
|
|
FVector eastVec = FVector::CrossProduct(magneticVec, gravityVec);
|
|
|
|
// Normalize & check the new basis vector
|
|
const float normEast = eastVec.Size();
|
|
if (normEast < 0.1f)
|
|
{
|
|
// device is close to free fall (or in space?), or close to
|
|
// magnetic north pole. Typical values are > 100.
|
|
return;
|
|
}
|
|
float invEastSize = 1.0f / normEast;
|
|
eastVec.X *= invEastSize;
|
|
eastVec.Y *= invEastSize;
|
|
eastVec.Z *= invEastSize;
|
|
|
|
// Now normalize the acceleration (assumed = gravity) vector
|
|
float invGravSize = 1.0f / gravityVec.Size();
|
|
gravityVec.X *= invGravSize;
|
|
gravityVec.Y *= invGravSize;
|
|
gravityVec.Z *= invGravSize;
|
|
|
|
// A second cross product of the newly computed East and our measured gravity
|
|
// vector gives a north vector in the horizontal plane.
|
|
FVector northVec = FVector::CrossProduct(gravityVec, eastVec);
|
|
|
|
outRotationMatrix[0] = eastVec.X; outRotationMatrix[1] = eastVec.Y; outRotationMatrix[2] = eastVec.Z;
|
|
outRotationMatrix[3] = northVec.X; outRotationMatrix[4] = northVec.Y; outRotationMatrix[5] = northVec.Z;
|
|
outRotationMatrix[6] = gravityVec.X; outRotationMatrix[7] = gravityVec.Y; outRotationMatrix[8] = gravityVec.Z;
|
|
}
|
|
|
|
static int HandleSensorEvents(int fd, int events, void* data)
|
|
{
|
|
// It's not possible to discern sequencing across sensors in
|
|
// Android. So we average out all the sensor events on one cycle
|
|
// and post a single motion sensor data point. We also need
|
|
// to synthesize additional information.
|
|
FVector current_accelerometer(0, 0, 0);
|
|
FVector current_gyroscope(0, 0, 0);
|
|
FVector current_magnetometer(0, 0, 0);
|
|
int32 current_accelerometer_sample_count = 0;
|
|
int32 current_gyroscope_sample_count = 0;
|
|
int32 current_magnetometer_sample_count = 0;
|
|
static FVector last_accelerometer(0, 0, 0);
|
|
static FVector last_magnetometer(0, 0, 0);
|
|
|
|
if (NULL != SensorAccelerometer || NULL != SensorGyroscope)
|
|
{
|
|
ASensorEvent sensor_event;
|
|
while (ASensorEventQueue_getEvents(SensorQueue, &sensor_event, 1) > 0)
|
|
{
|
|
if (ASENSOR_TYPE_ACCELEROMETER == sensor_event.type)
|
|
{
|
|
current_accelerometer.X += sensor_event.acceleration.x;
|
|
current_accelerometer.Y += sensor_event.acceleration.y;
|
|
current_accelerometer.Z += sensor_event.acceleration.z;
|
|
current_accelerometer_sample_count += 1;
|
|
}
|
|
else if (ASENSOR_TYPE_GYROSCOPE == sensor_event.type)
|
|
{
|
|
current_gyroscope.X += sensor_event.vector.pitch;
|
|
current_gyroscope.Y += sensor_event.vector.azimuth;
|
|
current_gyroscope.Z += sensor_event.vector.roll;
|
|
current_gyroscope_sample_count += 1;
|
|
}
|
|
else if (ASENSOR_TYPE_MAGNETIC_FIELD == sensor_event.type)
|
|
{
|
|
current_magnetometer.X += sensor_event.magnetic.x;
|
|
current_magnetometer.Y += sensor_event.magnetic.y;
|
|
current_magnetometer.Z += sensor_event.magnetic.z;
|
|
current_magnetometer_sample_count += 1;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (current_accelerometer_sample_count > 0)
|
|
{
|
|
// Do simple average of the samples we just got.
|
|
current_accelerometer /= float(current_accelerometer_sample_count);
|
|
last_accelerometer = current_accelerometer;
|
|
}
|
|
else
|
|
{
|
|
current_accelerometer = last_accelerometer;
|
|
}
|
|
|
|
if (current_gyroscope_sample_count > 0)
|
|
{
|
|
// Do simple average of the samples we just got.
|
|
current_gyroscope /= float(current_gyroscope_sample_count);
|
|
}
|
|
|
|
if (current_magnetometer_sample_count > 0)
|
|
{
|
|
// Do simple average of the samples we just got.
|
|
current_magnetometer /= float(current_magnetometer_sample_count);
|
|
last_magnetometer = current_magnetometer;
|
|
}
|
|
else
|
|
{
|
|
current_magnetometer = last_magnetometer;
|
|
}
|
|
|
|
// If we have motion samples we generate the single event.
|
|
if (current_accelerometer_sample_count > 0 ||
|
|
current_gyroscope_sample_count > 0 ||
|
|
current_magnetometer_sample_count > 0)
|
|
{
|
|
// The data we compose the motion event from.
|
|
FVector current_tilt(0, 0, 0);
|
|
FVector current_rotation_rate(0, 0, 0);
|
|
FVector current_gravity(0, 0, 0);
|
|
FVector current_acceleration(0, 0, 0);
|
|
|
|
// Buffered, historical, motion data.
|
|
static FVector last_tilt(0, 0, 0);
|
|
static FVector last_gravity(0, 0, 0);
|
|
|
|
// We use a low-pass filter to synthesize the gravity
|
|
// vector.
|
|
static bool first_acceleration_sample = true;
|
|
if (!first_acceleration_sample)
|
|
{
|
|
current_gravity
|
|
= last_gravity*SampleDecayRate
|
|
+ current_accelerometer*(1.0f - SampleDecayRate);
|
|
}
|
|
first_acceleration_sample = false;
|
|
|
|
// get the rotation matrix value, the convert those to Euler angle rotation values
|
|
float outRotationMatrix[9];
|
|
GetRotationMatrix(current_accelerometer, current_magnetometer, outRotationMatrix);
|
|
|
|
float current_yaw = FMath::Atan2(outRotationMatrix[1], outRotationMatrix[4]);
|
|
float current_roll = FMath::Asin(-1 * outRotationMatrix[7]);
|
|
float current_pitch = FMath::Atan2(-1 * outRotationMatrix[6], outRotationMatrix[8]);
|
|
|
|
//to match up with ipad values for Y, we need to adjust by pi
|
|
current_yaw += PI;
|
|
if (current_yaw >= PI)
|
|
{
|
|
current_yaw = (current_yaw - PI) + -PI;
|
|
}
|
|
|
|
current_tilt.X = current_pitch;
|
|
current_tilt.Y = current_yaw;
|
|
current_tilt.Z = current_roll;
|
|
|
|
// And take out the gravity from the accel to get
|
|
// the linear acceleration.
|
|
current_acceleration = current_accelerometer - current_gravity;
|
|
|
|
if (current_gyroscope_sample_count > 0)
|
|
{
|
|
// The rotation rate is the what the gyroscope gives us.
|
|
current_rotation_rate = current_gyroscope;
|
|
}
|
|
else if (NULL == SensorGyroscope)
|
|
{
|
|
// If we don't have a gyroscope at all we need to calc a rotation
|
|
// rate from our calculated tilt and a delta.
|
|
current_rotation_rate = current_tilt - last_tilt;
|
|
}
|
|
|
|
// Finally record the motion event with all the data.
|
|
FAndroidInputInterface::QueueMotionData(current_tilt,
|
|
current_rotation_rate, current_gravity, current_acceleration);
|
|
|
|
// Update history values.
|
|
last_tilt = current_tilt;
|
|
last_gravity = current_gravity;
|
|
|
|
// UE_LOG(LogTemp, Log, TEXT("MOTION: tilt = %s, rotation-rate = %s, gravity = %s, acceleration = %s"),
|
|
// *current_tilt.ToCompactString(),
|
|
// *current_rotation_rate.ToCompactString(),
|
|
// *current_gravity.ToCompactString(),
|
|
// *current_acceleration.ToCompactString());
|
|
}
|
|
|
|
// Indicate we want to keep getting events.
|
|
return 1;
|
|
}
|
|
|
|
//Native-defined functions
|
|
|
|
//This function is declared in the Java-defined class, GameActivity.java: "public native void nativeConsoleCommand(String commandString);"
|
|
JNI_METHOD void Java_com_epicgames_ue4_GameActivity_nativeConsoleCommand(JNIEnv* jenv, jobject thiz, jstring commandString)
|
|
{
|
|
const char* javaChars = jenv->GetStringUTFChars(commandString, 0);
|
|
|
|
new(GEngine->DeferredCommands) FString(UTF8_TO_TCHAR(javaChars));
|
|
|
|
//Release the string
|
|
jenv->ReleaseStringUTFChars(commandString, javaChars);
|
|
}
|
|
|
|
// This is called from the Java UI thread for initializing VR HMDs
|
|
JNI_METHOD void Java_com_epicgames_ue4_GameActivity_nativeInitHMDs(JNIEnv* jenv, jobject thiz)
|
|
{
|
|
for (auto HMDModuleIt = GHMDImplementations.CreateIterator(); HMDModuleIt; ++HMDModuleIt)
|
|
{
|
|
(*HMDModuleIt)->PreInit();
|
|
}
|
|
|
|
GHMDsInitialized = true;
|
|
}
|
|
|
|
JNI_METHOD void Java_com_epicgames_ue4_GameActivity_nativeSetAndroidVersionInformation(JNIEnv* jenv, jobject thiz, jstring androidVersion, jstring phoneMake, jstring phoneModel, jstring osLanguage )
|
|
{
|
|
const char *javaAndroidVersion = jenv->GetStringUTFChars(androidVersion, 0 );
|
|
FString UEAndroidVersion = FString(UTF8_TO_TCHAR( javaAndroidVersion ));
|
|
|
|
const char *javaPhoneMake = jenv->GetStringUTFChars(phoneMake, 0 );
|
|
FString UEPhoneMake = FString(UTF8_TO_TCHAR( javaPhoneMake ));
|
|
|
|
const char *javaPhoneModel = jenv->GetStringUTFChars(phoneModel, 0 );
|
|
FString UEPhoneModel = FString(UTF8_TO_TCHAR( javaPhoneModel ));
|
|
|
|
const char *javaOSLanguage = jenv->GetStringUTFChars(osLanguage, 0);
|
|
FString UEOSLanguage = FString(UTF8_TO_TCHAR(javaOSLanguage));
|
|
|
|
FAndroidMisc::SetVersionInfo( UEAndroidVersion, UEPhoneMake, UEPhoneModel, UEOSLanguage );
|
|
}
|
|
|
|
bool WaitForAndroidLoseFocusEvent(double TimeoutSeconds)
|
|
{
|
|
return FAppEventManager::GetInstance()->WaitForEventInQueue(EAppEventState::APP_EVENT_STATE_WINDOW_LOST_FOCUS, TimeoutSeconds);
|
|
}
|