diff --git a/JavaApp/src/main/java/org/lwjgl/glfw/CallbackBridge.java b/JavaApp/src/main/java/org/lwjgl/glfw/CallbackBridge.java index aecb87cb..3ab48ccd 100644 --- a/JavaApp/src/main/java/org/lwjgl/glfw/CallbackBridge.java +++ b/JavaApp/src/main/java/org/lwjgl/glfw/CallbackBridge.java @@ -57,7 +57,7 @@ public class CallbackBridge { net.kdt.pojavlaunch.PLaunchApp.applicationDidFinishLaunching(); } - public static void callback_ViewController_onTouch(int event, int x, int y) { + public static void callback_SurfaceViewController_onTouch(int event, int x, int y) { switch (event) { case ACTION_DOWN: case ACTION_UP: diff --git a/Natives/CMakeLists.txt b/Natives/CMakeLists.txt index eeceb367..014bce54 100644 --- a/Natives/CMakeLists.txt +++ b/Natives/CMakeLists.txt @@ -13,7 +13,7 @@ set_target_properties(PojavLauncher PROPERTIES MACOSX_FRAMEWORK_IDENTIFIER org.cmake.ExecutableTarget MACOSX_BUNDLE_INFO_PLIST "../Info.plist") -add_library(pojavexec SHARED log.m AppDelegate.m UILauncher.m ViewController.m egl_bridge_ios.m egl_bridge.c input_bridge_v3.c utils.c) +add_library(pojavexec SHARED log.m AppDelegate.m UILauncher.m SurfaceViewController.m egl_bridge_ios.m egl_bridge.c input_bridge_v3.c utils.c) target_link_libraries(pojavexec "-Fresources/Frameworks" "-framework UIKit" diff --git a/Natives/ViewController.h b/Natives/SurfaceViewController.h similarity index 67% rename from Natives/ViewController.h rename to Natives/SurfaceViewController.h index 7108bf22..4b70b7c4 100644 --- a/Natives/ViewController.h +++ b/Natives/SurfaceViewController.h @@ -3,7 +3,7 @@ MGLKView *glView; -@interface ViewController : MGLKViewController +@interface SurfaceViewController : MGLKViewController // MGLKViewController // UIViewController diff --git a/Natives/ViewController.m b/Natives/SurfaceViewController.m similarity index 87% rename from Natives/ViewController.m rename to Natives/SurfaceViewController.m index 9ebb1ae9..b770e883 100644 --- a/Natives/ViewController.m +++ b/Natives/SurfaceViewController.m @@ -1,4 +1,4 @@ -#import "ViewController.h" +#import "SurfaceViewController.h" #import "egl_bridge_ios.h" #include "utils.h" @@ -7,7 +7,7 @@ #include "GLES2/gl2.h" #include "GLES2/gl2ext.h" -@interface ViewController () { +@interface SurfaceViewController () { } @property (strong, nonatomic) MGLContext *context; @@ -16,7 +16,7 @@ @end -@implementation ViewController +@implementation SurfaceViewController - (void)viewDidLoad { @@ -86,10 +86,13 @@ - (void)sendTouchEvent:(NSSet *)touches withEvent:(int)event { + CGRect screenBounds = [[UIScreen mainScreen] bounds]; + CGFloat screenScale = [[UIScreen mainScreen] scale]; + UITouch* touchEvent = [touches anyObject]; CGPoint locationInView = [touchEvent locationInView:self.view]; // CGPoint normalizedPoint = getNormalizedPoint(self.view, locationInView); - callback_ViewController_onTouch(event, locationInView.x, locationInView.y /* normalizedPoint.x, normalizedPoint.y */); + callback_SurfaceViewController_onTouch(event, locationInView.x * screenScale, locationInView.y * screenScale /* normalizedPoint.x, normalizedPoint.y */); } // Equals to Android ACTION_DOWN diff --git a/Natives/aminimake.sh b/Natives/aminimake.sh index 5c2d0951..e35597af 100644 --- a/Natives/aminimake.sh +++ b/Natives/aminimake.sh @@ -5,7 +5,7 @@ set -e CFLAGS="-fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -Wno-trigraphs -fpascal-strings -O3 -Wno-missing-field-initializers -Wno-missing-prototypes -Wno-return-type -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wno-unused-variable -Wunused-value -Wno-empty-body -Wno-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wno-constant-conversion -Wno-int-conversion -Wno-bool-conversion -Wno-enum-conversion -Wno-float-conversion -Wno-non-literal-null-conversion -Wno-objc-literal-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof" -clang -Wl,-rpath,/Applications/PojavLauncher.app/Frameworks -fobjc-arc -x objective-c -Fresources/Frameworks -framework UIKit -framework MetalANGLE -Iresources/Frameworks/MetalANGLE.framework/Headers -dynamiclib -isysroot /var/mobile/theos/sdks/iPhoneOS11.2.sdk $CFLAGS -o libpojavexec.dylib log.m AppDelegate.m UILauncher.m ViewController.m egl_bridge_ios.m egl_bridge.c input_bridge_v3.c utils.c -DGLES_TESTZ -DUSE_EGLZ +clang -Wl,-rpath,/Applications/PojavLauncher.app/Frameworks -fobjc-arc -x objective-c -Fresources/Frameworks -framework UIKit -framework MetalANGLE -Iresources/Frameworks/MetalANGLE.framework/Headers -dynamiclib -isysroot /var/mobile/theos/sdks/iPhoneOS11.2.sdk $CFLAGS -o libpojavexec.dylib log.m AppDelegate.m UILauncher.m SurfaceViewController.m egl_bridge_ios.m egl_bridge.c input_bridge_v3.c utils.c -DGLES_TESTZ -DUSE_EGLZ ldid -S../entitlements.xml libpojavexec.dylib diff --git a/Natives/en.lproj/Main.storyboard b/Natives/en.lproj/Main.storyboard index 2ff12f8a..def09684 100644 --- a/Natives/en.lproj/Main.storyboard +++ b/Natives/en.lproj/Main.storyboard @@ -7,7 +7,7 @@ - + diff --git a/Natives/input_bridge_v3.c b/Natives/input_bridge_v3.c index 64d4088b..361d3869 100644 --- a/Natives/input_bridge_v3.c +++ b/Natives/input_bridge_v3.c @@ -174,7 +174,7 @@ void callback_AppDelegate_didFinishLaunching(int width, int height) { ); } -void callback_ViewController_onTouch(int event, int x, int y) { +void callback_SurfaceViewController_onTouch(int event, int x, int y) { // Because UI init after JVM init, this should not be null assert (runtimeJNIEnvPtr_JRE != NULL); @@ -184,7 +184,7 @@ void callback_ViewController_onTouch(int event, int x, int y) { } if (!touchBridgeMethod) { - touchBridgeMethod = (*runtimeJNIEnvPtr_JRE)->GetStaticMethodID(runtimeJNIEnvPtr_JRE, inputBridgeClass_ANDROID, "callback_ViewController_onTouch", "(III)V"); + touchBridgeMethod = (*runtimeJNIEnvPtr_JRE)->GetStaticMethodID(runtimeJNIEnvPtr_JRE, inputBridgeClass_ANDROID, "callback_SurfaceViewController_onTouch", "(III)V"); assert(touchBridgeMethod != NULL); } diff --git a/Natives/libpojavexec.dylib b/Natives/libpojavexec.dylib new file mode 100755 index 00000000..c1ced690 Binary files /dev/null and b/Natives/libpojavexec.dylib differ diff --git a/Natives/utils.h b/Natives/utils.h index 521923d0..d4e0aef7 100644 --- a/Natives/utils.h +++ b/Natives/utils.h @@ -31,7 +31,7 @@ void free_char_array(JNIEnv *env, jobjectArray jstringArray, const char **charAr void closeGLFWWindow(); void callback_AppDelegate_didFinishLaunching(int width, int height); -void callback_ViewController_onTouch(int event, int x, int y); +void callback_SurfaceViewController_onTouch(int event, int x, int y); #endif // _BINARY_UTILS_H_