kivyforge 3.0.0.dev0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (225) hide show
  1. kivyforge/__init__.py +9 -0
  2. kivyforge/artifacts/__init__.py +41 -0
  3. kivyforge/artifacts/cache.py +81 -0
  4. kivyforge/artifacts/collect.py +354 -0
  5. kivyforge/artifacts/download.py +125 -0
  6. kivyforge/artifacts/frameworks.py +240 -0
  7. kivyforge/artifacts/native_stage_util.py +346 -0
  8. kivyforge/artifacts/runtime.py +65 -0
  9. kivyforge/artifacts/verify.py +45 -0
  10. kivyforge/artifacts/wheels.py +89 -0
  11. kivyforge/bundle/__init__.py +1 -0
  12. kivyforge/bundle/pycompile.py +161 -0
  13. kivyforge/cli/__init__.py +52 -0
  14. kivyforge/cli/_common.py +62 -0
  15. kivyforge/cli/_platform.py +84 -0
  16. kivyforge/cli/build.py +111 -0
  17. kivyforge/cli/clean.py +135 -0
  18. kivyforge/cli/doctor.py +52 -0
  19. kivyforge/cli/init.py +612 -0
  20. kivyforge/cli/init_writer.py +716 -0
  21. kivyforge/cli/lock.py +261 -0
  22. kivyforge/cli/open_cmd.py +15 -0
  23. kivyforge/cli/package.py +134 -0
  24. kivyforge/cli/run.py +162 -0
  25. kivyforge/cli/status.py +20 -0
  26. kivyforge/cli/upgrade.py +314 -0
  27. kivyforge/config/__init__.py +46 -0
  28. kivyforge/config/errors.py +43 -0
  29. kivyforge/config/icons.py +60 -0
  30. kivyforge/config/loader.py +3079 -0
  31. kivyforge/config/model.py +817 -0
  32. kivyforge/doctor/__init__.py +19 -0
  33. kivyforge/doctor/checks_common.py +95 -0
  34. kivyforge/doctor/probe.py +357 -0
  35. kivyforge/doctor/result.py +41 -0
  36. kivyforge/lock/__init__.py +42 -0
  37. kivyforge/lock/_pip_shim.py +63 -0
  38. kivyforge/lock/find_links.py +182 -0
  39. kivyforge/lock/model.py +69 -0
  40. kivyforge/lock/pep751.py +111 -0
  41. kivyforge/lock/reader.py +30 -0
  42. kivyforge/lock/resolver.py +124 -0
  43. kivyforge/lock/wheelruntime/__init__.py +70 -0
  44. kivyforge/lock/wheelruntime/builder.py +280 -0
  45. kivyforge/lock/wheelruntime/model.py +94 -0
  46. kivyforge/lock/wheelruntime/native_binaries.py +127 -0
  47. kivyforge/lock/wheelruntime/pbs_github.py +133 -0
  48. kivyforge/lock/wheelruntime/profile.py +104 -0
  49. kivyforge/lock/wheelruntime/resolver.py +248 -0
  50. kivyforge/lock/wheelruntime/runtime.py +161 -0
  51. kivyforge/lock/wheelruntime/serialize.py +245 -0
  52. kivyforge/platforms/__init__.py +114 -0
  53. kivyforge/platforms/android/__init__.py +140 -0
  54. kivyforge/platforms/android/adb.py +215 -0
  55. kivyforge/platforms/android/bootstrap/__init__.py +7 -0
  56. kivyforge/platforms/android/bootstrap/contract.py +166 -0
  57. kivyforge/platforms/android/bootstrap/render.py +244 -0
  58. kivyforge/platforms/android/bootstrap/templates/androidtest/KivyforgeContractTest.java +76 -0
  59. kivyforge/platforms/android/bootstrap/templates/bootstrap_py/_kivy_bootstrap.py +50 -0
  60. kivyforge/platforms/android/bootstrap/templates/bootstrap_py/_kivyforge_bootstrap.py +54 -0
  61. kivyforge/platforms/android/bootstrap/templates/bootstrap_py/_kivyforge_selftest.py +97 -0
  62. kivyforge/platforms/android/bootstrap/templates/cpp/CMakeLists.txt +20 -0
  63. kivyforge/platforms/android/bootstrap/templates/cpp/main.c +150 -0
  64. kivyforge/platforms/android/bootstrap/templates/java/org/jnius/NativeInvocationHandler.java +48 -0
  65. kivyforge/platforms/android/bootstrap/templates/java/org/kivy/android/PythonActivity.java +75 -0
  66. kivyforge/platforms/android/bootstrap/templates/java/org/kivy/android/PythonBundle.java +132 -0
  67. kivyforge/platforms/android/bootstrap/templates/java/org/kivy/android/PythonService.java +189 -0
  68. kivyforge/platforms/android/bootstrap/templates/java/org/renpy/android/Hardware.java +276 -0
  69. kivyforge/platforms/android/bootstrap/templates/sdl2/LICENSE-SDL.txt +18 -0
  70. kivyforge/platforms/android/bootstrap/templates/sdl2/SDL_REVISION.txt +3 -0
  71. kivyforge/platforms/android/bootstrap/templates/sdl2/org/libsdl/app/HIDDevice.java +22 -0
  72. kivyforge/platforms/android/bootstrap/templates/sdl2/org/libsdl/app/HIDDeviceBLESteamController.java +650 -0
  73. kivyforge/platforms/android/bootstrap/templates/sdl2/org/libsdl/app/HIDDeviceManager.java +698 -0
  74. kivyforge/platforms/android/bootstrap/templates/sdl2/org/libsdl/app/HIDDeviceUSB.java +309 -0
  75. kivyforge/platforms/android/bootstrap/templates/sdl2/org/libsdl/app/SDL.java +90 -0
  76. kivyforge/platforms/android/bootstrap/templates/sdl2/org/libsdl/app/SDLActivity.java +2120 -0
  77. kivyforge/platforms/android/bootstrap/templates/sdl2/org/libsdl/app/SDLAudioManager.java +514 -0
  78. kivyforge/platforms/android/bootstrap/templates/sdl2/org/libsdl/app/SDLControllerManager.java +856 -0
  79. kivyforge/platforms/android/bootstrap/templates/sdl2/org/libsdl/app/SDLSurface.java +405 -0
  80. kivyforge/platforms/android/bootstrap/templates/sdl3/LICENSE-SDL.txt +18 -0
  81. kivyforge/platforms/android/bootstrap/templates/sdl3/SDL_REVISION.txt +3 -0
  82. kivyforge/platforms/android/bootstrap/templates/sdl3/org/libsdl/app/HIDDevice.java +21 -0
  83. kivyforge/platforms/android/bootstrap/templates/sdl3/org/libsdl/app/HIDDeviceBLESteamController.java +829 -0
  84. kivyforge/platforms/android/bootstrap/templates/sdl3/org/libsdl/app/HIDDeviceManager.java +698 -0
  85. kivyforge/platforms/android/bootstrap/templates/sdl3/org/libsdl/app/HIDDeviceUSB.java +354 -0
  86. kivyforge/platforms/android/bootstrap/templates/sdl3/org/libsdl/app/SDL.java +90 -0
  87. kivyforge/platforms/android/bootstrap/templates/sdl3/org/libsdl/app/SDLActivity.java +2240 -0
  88. kivyforge/platforms/android/bootstrap/templates/sdl3/org/libsdl/app/SDLAudioManager.java +126 -0
  89. kivyforge/platforms/android/bootstrap/templates/sdl3/org/libsdl/app/SDLControllerManager.java +1010 -0
  90. kivyforge/platforms/android/bootstrap/templates/sdl3/org/libsdl/app/SDLDummyEdit.java +66 -0
  91. kivyforge/platforms/android/bootstrap/templates/sdl3/org/libsdl/app/SDLInputConnection.java +136 -0
  92. kivyforge/platforms/android/bootstrap/templates/sdl3/org/libsdl/app/SDLSensorManager.java +73 -0
  93. kivyforge/platforms/android/bootstrap/templates/sdl3/org/libsdl/app/SDLSurface.java +464 -0
  94. kivyforge/platforms/android/cli.py +1023 -0
  95. kivyforge/platforms/android/doctor.py +899 -0
  96. kivyforge/platforms/android/elf.py +148 -0
  97. kivyforge/platforms/android/generate/__init__.py +1 -0
  98. kivyforge/platforms/android/generate/manifest.py +261 -0
  99. kivyforge/platforms/android/generate/project.py +462 -0
  100. kivyforge/platforms/android/generate/services.py +187 -0
  101. kivyforge/platforms/android/gradle_wrapper/NOTICE +3 -0
  102. kivyforge/platforms/android/gradle_wrapper/SHA256SUMS +1 -0
  103. kivyforge/platforms/android/gradle_wrapper/gradle-wrapper.jar +0 -0
  104. kivyforge/platforms/android/gradle_wrapper/gradlew +164 -0
  105. kivyforge/platforms/android/gradle_wrapper/gradlew.bat +90 -0
  106. kivyforge/platforms/android/gradlew.py +60 -0
  107. kivyforge/platforms/android/icons.py +237 -0
  108. kivyforge/platforms/android/lock/__init__.py +1 -0
  109. kivyforge/platforms/android/lock/archives.py +109 -0
  110. kivyforge/platforms/android/lock/builder.py +387 -0
  111. kivyforge/platforms/android/lock/markers.py +71 -0
  112. kivyforge/platforms/android/lock/maven.py +252 -0
  113. kivyforge/platforms/android/lock/model.py +113 -0
  114. kivyforge/platforms/android/lock/python_meta.py +199 -0
  115. kivyforge/platforms/android/lock/reader.py +206 -0
  116. kivyforge/platforms/android/lock/resolver.py +276 -0
  117. kivyforge/platforms/android/lock/writer.py +121 -0
  118. kivyforge/platforms/android/policy.py +214 -0
  119. kivyforge/platforms/android/signing.py +145 -0
  120. kivyforge/platforms/android/smoke.py +43 -0
  121. kivyforge/platforms/android/splash.py +293 -0
  122. kivyforge/platforms/android/stage/__init__.py +1 -0
  123. kivyforge/platforms/android/stage/bundle.py +295 -0
  124. kivyforge/platforms/android/stage/jnilibs.py +186 -0
  125. kivyforge/platforms/android/stage/runtime.py +61 -0
  126. kivyforge/platforms/android/stage/wheels.py +106 -0
  127. kivyforge/platforms/android/toolchain.py +29 -0
  128. kivyforge/platforms/base.py +157 -0
  129. kivyforge/platforms/ios/__init__.py +129 -0
  130. kivyforge/platforms/ios/assets.py +193 -0
  131. kivyforge/platforms/ios/buildsettings.py +128 -0
  132. kivyforge/platforms/ios/cli.py +543 -0
  133. kivyforge/platforms/ios/doctor.py +410 -0
  134. kivyforge/platforms/ios/entitlements.py +34 -0
  135. kivyforge/platforms/ios/generator.py +318 -0
  136. kivyforge/platforms/ios/lock/__init__.py +71 -0
  137. kivyforge/platforms/ios/lock/builder.py +393 -0
  138. kivyforge/platforms/ios/lock/markers.py +69 -0
  139. kivyforge/platforms/ios/lock/model.py +95 -0
  140. kivyforge/platforms/ios/lock/python_meta.py +187 -0
  141. kivyforge/platforms/ios/lock/reader.py +191 -0
  142. kivyforge/platforms/ios/lock/resolver.py +304 -0
  143. kivyforge/platforms/ios/lock/spm.py +217 -0
  144. kivyforge/platforms/ios/lock/writer.py +114 -0
  145. kivyforge/platforms/ios/lock/xcframework.py +188 -0
  146. kivyforge/platforms/ios/materialize.py +59 -0
  147. kivyforge/platforms/ios/plist.py +91 -0
  148. kivyforge/platforms/ios/privacy.py +39 -0
  149. kivyforge/platforms/ios/skeleton.py +165 -0
  150. kivyforge/platforms/ios/sources.py +63 -0
  151. kivyforge/platforms/ios/staging.py +225 -0
  152. kivyforge/platforms/ios/swift_packages.py +324 -0
  153. kivyforge/platforms/ios/templates/kivyforge_bootstrap.h +34 -0
  154. kivyforge/platforms/ios/templates/kivyforge_bootstrap.m +146 -0
  155. kivyforge/platforms/ios/templates/main.m +15 -0
  156. kivyforge/platforms/ios/templates/main_config.h.in +12 -0
  157. kivyforge/platforms/ios/xcframeworks.py +194 -0
  158. kivyforge/platforms/ios/xcode/__init__.py +76 -0
  159. kivyforge/platforms/ios/xcode/commands.py +296 -0
  160. kivyforge/platforms/ios/xcode/runner.py +316 -0
  161. kivyforge/platforms/linux/__init__.py +120 -0
  162. kivyforge/platforms/linux/appimage.py +169 -0
  163. kivyforge/platforms/linux/bundle.py +235 -0
  164. kivyforge/platforms/linux/cli.py +232 -0
  165. kivyforge/platforms/linux/desktop.py +71 -0
  166. kivyforge/platforms/linux/doctor.py +438 -0
  167. kivyforge/platforms/linux/elftools.py +95 -0
  168. kivyforge/platforms/linux/icons.py +129 -0
  169. kivyforge/platforms/linux/launcher.py +107 -0
  170. kivyforge/platforms/linux/lock/__init__.py +126 -0
  171. kivyforge/platforms/linux/lock/profile.py +254 -0
  172. kivyforge/platforms/linux/lock/runtime.py +75 -0
  173. kivyforge/platforms/linux/native_stage.py +47 -0
  174. kivyforge/platforms/linux/runtime_stage.py +107 -0
  175. kivyforge/platforms/linux/wheels_stage.py +103 -0
  176. kivyforge/platforms/macos/__init__.py +121 -0
  177. kivyforge/platforms/macos/bundle.py +255 -0
  178. kivyforge/platforms/macos/cli.py +269 -0
  179. kivyforge/platforms/macos/doctor.py +480 -0
  180. kivyforge/platforms/macos/icns.py +75 -0
  181. kivyforge/platforms/macos/launcher.py +118 -0
  182. kivyforge/platforms/macos/lock/__init__.py +112 -0
  183. kivyforge/platforms/macos/lock/profile.py +119 -0
  184. kivyforge/platforms/macos/lock/runtime.py +58 -0
  185. kivyforge/platforms/macos/machotools.py +138 -0
  186. kivyforge/platforms/macos/native_stage.py +47 -0
  187. kivyforge/platforms/macos/notarize.py +143 -0
  188. kivyforge/platforms/macos/plist.py +37 -0
  189. kivyforge/platforms/macos/runtime_stage.py +110 -0
  190. kivyforge/platforms/macos/signing.py +78 -0
  191. kivyforge/platforms/macos/wheels_stage.py +108 -0
  192. kivyforge/platforms/windows/__init__.py +133 -0
  193. kivyforge/platforms/windows/assets.py +76 -0
  194. kivyforge/platforms/windows/bundle.py +298 -0
  195. kivyforge/platforms/windows/cli.py +314 -0
  196. kivyforge/platforms/windows/doctor.py +563 -0
  197. kivyforge/platforms/windows/fsswap.py +87 -0
  198. kivyforge/platforms/windows/icons.py +64 -0
  199. kivyforge/platforms/windows/launcher/__init__.py +193 -0
  200. kivyforge/platforms/windows/launcher/build_launcher.py +507 -0
  201. kivyforge/platforms/windows/launcher/launcher.c +379 -0
  202. kivyforge/platforms/windows/lock/__init__.py +112 -0
  203. kivyforge/platforms/windows/lock/profile.py +101 -0
  204. kivyforge/platforms/windows/lock/runtime.py +64 -0
  205. kivyforge/platforms/windows/naming.py +52 -0
  206. kivyforge/platforms/windows/native_stage.py +66 -0
  207. kivyforge/platforms/windows/petools.py +98 -0
  208. kivyforge/platforms/windows/rcedit.py +116 -0
  209. kivyforge/platforms/windows/runtime_stage.py +221 -0
  210. kivyforge/platforms/windows/signing.py +168 -0
  211. kivyforge/platforms/windows/vendor/LICENSE.rcedit +29 -0
  212. kivyforge/platforms/windows/vendor/NOTICE +17 -0
  213. kivyforge/platforms/windows/vendor/SHA256SUMS +4 -0
  214. kivyforge/platforms/windows/vendor/TOOLSET.txt +4 -0
  215. kivyforge/platforms/windows/vendor/__init__.py +12 -0
  216. kivyforge/platforms/windows/vendor/fetch_rcedit.py +97 -0
  217. kivyforge/platforms/windows/vendor/launcher-amd64.exe +0 -0
  218. kivyforge/platforms/windows/vendor/rcedit-x64.exe +0 -0
  219. kivyforge/platforms/windows/wheels_stage.py +139 -0
  220. kivyforge-3.0.0.dev0.dist-info/METADATA +609 -0
  221. kivyforge-3.0.0.dev0.dist-info/RECORD +225 -0
  222. kivyforge-3.0.0.dev0.dist-info/WHEEL +5 -0
  223. kivyforge-3.0.0.dev0.dist-info/entry_points.txt +3 -0
  224. kivyforge-3.0.0.dev0.dist-info/licenses/LICENSE +21 -0
  225. kivyforge-3.0.0.dev0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,405 @@
