diff --git a/Natives/SurfaceViewController.m b/Natives/SurfaceViewController.m index f258abed..326c4c5d 100644 --- a/Natives/SurfaceViewController.m +++ b/Natives/SurfaceViewController.m @@ -95,10 +95,11 @@ int notchOffset; [self.view addSubview:touchView]; - if (@available(iOS 13.4, *)) { + if (NSClassFromString(@"UIPointerInteraction") != nil) { [touchView addInteraction:[[UIPointerInteraction alloc] initWithDelegate:self]]; - - // TODO scroll + } + + if (@available(iOS 13.4, *)) { UIPanGestureRecognizer *mouseWheelGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(surfaceOnMouseScroll:)]; mouseWheelGesture.allowedScrollTypesMask = UIScrollTypeMaskDiscrete; mouseWheelGesture.allowedTouchTypes = @[ @(UITouchTypeIndirectPointer) ]; @@ -346,6 +347,55 @@ BOOL isNotifRemoved; } } +-(void)surfaceOnMouseScroll:(UIPanGestureRecognizer *)sender API_AVAILABLE(ios(13.4)) +{ + if (sender.state == UIGestureRecognizerStateBegan || + sender.state == UIGestureRecognizerStateChanged || + sender.state == UIGestureRecognizerStateEnded) { + CGPoint velocity = [sender velocityInView:self]; + + if (velocity.x > 0.0f) { + velocity.x = -1.0; + } else if (velocity.x < 0.0f) { + velocity.x = 1.0f; + } + if (velocity.y > 0.0f) { + velocity.y = -1.0; + } else if (velocity.y < 0.0f) { + velocity.y = 1.0f; + } + if (velocity.x != 0.0f || velocity.y != 0.0f) { + Java_org_lwjgl_glfw_CallbackBridge_nativeSendScroll(NULL, NULL, (jdouble) velocity.x, (jdouble) velocity.y); + } + } +} + +- (UIPointerRegion *)pointerInteraction:(UIPointerInteraction *)interaction regionForRequest:(UIPointerRegionRequest *)request defaultRegion:(UIPointerRegion *)defaultRegion API_AVAILABLE(ios(13.4)) API_AVAILABLE(ios(13.4)) API_AVAILABLE(ios(13.4)){ + if (request != nil) { + CGPoint origin = touchView.bounds.origin; + CGPoint point = request.location; + + point.x -= origin.x; + point.y -= origin.y; + + NSLog("UIPointerInteraction pos changed: x=%d, y=%d", point.x, point.y); + + // TODO FIXME + callback_SurfaceViewController_onTouch(ACTION_DOWN, (int)point.x, (int)point.y); + } + return [UIPointerRegion regionWithRect:touchView.bounds identifier:nil]; +} + +- (UIPointerStyle *)pointerInteraction:(UIPointerInteraction *)interaction styleForRegion:(UIPointerRegion *)region API_AVAILABLE(ios(13.4)){ + if (isGrabbing == JNI_FALSE) { + return nil; + } else { + return [UIPointerStyle hiddenPointerStyle]; + } +} + +#pragma mark - Input view stuff + -(void)inputViewDidChange { if ([inputView.text length] <= 1) { Java_org_lwjgl_glfw_CallbackBridge_nativeSendKey(NULL, NULL, GLFW_KEY_BACKSPACE, 0, 1, 0); diff --git a/Natives/aminimake.sh b/Natives/aminimake.sh index 82790c31..ac2655f7 100644 --- a/Natives/aminimake.sh +++ b/Natives/aminimake.sh @@ -6,7 +6,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 -Wl,-rpath,/Applications/PojavLauncher.app/Frameworks -fobjc-arc -x objective-c -Fresources/Frameworks -Iresources/Frameworks/MetalANGLE.framework/Headers -isysroot /var/mobile/theos/sdks/iPhoneOS13.4.sdk" clang -framework UIKit $CFLAGS -o PojavLauncher main.c log.m JavaLauncher.c -clang -framework UIKit -framework MetalANGLE -framework CoreGraphics -framework SafariServices -dynamiclib $CFLAGS -o libpojavexec.dylib log.m AppDelegate.m SceneDelegate.m UILauncher.m LauncherViewController.m LoginViewController.m SurfaceViewController.m egl_bridge_ios.m ios_uikit_bridge.m egl_bridge.c input_bridge_v3.c utils.c -DGLES_TESTZ -DUSE_EGLZ +clang -framework UIKit -framework MetalANGLE -framework CoreGraphics -framework SafariServices -dynamiclib $CFLAGS -o libpojavexec.dylib log.m AppDelegate.m SceneDelegate.m UILauncher.m LauncherViewController.m LoginViewController.m SurfaceViewController.m egl_bridge_ios.m ios_uikit_bridge.m egl_bridge.c input_bridge_v3.c utils.c -DGLES_TESTZ -DUSE_EGLZ -Wl,-undefined,dynamic_lookup ldid -S../entitlements.xml PojavLauncher ldid -S../entitlements.xml libpojavexec.dylib