Révision | a2db6bc692c1b0ac069851bcb81b4a0ecda86384 (tree) |
---|---|
l'heure | 2021-09-27 21:27:11 |
Auteur | Hotshot5000 <sebastian_bugiu@yaho...> |
Commiter | Hotshot5000 |
Added continuous and transient vibration support
@@ -750,6 +750,16 @@ public class AndroidGraphics extends AbstractGraphics implements Renderer { | ||
750 | 750 | public void setSystemCursor (SystemCursor systemCursor) { |
751 | 751 | } |
752 | 752 | |
753 | + @Override | |
754 | + public long getViewHandle() { | |
755 | + return 0; | |
756 | + } | |
757 | + | |
758 | + @Override | |
759 | + public long getViewControllerHandle() { | |
760 | + return 0; | |
761 | + } | |
762 | + | |
753 | 763 | private class AndroidDisplayMode extends DisplayMode { |
754 | 764 | protected AndroidDisplayMode (int width, int height, int refreshRate, int bitsPerPixel) { |
755 | 765 | super(width, height, refreshRate, bitsPerPixel); |
@@ -661,6 +661,26 @@ public class DefaultAndroidInput extends AbstractInput implements AndroidInput { | ||
661 | 661 | } |
662 | 662 | |
663 | 663 | @Override |
664 | + public void vibrate(int milliseconds, VibrationStyle vibrationStyle) { | |
665 | + | |
666 | + } | |
667 | + | |
668 | + @Override | |
669 | + public void vibrate(int milliseconds, VibrationStyle vibrationStyle, boolean fallback) { | |
670 | + | |
671 | + } | |
672 | + | |
673 | + @Override | |
674 | + public void vibrate(int milliseconds, int amplitude, VibrationStyle vibrationStyle, boolean fallback) { | |
675 | + | |
676 | + } | |
677 | + | |
678 | + @Override | |
679 | + public void vibrate(VibrationType vibrationType, VibrationStyle vibrationStyle, boolean fallback) { | |
680 | + | |
681 | + } | |
682 | + | |
683 | + @Override | |
664 | 684 | public boolean justTouched () { |
665 | 685 | return justTouched; |
666 | 686 | } |
@@ -256,6 +256,16 @@ public class MockGraphics extends AbstractGraphics { | ||
256 | 256 | } |
257 | 257 | |
258 | 258 | @Override |
259 | + public long getViewHandle() { | |
260 | + return 0; | |
261 | + } | |
262 | + | |
263 | + @Override | |
264 | + public long getViewControllerHandle() { | |
265 | + return 0; | |
266 | + } | |
267 | + | |
268 | + @Override | |
259 | 269 | public Monitor getPrimaryMonitor() { |
260 | 270 | return null; |
261 | 271 | } |
@@ -183,6 +183,26 @@ public class MockInput implements Input { | ||
183 | 183 | } |
184 | 184 | |
185 | 185 | @Override |
186 | + public void vibrate(int milliseconds, VibrationStyle vibrationStyle) { | |
187 | + | |
188 | + } | |
189 | + | |
190 | + @Override | |
191 | + public void vibrate(int milliseconds, VibrationStyle vibrationStyle, boolean fallback) { | |
192 | + | |
193 | + } | |
194 | + | |
195 | + @Override | |
196 | + public void vibrate(int milliseconds, int amplitude, VibrationStyle vibrationStyle, boolean fallback) { | |
197 | + | |
198 | + } | |
199 | + | |
200 | + @Override | |
201 | + public void vibrate(VibrationType vibrationType, VibrationStyle vibrationStyle, boolean fallback) { | |
202 | + | |
203 | + } | |
204 | + | |
205 | + @Override | |
186 | 206 | public float getAzimuth() { |
187 | 207 | return 0; |
188 | 208 | } |
@@ -639,6 +639,26 @@ final public class DefaultLwjglInput extends AbstractInput implements LwjglInput | ||
639 | 639 | } |
640 | 640 | |
641 | 641 | @Override |
642 | + public void vibrate(int milliseconds, VibrationStyle vibrationStyle) { | |
643 | + | |
644 | + } | |
645 | + | |
646 | + @Override | |
647 | + public void vibrate(int milliseconds, VibrationStyle vibrationStyle, boolean fallback) { | |
648 | + | |
649 | + } | |
650 | + | |
651 | + @Override | |
652 | + public void vibrate(int milliseconds, int amplitude, VibrationStyle vibrationStyle, boolean fallback) { | |
653 | + | |
654 | + } | |
655 | + | |
656 | + @Override | |
657 | + public void vibrate(VibrationType vibrationType, VibrationStyle vibrationStyle, boolean fallback) { | |
658 | + | |
659 | + } | |
660 | + | |
661 | + @Override | |
642 | 662 | public boolean justTouched () { |
643 | 663 | return justTouched; |
644 | 664 | } |
@@ -859,6 +859,26 @@ public class LwjglAWTInput extends AbstractInput implements MouseMotionListener, | ||
859 | 859 | } |
860 | 860 | |
861 | 861 | @Override |
862 | + public void vibrate(int milliseconds, VibrationStyle vibrationStyle) { | |
863 | + | |
864 | + } | |
865 | + | |
866 | + @Override | |
867 | + public void vibrate(int milliseconds, VibrationStyle vibrationStyle, boolean fallback) { | |
868 | + | |
869 | + } | |
870 | + | |
871 | + @Override | |
872 | + public void vibrate(int milliseconds, int amplitude, VibrationStyle vibrationStyle, boolean fallback) { | |
873 | + | |
874 | + } | |
875 | + | |
876 | + @Override | |
877 | + public void vibrate(VibrationType vibrationType, VibrationStyle vibrationStyle, boolean fallback) { | |
878 | + | |
879 | + } | |
880 | + | |
881 | + @Override | |
862 | 882 | public boolean justTouched () { |
863 | 883 | return justTouched; |
864 | 884 | } |
@@ -730,6 +730,16 @@ public class LwjglGraphics extends AbstractGraphics { | ||
730 | 730 | } |
731 | 731 | } |
732 | 732 | |
733 | + @Override | |
734 | + public long getViewHandle() { | |
735 | + return 0; | |
736 | + } | |
737 | + | |
738 | + @Override | |
739 | + public long getViewControllerHandle() { | |
740 | + return 0; | |
741 | + } | |
742 | + | |
733 | 743 | private class LwjglDisplayMode extends DisplayMode { |
734 | 744 | org.lwjgl.opengl.DisplayMode mode; |
735 | 745 |
@@ -674,6 +674,26 @@ public class DefaultLwjgl3Input extends AbstractInput implements Lwjgl3Input { | ||
674 | 674 | } |
675 | 675 | |
676 | 676 | @Override |
677 | + public void vibrate(int milliseconds, VibrationStyle vibrationStyle) { | |
678 | + | |
679 | + } | |
680 | + | |
681 | + @Override | |
682 | + public void vibrate(int milliseconds, VibrationStyle vibrationStyle, boolean fallback) { | |
683 | + | |
684 | + } | |
685 | + | |
686 | + @Override | |
687 | + public void vibrate(int milliseconds, int amplitude, VibrationStyle vibrationStyle, boolean fallback) { | |
688 | + | |
689 | + } | |
690 | + | |
691 | + @Override | |
692 | + public void vibrate(VibrationType vibrationType, VibrationStyle vibrationStyle, boolean fallback) { | |
693 | + | |
694 | + } | |
695 | + | |
696 | + @Override | |
677 | 697 | public float getAzimuth () { |
678 | 698 | return 0; |
679 | 699 | } |
@@ -505,6 +505,16 @@ public class Lwjgl3Graphics extends AbstractGraphics implements Disposable { | ||
505 | 505 | } |
506 | 506 | |
507 | 507 | @Override |
508 | + public long getViewHandle() { | |
509 | + return 0; | |
510 | + } | |
511 | + | |
512 | + @Override | |
513 | + public long getViewControllerHandle() { | |
514 | + return 0; | |
515 | + } | |
516 | + | |
517 | + @Override | |
508 | 518 | public void dispose() { |
509 | 519 | this.resizeCallback.free(); |
510 | 520 | } |
@@ -563,6 +563,26 @@ public class DefaultIOSInput extends AbstractInput implements IOSInput { | ||
563 | 563 | } |
564 | 564 | |
565 | 565 | @Override |
566 | + public void vibrate(int milliseconds, VibrationStyle vibrationStyle) { | |
567 | + haptics.vibrate(milliseconds, vibrationStyle, true); | |
568 | + } | |
569 | + | |
570 | + @Override | |
571 | + public void vibrate(int milliseconds, VibrationStyle vibrationStyle, boolean fallback) { | |
572 | + haptics.vibrate(milliseconds, vibrationStyle, fallback); | |
573 | + } | |
574 | + | |
575 | + @Override | |
576 | + public void vibrate(int milliseconds, int amplitude, VibrationStyle vibrationStyle, boolean fallback) { | |
577 | + haptics.vibrate(milliseconds, amplitude, vibrationStyle, fallback); | |
578 | + } | |
579 | + | |
580 | + @Override | |
581 | + public void vibrate(VibrationType vibrationType, VibrationStyle vibrationStyle, boolean fallback) { | |
582 | + haptics.vibrate(vibrationType, vibrationStyle, fallback); | |
583 | + } | |
584 | + | |
585 | + @Override | |
566 | 586 | public long getCurrentEventTime () { |
567 | 587 | return currentEventTimeStamp; |
568 | 588 | } |
@@ -130,7 +130,7 @@ public class IOSApplication implements Application { | ||
130 | 130 | Gdx.app.debug("IOSApplication", "Pixels per point: " + pixelsPerPoint); |
131 | 131 | |
132 | 132 | this.uiWindow = new UIWindow(UIScreen.getMainScreen().getBounds()); |
133 | - this.uiWindow.makeKeyAndVisible(); | |
133 | +// this.uiWindow.makeKeyAndVisible(); | |
134 | 134 | uiApp.getDelegate().setWindow(uiWindow); |
135 | 135 | |
136 | 136 | // setup libgdx |
@@ -150,8 +150,13 @@ public class IOSApplication implements Application { | ||
150 | 150 | |
151 | 151 | this.input.setupPeripherals(); |
152 | 152 | |
153 | - this.uiWindow.setRootViewController(this.graphics.viewController); | |
153 | +// this.uiWindow.setRootViewController(this.graphics.viewController); | |
154 | 154 | Gdx.app.debug("IOSApplication", "created"); |
155 | + // We need to pass the uiWindow pointer to native side where setting the root view will happen. | |
156 | + long uiWindowHandle = uiWindow.getHandle(); | |
157 | + config.uiWindowHandle = uiWindowHandle; | |
158 | + | |
159 | + Gdx.app.getApplicationListener().create(); | |
155 | 160 | return true; |
156 | 161 | } |
157 | 162 |
@@ -268,7 +273,7 @@ public class IOSApplication implements Application { | ||
268 | 273 | Gdx.app.debug("IOSApplication", "paused"); |
269 | 274 | graphics.makeCurrent(); |
270 | 275 | graphics.pause(); |
271 | - Gdx.gl.glFinish(); | |
276 | +// Gdx.gl.glFinish(); | |
272 | 277 | } |
273 | 278 | |
274 | 279 | final void willTerminate (UIApplication uiApp) { |
@@ -281,7 +286,7 @@ public class IOSApplication implements Application { | ||
281 | 286 | } |
282 | 287 | } |
283 | 288 | listener.dispose(); |
284 | - Gdx.gl.glFinish(); | |
289 | +// Gdx.gl.glFinish(); | |
285 | 290 | } |
286 | 291 | |
287 | 292 | @Override |
@@ -84,6 +84,8 @@ public class IOSApplicationConfiguration { | ||
84 | 84 | * Prior to iOS 11, UIRectEdge.All was default behaviour if status bar hidden, see https://github.com/libgdx/libgdx/issues/5110 **/ |
85 | 85 | public UIRectEdge screenEdgesDeferringSystemGestures = UIRectEdge.None; |
86 | 86 | |
87 | + public long uiWindowHandle; | |
88 | + | |
87 | 89 | /** The maximum number of threads to use for network requests. Default is {@link Integer#MAX_VALUE}. */ |
88 | 90 | public int maxNetThreads = Integer.MAX_VALUE; |
89 | 91 |
@@ -91,58 +91,58 @@ public class IOSGraphics extends AbstractGraphics { | ||
91 | 91 | // setup view and OpenGL |
92 | 92 | screenBounds = app.computeBounds(); |
93 | 93 | |
94 | - if (useGLES30) { | |
95 | - context = new EAGLContext(EAGLRenderingAPI.OpenGLES3); | |
96 | - if (context != null) | |
97 | - gl20 = gl30 = new IOSGLES30(); | |
98 | - else | |
99 | - Gdx.app.log("IOGraphics", "OpenGL ES 3.0 not supported, falling back on 2.0"); | |
100 | - } | |
101 | - if (context == null) { | |
102 | - context = new EAGLContext(EAGLRenderingAPI.OpenGLES2); | |
103 | - gl20 = new IOSGLES20(); | |
104 | - gl30 = null; | |
105 | - } | |
106 | - | |
107 | - IOSViewDelegate viewDelegate = new IOSViewDelegate(); | |
108 | - view = new GLKView(new CGRect(0, 0, screenBounds.width, screenBounds.height), context) { | |
109 | - @Method(selector = "touchesBegan:withEvent:") | |
110 | - public void touchesBegan (@Pointer long touches, UIEvent event) { | |
111 | - IOSGraphics.this.input.onTouch(touches); | |
112 | - } | |
113 | - | |
114 | - @Method(selector = "touchesCancelled:withEvent:") | |
115 | - public void touchesCancelled (@Pointer long touches, UIEvent event) { | |
116 | - IOSGraphics.this.input.onTouch(touches); | |
117 | - } | |
118 | - | |
119 | - @Method(selector = "touchesEnded:withEvent:") | |
120 | - public void touchesEnded (@Pointer long touches, UIEvent event) { | |
121 | - IOSGraphics.this.input.onTouch(touches); | |
122 | - } | |
123 | - | |
124 | - @Method(selector = "touchesMoved:withEvent:") | |
125 | - public void touchesMoved (@Pointer long touches, UIEvent event) { | |
126 | - IOSGraphics.this.input.onTouch(touches); | |
127 | - } | |
128 | - | |
129 | - @Override | |
130 | - public void draw (CGRect rect) { | |
131 | - IOSGraphics.this.draw(this, rect); | |
132 | - } | |
133 | - | |
134 | - }; | |
135 | - view.setDelegate(viewDelegate); | |
136 | - view.setDrawableColorFormat(config.colorFormat); | |
137 | - view.setDrawableDepthFormat(config.depthFormat); | |
138 | - view.setDrawableStencilFormat(config.stencilFormat); | |
139 | - view.setDrawableMultisample(config.multisample); | |
140 | - view.setMultipleTouchEnabled(true); | |
141 | - | |
142 | - viewController = app.createUIViewController(this); | |
143 | - viewController.setView(view); | |
144 | - viewController.setDelegate(viewDelegate); | |
145 | - viewController.setPreferredFramesPerSecond(config.preferredFramesPerSecond); | |
94 | +// if (useGLES30) { | |
95 | +// context = new EAGLContext(EAGLRenderingAPI.OpenGLES3); | |
96 | +// if (context != null) | |
97 | +// gl20 = gl30 = new IOSGLES30(); | |
98 | +// else | |
99 | +// Gdx.app.log("IOGraphics", "OpenGL ES 3.0 not supported, falling back on 2.0"); | |
100 | +// } | |
101 | +// if (context == null) { | |
102 | +// context = new EAGLContext(EAGLRenderingAPI.OpenGLES2); | |
103 | +// gl20 = new IOSGLES20(); | |
104 | +// gl30 = null; | |
105 | +// } | |
106 | +// | |
107 | +// IOSViewDelegate viewDelegate = new IOSViewDelegate(); | |
108 | +// view = new GLKView(new CGRect(0, 0, screenBounds.width, screenBounds.height), context) { | |
109 | +// @Method(selector = "touchesBegan:withEvent:") | |
110 | +// public void touchesBegan (@Pointer long touches, UIEvent event) { | |
111 | +// IOSGraphics.this.input.onTouch(touches); | |
112 | +// } | |
113 | +// | |
114 | +// @Method(selector = "touchesCancelled:withEvent:") | |
115 | +// public void touchesCancelled (@Pointer long touches, UIEvent event) { | |
116 | +// IOSGraphics.this.input.onTouch(touches); | |
117 | +// } | |
118 | +// | |
119 | +// @Method(selector = "touchesEnded:withEvent:") | |
120 | +// public void touchesEnded (@Pointer long touches, UIEvent event) { | |
121 | +// IOSGraphics.this.input.onTouch(touches); | |
122 | +// } | |
123 | +// | |
124 | +// @Method(selector = "touchesMoved:withEvent:") | |
125 | +// public void touchesMoved (@Pointer long touches, UIEvent event) { | |
126 | +// IOSGraphics.this.input.onTouch(touches); | |
127 | +// } | |
128 | +// | |
129 | +// @Override | |
130 | +// public void draw (CGRect rect) { | |
131 | +// IOSGraphics.this.draw(this, rect); | |
132 | +// } | |
133 | +// | |
134 | +// }; | |
135 | +// view.setDelegate(viewDelegate); | |
136 | +// view.setDrawableColorFormat(config.colorFormat); | |
137 | +// view.setDrawableDepthFormat(config.depthFormat); | |
138 | +// view.setDrawableStencilFormat(config.stencilFormat); | |
139 | +// view.setDrawableMultisample(config.multisample); | |
140 | +// view.setMultipleTouchEnabled(true); | |
141 | +// | |
142 | +// viewController = app.createUIViewController(this); | |
143 | +// viewController.setView(view); | |
144 | +// viewController.setDelegate(viewDelegate); | |
145 | +// viewController.setPreferredFramesPerSecond(config.preferredFramesPerSecond); | |
146 | 146 | |
147 | 147 | this.app = app; |
148 | 148 | this.input = input; |
@@ -219,21 +219,21 @@ public class IOSGraphics extends AbstractGraphics { | ||
219 | 219 | boolean created = false; |
220 | 220 | |
221 | 221 | public void draw (GLKView view, CGRect rect) { |
222 | - makeCurrent(); | |
223 | - // massive hack, GLKView resets the viewport on each draw call, so IOSGLES20 | |
224 | - // stores the last known viewport and we reset it here... | |
225 | - gl20.glViewport(IOSGLES20.x, IOSGLES20.y, IOSGLES20.width, IOSGLES20.height); | |
222 | +// makeCurrent(); | |
223 | +// // massive hack, GLKView resets the viewport on each draw call, so IOSGLES20 | |
224 | +// // stores the last known viewport and we reset it here... | |
225 | +// gl20.glViewport(IOSGLES20.x, IOSGLES20.y, IOSGLES20.width, IOSGLES20.height); | |
226 | 226 | |
227 | 227 | if (!created) { |
228 | 228 | // OpenGL glViewport() function expects backbuffer coordinates instead of logical coordinates |
229 | - gl20.glViewport(0, 0, screenBounds.backBufferWidth, screenBounds.backBufferHeight); | |
230 | - | |
231 | - String versionString = gl20.glGetString(GL20.GL_VERSION); | |
232 | - String vendorString = gl20.glGetString(GL20.GL_VENDOR); | |
233 | - String rendererString = gl20.glGetString(GL20.GL_RENDERER); | |
234 | - glVersion = new GLVersion(Application.ApplicationType.iOS, versionString, vendorString, rendererString); | |
235 | - | |
236 | - updateSafeInsets(); | |
229 | +// gl20.glViewport(0, 0, screenBounds.backBufferWidth, screenBounds.backBufferHeight); | |
230 | +// | |
231 | +// String versionString = gl20.glGetString(GL20.GL_VERSION); | |
232 | +// String vendorString = gl20.glGetString(GL20.GL_VENDOR); | |
233 | +// String rendererString = gl20.glGetString(GL20.GL_RENDERER); | |
234 | +// glVersion = new GLVersion(Application.ApplicationType.iOS, versionString, vendorString, rendererString); | |
235 | +// | |
236 | +// updateSafeInsets(); | |
237 | 237 | app.listener.create(); |
238 | 238 | app.listener.resize(getWidth(), getHeight()); |
239 | 239 | created = true; |
@@ -264,16 +264,16 @@ public class IOSGraphics extends AbstractGraphics { | ||
264 | 264 | } |
265 | 265 | |
266 | 266 | void makeCurrent () { |
267 | - EAGLContext.setCurrentContext(context); | |
267 | +// EAGLContext.setCurrentContext(context); | |
268 | 268 | } |
269 | 269 | |
270 | 270 | public void update (GLKViewController controller) { |
271 | - makeCurrent(); | |
271 | +// makeCurrent(); | |
272 | 272 | app.processRunnables(); |
273 | 273 | // pause the GLKViewController render loop if we are no longer continuous |
274 | 274 | // and if we haven't requested a frame in the last loop iteration |
275 | 275 | if (!isContinuous && !isFrameRequested) { |
276 | - viewController.setPaused(true); | |
276 | +// viewController.setPaused(true); | |
277 | 277 | } |
278 | 278 | isFrameRequested = false; |
279 | 279 | } |
@@ -497,6 +497,16 @@ public class IOSGraphics extends AbstractGraphics { | ||
497 | 497 | } |
498 | 498 | |
499 | 499 | @Override |
500 | + public long getViewHandle() { | |
501 | + return 0; | |
502 | + } | |
503 | + | |
504 | + @Override | |
505 | + public long getViewControllerHandle() { | |
506 | + return 0; | |
507 | + } | |
508 | + | |
509 | + @Override | |
500 | 510 | public void setResizable(boolean resizable) { |
501 | 511 | } |
502 | 512 |
@@ -528,7 +538,7 @@ public class IOSGraphics extends AbstractGraphics { | ||
528 | 538 | if (isContinuous != this.isContinuous) { |
529 | 539 | this.isContinuous = isContinuous; |
530 | 540 | // start the GLKViewController if we go from non-continuous -> continuous |
531 | - if (isContinuous) viewController.setPaused(false); | |
541 | +// if (isContinuous) viewController.setPaused(false); | |
532 | 542 | } |
533 | 543 | } |
534 | 544 |
@@ -542,7 +552,7 @@ public class IOSGraphics extends AbstractGraphics { | ||
542 | 552 | isFrameRequested = true; |
543 | 553 | // start the GLKViewController if we are in non-continuous mode |
544 | 554 | // (we should already be started in continuous mode) |
545 | - if (!isContinuous) viewController.setPaused(false); | |
555 | +// if (!isContinuous) viewController.setPaused(false); | |
546 | 556 | } |
547 | 557 | |
548 | 558 | @Override |
@@ -56,10 +56,14 @@ public class IOSHaptics { | ||
56 | 56 | } |
57 | 57 | } |
58 | 58 | } |
59 | - | |
59 | + | |
60 | 60 | public void vibrate(int milliseconds, boolean fallback) { |
61 | + vibrate(milliseconds, Input.VibrationStyle.CONTINUOUS, fallback); | |
62 | + } | |
63 | + | |
64 | + public void vibrate(int milliseconds, Input.VibrationStyle vibrationStyle, boolean fallback) { | |
61 | 65 | if (hapticsSupport) { |
62 | - CHHapticPatternDict hapticDict = getChHapticPatternDict(milliseconds, 0.5f); | |
66 | + CHHapticPatternDict hapticDict = getChHapticPatternDict(milliseconds, 0.5f, vibrationStyle); | |
63 | 67 | System.out.println(hapticDict); |
64 | 68 | try { |
65 | 69 | CHHapticPattern pattern = new CHHapticPattern(hapticDict); |
@@ -77,9 +81,13 @@ public class IOSHaptics { | ||
77 | 81 | } |
78 | 82 | |
79 | 83 | public void vibrate(int milliseconds, int amplitude, boolean fallback) { |
84 | + vibrate(milliseconds, amplitude, Input.VibrationStyle.CONTINUOUS, fallback); | |
85 | + } | |
86 | + | |
87 | + public void vibrate(int milliseconds, int amplitude, Input.VibrationStyle vibrationStyle, boolean fallback) { | |
80 | 88 | if (hapticsSupport) { |
81 | 89 | float intensity = MathUtils.clamp(amplitude / 255f, 0, 1); |
82 | - CHHapticPatternDict hapticDict = getChHapticPatternDict(milliseconds, intensity); | |
90 | + CHHapticPatternDict hapticDict = getChHapticPatternDict(milliseconds, intensity, vibrationStyle); | |
83 | 91 | try { |
84 | 92 | CHHapticPattern pattern = new CHHapticPattern(hapticDict); |
85 | 93 | NSError.NSErrorPtr ptr = new NSError.NSErrorPtr(); |
@@ -96,6 +104,10 @@ public class IOSHaptics { | ||
96 | 104 | } |
97 | 105 | |
98 | 106 | private CHHapticPatternDict getChHapticPatternDict(int milliseconds, float intensity) { |
107 | + return getChHapticPatternDict(milliseconds, intensity, Input.VibrationStyle.CONTINUOUS); | |
108 | + } | |
109 | + | |
110 | + private CHHapticPatternDict getChHapticPatternDict(int milliseconds, float intensity, Input.VibrationStyle vibrationStyle) { | |
99 | 111 | // NSArray<NSObject> parameters = new NSArray<NSObject>( |
100 | 112 | // new CHHapticPatternDict().setEventParameters( |
101 | 113 | // new NSArray<NSObject>(new NSDictionary<NSString, NSObject>(new NSString("ParameterID"), new NSString("HapticIntensity"), new NSString("ParameterValue"), NSNumber.valueOf(intensity))) |
@@ -105,13 +117,24 @@ public class IOSHaptics { | ||
105 | 117 | // NSArray<NSObject> parameters = new NSArray<NSObject>( |
106 | 118 | // new NSArray<NSObject>(new CHHapticEventParameter(CHHapticEventParameterID.HapticIntensity, intensity)) |
107 | 119 | // ); |
120 | + CHHapticEventType eventType = null; | |
121 | + switch (vibrationStyle) { | |
122 | + case TRANSIENT: | |
123 | + eventType = CHHapticEventType.HapticTransient; | |
124 | + break; | |
125 | + case CONTINUOUS: | |
126 | + eventType = CHHapticEventType.HapticContinuous; | |
127 | + break; | |
128 | + default: | |
129 | + throw new IllegalStateException("Unexpected value: " + vibrationStyle); | |
130 | + } | |
108 | 131 | return new CHHapticPatternDict() |
109 | 132 | .setPattern( |
110 | 133 | new NSArray<NSObject>( |
111 | 134 | new CHHapticPatternDict() |
112 | 135 | .setEvent( |
113 | 136 | new CHHapticPatternDict() |
114 | - .setEventType(CHHapticEventType.HapticTransient) | |
137 | + .setEventType(eventType) | |
115 | 138 | .setTime(0.0) |
116 | 139 | .setEventDuration(milliseconds / 1000f) |
117 | 140 | .setEventParameters(new NSArray<NSObject>(new NSDictionary<NSString, NSObject>(new NSString("ParameterID"), new NSString("HapticIntensity"), new NSString("ParameterValue"), NSNumber.valueOf(intensity)))) |
@@ -121,8 +144,11 @@ public class IOSHaptics { | ||
121 | 144 | ); |
122 | 145 | } |
123 | 146 | |
124 | - | |
125 | 147 | public void vibrate (Input.VibrationType vibrationType, boolean fallback) { |
148 | + vibrate(vibrationType, Input.VibrationStyle.CONTINUOUS, fallback); | |
149 | + } | |
150 | + | |
151 | + public void vibrate (Input.VibrationType vibrationType, Input.VibrationStyle vibrationStyle, boolean fallback) { | |
126 | 152 | final int DEFAULT_LENGTH = 50; |
127 | 153 | if (hapticsSupport) { |
128 | 154 | UIImpactFeedbackStyle uiImpactFeedbackStyle; |
@@ -309,6 +309,26 @@ public class DefaultGwtInput extends AbstractInput implements GwtInput { | ||
309 | 309 | } |
310 | 310 | |
311 | 311 | @Override |
312 | + public void vibrate(int milliseconds, VibrationStyle vibrationStyle) { | |
313 | + | |
314 | + } | |
315 | + | |
316 | + @Override | |
317 | + public void vibrate(int milliseconds, VibrationStyle vibrationStyle, boolean fallback) { | |
318 | + | |
319 | + } | |
320 | + | |
321 | + @Override | |
322 | + public void vibrate(int milliseconds, int amplitude, VibrationStyle vibrationStyle, boolean fallback) { | |
323 | + | |
324 | + } | |
325 | + | |
326 | + @Override | |
327 | + public void vibrate(VibrationType vibrationType, VibrationStyle vibrationStyle, boolean fallback) { | |
328 | + | |
329 | + } | |
330 | + | |
331 | + @Override | |
312 | 332 | public float getAzimuth () { |
313 | 333 | return 0; |
314 | 334 | } |
@@ -565,6 +565,16 @@ public class GwtGraphics extends AbstractGraphics { | ||
565 | 565 | ((GwtApplication)Gdx.app).graphics.canvas.getStyle().setProperty("cursor", GwtCursor.getNameForSystemCursor(systemCursor)); |
566 | 566 | } |
567 | 567 | |
568 | + @Override | |
569 | + public long getViewHandle() { | |
570 | + return 0; | |
571 | + } | |
572 | + | |
573 | + @Override | |
574 | + public long getViewControllerHandle() { | |
575 | + return 0; | |
576 | + } | |
577 | + | |
568 | 578 | static class GwtMonitor extends Monitor { |
569 | 579 | protected GwtMonitor (int virtualX, int virtualY, String name) { |
570 | 580 | super(virtualX, virtualY, name); |
@@ -356,4 +356,8 @@ public interface Graphics { | ||
356 | 356 | * Sets one of the predefined {@link SystemCursor}s |
357 | 357 | */ |
358 | 358 | void setSystemCursor(SystemCursor systemCursor); |
359 | + | |
360 | + public long getViewHandle(); | |
361 | + | |
362 | + public long getViewControllerHandle(); | |
359 | 363 | } |
@@ -804,6 +804,21 @@ public interface Input { | ||
804 | 804 | public enum VibrationType { |
805 | 805 | LIGHT, MEDIUM, HEAVY; |
806 | 806 | } |
807 | + | |
808 | + /** | |
809 | + * Defined mostly for iOS. | |
810 | + */ | |
811 | + public enum VibrationStyle { | |
812 | + TRANSIENT, CONTINUOUS; | |
813 | + } | |
814 | + | |
815 | + public void vibrate (int milliseconds, VibrationStyle vibrationStyle); | |
816 | + | |
817 | + public void vibrate (int milliseconds, VibrationStyle vibrationStyle, boolean fallback); | |
818 | + | |
819 | + public void vibrate (int milliseconds, int amplitude, VibrationStyle vibrationStyle, boolean fallback); | |
820 | + | |
821 | + public void vibrate (VibrationType vibrationType, VibrationStyle vibrationStyle, boolean fallback); | |
807 | 822 | |
808 | 823 | /** The azimuth is the angle of the device's orientation around the z-axis. The positive z-axis points towards the earths |
809 | 824 | * center. |
@@ -481,6 +481,26 @@ public class RemoteInput implements Runnable, Input { | ||
481 | 481 | } |
482 | 482 | |
483 | 483 | @Override |
484 | + public void vibrate(int milliseconds, VibrationStyle vibrationStyle) { | |
485 | + | |
486 | + } | |
487 | + | |
488 | + @Override | |
489 | + public void vibrate(int milliseconds, VibrationStyle vibrationStyle, boolean fallback) { | |
490 | + | |
491 | + } | |
492 | + | |
493 | + @Override | |
494 | + public void vibrate(int milliseconds, int amplitude, VibrationStyle vibrationStyle, boolean fallback) { | |
495 | + | |
496 | + } | |
497 | + | |
498 | + @Override | |
499 | + public void vibrate(VibrationType vibrationType, VibrationStyle vibrationStyle, boolean fallback) { | |
500 | + | |
501 | + } | |
502 | + | |
503 | + @Override | |
484 | 504 | public float getAzimuth () { |
485 | 505 | return compass[0]; |
486 | 506 | } |
@@ -320,6 +320,26 @@ public abstract class AbstractTestWrapper extends GdxTest { | ||
320 | 320 | } |
321 | 321 | |
322 | 322 | @Override |
323 | + public void vibrate(int milliseconds, VibrationStyle vibrationStyle) { | |
324 | + | |
325 | + } | |
326 | + | |
327 | + @Override | |
328 | + public void vibrate(int milliseconds, VibrationStyle vibrationStyle, boolean fallback) { | |
329 | + | |
330 | + } | |
331 | + | |
332 | + @Override | |
333 | + public void vibrate(int milliseconds, int amplitude, VibrationStyle vibrationStyle, boolean fallback) { | |
334 | + | |
335 | + } | |
336 | + | |
337 | + @Override | |
338 | + public void vibrate(VibrationType vibrationType, VibrationStyle vibrationStyle, boolean fallback) { | |
339 | + | |
340 | + } | |
341 | + | |
342 | + @Override | |
323 | 343 | public float getAzimuth () { |
324 | 344 | return input.getAzimuth(); |
325 | 345 | } |