Browse Source

Merge pull request #248 from revvv/ios-touch-fix

fix iOS touch: added scale factor
MeFisto94 5 years ago
parent
commit
c2d84b943c

+ 7 - 3
jme3-ios/ios-data/templates/project/jme-ios/jmeAppDelegate.m

@@ -275,7 +275,9 @@ getEnv(JavaVM* vm)
     if (e) {
     	UITouch *touch = [touches anyObject];
     	CGPoint position = [touch locationInView: nil];
-        (*e)->CallVoidMethod(e, self.harness, self.injectTouchBegin, 0, touch.timestamp, position.x, position.y);
+        float scale = _glview.contentScaleFactor;
+        // NOTE: cast to jlong is required, otherwise JmeAppHarness receives non-sense values
+        (*e)->CallVoidMethod(e, self.harness, self.injectTouchBegin, 0, (jlong) touch.timestamp, position.x * scale, position.y * scale);
         if ((*e)->ExceptionCheck(e)) {
             NSLog(@"Could not invoke iOS Harness injectTouchBegin");
             (*e)->ExceptionDescribe(e);
@@ -290,7 +292,8 @@ getEnv(JavaVM* vm)
     if (e) {
     	UITouch *touch = [touches anyObject];
     	CGPoint position = [touch locationInView: nil];
-        (*e)->CallVoidMethod(e, self.harness, self.injectTouchMove, 0, touch.timestamp, position.x, position.y);
+        float scale = _glview.contentScaleFactor;
+        (*e)->CallVoidMethod(e, self.harness, self.injectTouchMove, 0, (jlong) touch.timestamp, position.x * scale, position.y * scale);
         if ((*e)->ExceptionCheck(e)) {
             NSLog(@"Could not invoke iOS Harness injectTouchMove");
             (*e)->ExceptionDescribe(e);
@@ -305,7 +308,8 @@ getEnv(JavaVM* vm)
     if (e) {
     	UITouch *touch = [touches anyObject];
     	CGPoint position = [touch locationInView: nil];
-        (*e)->CallVoidMethod(e, self.harness, self.injectTouchEnd, 0, touch.timestamp, position.x, position.y);
+        float scale = _glview.contentScaleFactor;
+        (*e)->CallVoidMethod(e, self.harness, self.injectTouchEnd, 0, (jlong) touch.timestamp, position.x * scale, position.y * scale);
         if ((*e)->ExceptionCheck(e)) {
             NSLog(@"Could not invoke iOS Harness injectTouchEnd");
             (*e)->ExceptionDescribe(e);

+ 28 - 1
jme3-ios/ios-data/templates/project/jme-ios/logging.properties

@@ -1 +1,28 @@
-.level = FINEST
+# NOTE: If this file has no effect, add this line to your app:
+#       Class.forName("java.util.logging.LoggingProxyImpl");
+
+.level = FINEST
+#.level = OFF
+
+#com.mycompany.mygame.level = ALL
+#com.mycompany.mygame.level = INFO
+
+#handlers = handler1, handler2, handler3
+
+#handlers = com.jme3.system.ios.IosLogHandler
+# NOTE: IosLogHandler is always present, logs to System.err and is not configurable.
+#       Therefore you will see each log twice if you add another handler.
+
+#handlers = java.util.logging.ConsoleHandler
+#java.util.logging.ConsoleHandler.level = ALL
+#java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
+
+#handlers = java.util.logging.FileHandler
+#java.util.logging.FileHandler.level = ALL
+#java.util.logging.FileHandler.pattern = /tmp/mygame.log
+#java.util.logging.FileHandler.limit = 50000000
+#java.util.logging.FileHandler.count = 1
+#java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
+
+# http://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html#syntax
+#java.util.logging.SimpleFormatter.format = %1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS.%1$tL %4$s %2$s %5$s%6$s%n