aboutsummaryrefslogtreecommitdiff
path: root/v_windows/v/vlib/gg/gg_android.c.v
diff options
context:
space:
mode:
authorIndrajith K L2022-12-03 17:00:20 +0530
committerIndrajith K L2022-12-03 17:00:20 +0530
commitf5c4671bfbad96bf346bd7e9a21fc4317b4959df (patch)
tree2764fc62da58f2ba8da7ed341643fc359873142f /v_windows/v/vlib/gg/gg_android.c.v
downloadcli-tools-windows-master.tar.gz
cli-tools-windows-master.tar.bz2
cli-tools-windows-master.zip
Adds most of the toolsHEADmaster
Diffstat (limited to 'v_windows/v/vlib/gg/gg_android.c.v')
-rw-r--r--v_windows/v/vlib/gg/gg_android.c.v37
1 files changed, 37 insertions, 0 deletions
diff --git a/v_windows/v/vlib/gg/gg_android.c.v b/v_windows/v/vlib/gg/gg_android.c.v
new file mode 100644
index 0000000..23450f2
--- /dev/null
+++ b/v_windows/v/vlib/gg/gg_android.c.v
@@ -0,0 +1,37 @@
+module gg
+
+import sokol.sapp
+
+#include <android/configuration.h>
+#include <android/native_activity.h>
+
+fn C.AConfiguration_new() voidptr
+fn C.AConfiguration_fromAssetManager(voidptr, voidptr)
+fn C.AConfiguration_getDensity(voidptr) u32
+fn C.AConfiguration_delete(voidptr)
+
+struct C.AAssetManager {}
+
+// See https://developer.android.com/ndk/reference/struct/a-native-activity for more info.
+struct C.ANativeActivity {
+pub:
+ assetManager voidptr // Pointer to the Asset Manager instance for the application. (AAssetManager *)
+ callbacks voidptr // Pointer to the callback function table of the native application. (struct ANativeActivityCallbacks *)
+ clazz voidptr // The NativeActivity object handle.
+ env voidptr // JNI context for the main thread of the app.
+ externalDataPath &char // Path to this application's external (removable/mountable) data directory.
+ instance voidptr // This is the native instance of the application.
+ internalDataPath &char // Path to this application's internal data directory.
+ obbPath &char // Available starting with Honeycomb: path to the directory containing the application's OBB files (if any).
+ sdkVersion int // The platform's SDK version code.
+ vm voidptr // The global handle on the process's Java VM
+}
+
+pub fn android_dpi_scale() f32 {
+ config := C.AConfiguration_new()
+ activity := &C.ANativeActivity(sapp.android_get_native_activity())
+ C.AConfiguration_fromAssetManager(config, activity.assetManager)
+ density := C.AConfiguration_getDensity(config)
+ C.AConfiguration_delete(config)
+ return f32(density) / 160
+}