1
+ package org.libsdl.app;
2
+
3
+
4
+ import android.content.Context;
5
+ import android.content.pm.ActivityInfo;
6
+ import android.hardware.Sensor;
7
+ import android.hardware.SensorEvent;
8
+ import android.hardware.SensorEventListener;
9
+ import android.hardware.SensorManager;
10
+ import android.os.Build;
11
+ import android.util.DisplayMetrics;
12
+ import android.util.Log;
13
+ import android.view.Display;
14
+ import android.view.InputDevice;
15
+ import android.view.KeyEvent;
16
+ import android.view.MotionEvent;
17
+ import android.view.Surface;
18
+ import android.view.SurfaceHolder;
19
+ import android.view.SurfaceView;
20
+ import android.view.View;
21
+ import android.view.WindowManager;
22
+
23
+
24
+ /**
25
+ SDLSurface. This is what we draw on, so we need to know when it's created
26
+ in order to do anything useful.
27
+
28
+ Because of this, that's where we set up the SDL thread
29
+ */
30
+ public class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
31
+ View.OnKeyListener, View.OnTouchListener, SensorEventListener {
32
+
33
+ // Sensors
34
+ protected SensorManager mSensorManager;
35
+ protected Display mDisplay;
36
+
37
+ // Keep track of the surface size to normalize touch events
38
+ protected float mWidth, mHeight;
39
+
40
+ // Is SurfaceView ready for rendering
41
+ public boolean mIsSurfaceReady;
42
+
43
+ // Startup
44
+ public SDLSurface(Context context) {
45
+ super(context);
46
+ getHolder().addCallback(this);
47
+
48
+ setFocusable(true);
49
+ setFocusableInTouchMode(true);
50
+ requestFocus();
51
+ setOnKeyListener(this);
52
+ setOnTouchListener(this);
53
+
54
+ mDisplay = ((WindowManager)context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
55
+ mSensorManager = (SensorManager)context.getSystemService(Context.SENSOR_SERVICE);
56
+
57
+ setOnGenericMotionListener(SDLActivity.getMotionListener());
58
+
59
+ // Some arbitrary defaults to avoid a potential division by zero
60
+ mWidth = 1.0f;
61
+ mHeight = 1.0f;
62
+
63
+ mIsSurfaceReady = false;
64
+ }
65
+
66
+ public void handlePause() {
67
+ enableSensor(Sensor.TYPE_ACCELEROMETER, false);
68
+ }
69
+
70
+ public void handleResume() {
71
+ setFocusable(true);
72
+ setFocusableInTouchMode(true);
73
+ requestFocus();
74
+ setOnKeyListener(this);
75
+ setOnTouchListener(this);
76
+ enableSensor(Sensor.TYPE_ACCELEROMETER, true);
77
+ }
78
+
79
+ public Surface getNativeSurface() {
80
+ return getHolder().getSurface();
81
+ }
82
+
83
+ // Called when we have a valid drawing surface
84
+ @Override
85
+ public void surfaceCreated(SurfaceHolder holder) {
86
+ Log.v("SDL", "surfaceCreated()");
87
+ SDLActivity.onNativeSurfaceCreated();
88
+ }
89
+
90
+ // Called when we lose the surface
91
+ @Override
92
+ public void surfaceDestroyed(SurfaceHolder holder) {
93
+ Log.v("SDL", "surfaceDestroyed()");
94
+
95
+ // Transition to pause, if needed
96
+ SDLActivity.mNextNativeState = SDLActivity.NativeState.PAUSED;
97
+ SDLActivity.handleNativeState();
98
+
99
+ mIsSurfaceReady = false;
100
+ SDLActivity.onNativeSurfaceDestroyed();
101
+ }
102
+
103
+ // Called when the surface is resized
104
+ @Override
105
+ public void surfaceChanged(SurfaceHolder holder,
106
+ int format, int width, int height) {
107
+ Log.v("SDL", "surfaceChanged()");
108
+
109
+ if (SDLActivity.mSingleton == null) {
110
+ return;
111
+ }
112
+
113
+ mWidth = width;
114
+ mHeight = height;
115
+ int nDeviceWidth = width;
116
+ int nDeviceHeight = height;
117
+ try
118
+ {
119
+ if (Build.VERSION.SDK_INT >= 17 /* Android 4.2 (JELLY_BEAN_MR1) */) {
120
+ DisplayMetrics realMetrics = new DisplayMetrics();
121
+ mDisplay.getRealMetrics( realMetrics );
122
+ nDeviceWidth = realMetrics.widthPixels;
123
+ nDeviceHeight = realMetrics.heightPixels;
124
+ }
125
+ } catch(Exception ignored) {
126
+ }
127
+
128
+ synchronized(SDLActivity.getContext()) {
129
+ // In case we're waiting on a size change after going fullscreen, send a notification.
130
+ SDLActivity.getContext().notifyAll();
131
+ }
132
+
133
+ Log.v("SDL", "Window size: " + width + "x" + height);
134
+ Log.v("SDL", "Device size: " + nDeviceWidth + "x" + nDeviceHeight);
135
+ SDLActivity.nativeSetScreenResolution(width, height, nDeviceWidth, nDeviceHeight, mDisplay.getRefreshRate());
136
+ SDLActivity.onNativeResize();
137
+
138
+ // Prevent a screen distortion glitch,
139
+ // for instance when the device is in Landscape and a Portrait App is resumed.
140
+ boolean skip = false;
141
+ int requestedOrientation = SDLActivity.mSingleton.getRequestedOrientation();
142
+
143
+ if (requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT || requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT) {
144
+ if (mWidth > mHeight) {
145
+ skip = true;
146
+ }
147
+ } else if (requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE || requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE) {
148
+ if (mWidth < mHeight) {
149
+ skip = true;
150
+ }
151
+ }
152
+
153
+ // Special Patch for Square Resolution: Black Berry Passport
154
+ if (skip) {
155
+ double min = Math.min(mWidth, mHeight);
156
+ double max = Math.max(mWidth, mHeight);
157
+
158
+ if (max / min < 1.20) {
159
+ Log.v("SDL", "Don't skip on such aspect-ratio. Could be a square resolution.");
160
+ skip = false;
161
+ }
162
+ }
163
+
164
+ // Don't skip in MultiWindow.
165
+ if (skip) {
166
+ if (Build.VERSION.SDK_INT >= 24 /* Android 7.0 (N) */) {
167
+ if (SDLActivity.mSingleton.isInMultiWindowMode()) {
168
+ Log.v("SDL", "Don't skip in Multi-Window");
169
+ skip = false;
170
+ }
171
+ }
172
+ }
173
+
174
+ if (skip) {
175
+ Log.v("SDL", "Skip .. Surface is not ready.");
176
+ mIsSurfaceReady = false;
177
+ return;
178
+ }
179
+
180
+ /* If the surface has been previously destroyed by onNativeSurfaceDestroyed, recreate it here */
181
+ SDLActivity.onNativeSurfaceChanged();
182
+
183
+ /* Surface is ready */
184
+ mIsSurfaceReady = true;
185
+
186
+ SDLActivity.mNextNativeState = SDLActivity.NativeState.RESUMED;
187
+ SDLActivity.handleNativeState();
188
+ }
189
+
190
+ // Key events
191
+ @Override
192
+ public boolean onKey(View v, int keyCode, KeyEvent event) {
193
+ return SDLActivity.handleKeyEvent(v, keyCode, event, null);
194
+ }
195
+
196
+ // Touch events
197
+ @Override
198
+ public boolean onTouch(View v, MotionEvent event) {
199
+ /* Ref: http://developer.android.com/training/gestures/multi.html */
200
+ int touchDevId = event.getDeviceId();
201
+ final int pointerCount = event.getPointerCount();
202
+ int action = event.getActionMasked();
203
+ int pointerFingerId;
204
+ int i = -1;
205
+ float x,y,p;
206
+
207
+ /*
208
+ * Prevent id to be -1, since it's used in SDL internal for synthetic events
209
+ * Appears when using Android emulator, eg:
210
+ * adb shell input mouse tap 100 100
211
+ * adb shell input touchscreen tap 100 100
212
+ */
213
+ if (touchDevId < 0) {
214
+ touchDevId -= 1;
215
+ }
216
+
217
+ // 12290 = Samsung DeX mode desktop mouse
218
+ // 12290 = 0x3002 = 0x2002 | 0x1002 = SOURCE_MOUSE | SOURCE_TOUCHSCREEN
219
+ // 0x2 = SOURCE_CLASS_POINTER
220
+ if (event.getSource() == InputDevice.SOURCE_MOUSE || event.getSource() == (InputDevice.SOURCE_MOUSE | InputDevice.SOURCE_TOUCHSCREEN)) {
221
+ int mouseButton = 1;
222
+ try {
223
+ Object object = event.getClass().getMethod("getButtonState").invoke(event);
224
+ if (object != null) {
225
+ mouseButton = (Integer) object;
226
+ }
227
+ } catch(Exception ignored) {
228
+ }
229
+
230
+ // We need to check if we're in relative mouse mode and get the axis offset rather than the x/y values
231
+ // if we are. We'll leverage our existing mouse motion listener
232
+ SDLGenericMotionListener_API12 motionListener = SDLActivity.getMotionListener();
233
+ x = motionListener.getEventX(event);
234
+ y = motionListener.getEventY(event);
235
+
236
+ SDLActivity.onNativeMouse(mouseButton, action, x, y, motionListener.inRelativeMode());
237
+ } else {
238
+ switch(action) {
239
+ case MotionEvent.ACTION_MOVE:
240
+ for (i = 0; i < pointerCount; i++) {
241
+ pointerFingerId = event.getPointerId(i);
242
+ x = event.getX(i) / mWidth;
243
+ y = event.getY(i) / mHeight;
244
+ p = event.getPressure(i);
245
+ if (p > 1.0f) {
246
+ // may be larger than 1.0f on some devices
247
+ // see the documentation of getPressure(i)
248
+ p = 1.0f;
249
+ }
250
+ SDLActivity.onNativeTouch(touchDevId, pointerFingerId, action, x, y, p);
251
+ }
252
+ break;
253
+
254
+ case MotionEvent.ACTION_UP:
255
+ case MotionEvent.ACTION_DOWN:
256
+ // Primary pointer up/down, the index is always zero
257
+ i = 0;
258
+ /* fallthrough */
259
+ case MotionEvent.ACTION_POINTER_UP:
260
+ case MotionEvent.ACTION_POINTER_DOWN:
261
+ // Non primary pointer up/down
262
+ if (i == -1) {
263
+ i = event.getActionIndex();
264
+ }
265
+
266
+ pointerFingerId = event.getPointerId(i);
267
+ x = event.getX(i) / mWidth;
268
+ y = event.getY(i) / mHeight;
269
+ p = event.getPressure(i);
270
+ if (p > 1.0f) {
271
+ // may be larger than 1.0f on some devices
272
+ // see the documentation of getPressure(i)
273
+ p = 1.0f;
274
+ }
275
+ SDLActivity.onNativeTouch(touchDevId, pointerFingerId, action, x, y, p);
276
+ break;
277
+
278
+ case MotionEvent.ACTION_CANCEL:
279
+ for (i = 0; i < pointerCount; i++) {
280
+ pointerFingerId = event.getPointerId(i);
281
+ x = event.getX(i) / mWidth;
282
+ y = event.getY(i) / mHeight;
283
+ p = event.getPressure(i);
284
+ if (p > 1.0f) {
285
+ // may be larger than 1.0f on some devices
286
+ // see the documentation of getPressure(i)
287
+ p = 1.0f;
288
+ }
289
+ SDLActivity.onNativeTouch(touchDevId, pointerFingerId, MotionEvent.ACTION_UP, x, y, p);
290
+ }
291
+ break;
292
+
293
+ default:
294
+ break;
295
+ }
296
+ }
297
+
298
+ return true;
299
+ }
300
+
301
+ // Sensor events
302
+ public void enableSensor(int sensortype, boolean enabled) {
303
+ // TODO: This uses getDefaultSensor - what if we have >1 accels?
304
+ if (enabled) {
305
+ mSensorManager.registerListener(this,
306
+ mSensorManager.getDefaultSensor(sensortype),
307
+ SensorManager.SENSOR_DELAY_GAME, null);
308
+ } else {
309
+ mSensorManager.unregisterListener(this,
310
+ mSensorManager.getDefaultSensor(sensortype));
311
+ }
312
+ }
313
+
314
+ @Override
315
+ public void onAccuracyChanged(Sensor sensor, int accuracy) {
316
+ // TODO
317
+ }
318
+
319
+ @Override
320
+ public void onSensorChanged(SensorEvent event) {
321
+ if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
322
+
323
+ // Since we may have an orientation set, we won't receive onConfigurationChanged events.
324
+ // We thus should check here.
325
+ int newOrientation;
326
+
327
+ float x, y;
328
+ switch (mDisplay.getRotation()) {
329
+ case Surface.ROTATION_90:
330
+ x = -event.values[1];
331
+ y = event.values[0];
332
+ newOrientation = SDLActivity.SDL_ORIENTATION_LANDSCAPE;
333
+ break;
334
+ case Surface.ROTATION_270:
335
+ x = event.values[1];
336
+ y = -event.values[0];
337
+ newOrientation = SDLActivity.SDL_ORIENTATION_LANDSCAPE_FLIPPED;
338
+ break;
339
+ case Surface.ROTATION_180:
340
+ x = -event.values[0];
341
+ y = -event.values[1];
342
+ newOrientation = SDLActivity.SDL_ORIENTATION_PORTRAIT_FLIPPED;
343
+ break;
344
+ case Surface.ROTATION_0:
345
+ default:
346
+ x = event.values[0];
347
+ y = event.values[1];
348
+ newOrientation = SDLActivity.SDL_ORIENTATION_PORTRAIT;
349
+ break;
350
+ }
351
+
352
+ if (newOrientation != SDLActivity.mCurrentOrientation) {
353
+ SDLActivity.mCurrentOrientation = newOrientation;
354
+ SDLActivity.onNativeOrientationChanged(newOrientation);
355
+ }
356
+
357
+ SDLActivity.onNativeAccel(-x / SensorManager.GRAVITY_EARTH,
358
+ y / SensorManager.GRAVITY_EARTH,
359
+ event.values[2] / SensorManager.GRAVITY_EARTH);
360
+
361
+
362
+ }
363
+ }
364
+
365
+ // Captured pointer events for API 26.
366
+ public boolean onCapturedPointerEvent(MotionEvent event)
367
+ {
368
+ int action = event.getActionMasked();
369
+
370
+ float x, y;
371
+ switch (action) {
372
+ case MotionEvent.ACTION_SCROLL:
373
+ x = event.getAxisValue(MotionEvent.AXIS_HSCROLL, 0);
374
+ y = event.getAxisValue(MotionEvent.AXIS_VSCROLL, 0);
375
+ SDLActivity.onNativeMouse(0, action, x, y, false);
376
+ return true;
377
+
378
+ case MotionEvent.ACTION_HOVER_MOVE:
379
+ case MotionEvent.ACTION_MOVE:
380
+ x = event.getX(0);
381
+ y = event.getY(0);
382
+ SDLActivity.onNativeMouse(0, action, x, y, true);
383
+ return true;
384
+
385
+ case MotionEvent.ACTION_BUTTON_PRESS:
386
+ case MotionEvent.ACTION_BUTTON_RELEASE:
387
+
388
+ // Change our action value to what SDL's code expects.
389
+ if (action == MotionEvent.ACTION_BUTTON_PRESS) {
390
+ action = MotionEvent.ACTION_DOWN;
391
+ } else { /* MotionEvent.ACTION_BUTTON_RELEASE */
392
+ action = MotionEvent.ACTION_UP;
393
+ }
394
+
395
+ x = event.getX(0);
396
+ y = event.getY(0);
397
+ int button = event.getButtonState();
398
+
399
+ SDLActivity.onNativeMouse(button, action, x, y, true);
400
+ return true;
401
+ }
402
+
403
+ return false;
404
+ }
405
+ }
@@ -0,0 +1,18 @@
1
+ Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
2
+
3
+ This software is provided 'as-is', without any express or implied
4
+ warranty. In no event will the authors be held liable for any damages
5
+ arising from the use of this software.
6
+
7
+ Permission is granted to anyone to use this software for any purpose,
8
+ including commercial applications, and to alter it and redistribute it
9
+ freely, subject to the following restrictions:
10
+
11
+ 1. The origin of this software must not be misrepresented; you must not
12
+ claim that you wrote the original software. If you use this software
13
+ in a product, an acknowledgment in the product documentation would be
14
+ appreciated but is not required.
15
+ 2. Altered source versions must be plainly marked as such, and must not be
16
+ misrepresented as being the original software.
17
+ 3. This notice may not be removed or altered from any source distribution.
18
+
@@ -0,0 +1,3 @@
1
+ #define SDL_MAJOR_VERSION 3
2
+ #define SDL_MINOR_VERSION 4
3
+ #define SDL_MICRO_VERSION 12
@@ -0,0 +1,21 @@
1
+ package org.libsdl.app;
2
+
3
+ import android.hardware.usb.UsbDevice;
4
+
5
+ interface HIDDevice
6
+ {
7
+ public int getId();
8
+ public int getVendorId();
9
+ public int getProductId();
10
+ public String getSerialNumber();
11
+ public int getVersion();
12
+ public String getManufacturerName();
13
+ public String getProductName();
14
+ public UsbDevice getDevice();
15
+ public boolean open();
16
+ public int writeReport(byte[] report, boolean feature);
17
+ public boolean readReport(byte[] report, boolean feature);
18
+ public void setFrozen(boolean frozen);
19
+ public void close();
20
+ public void shutdown();
21
+ }