Skip to content
0.2.0-dev Download ZIP
93 lines ·4.1 KB Raw
1/**************************************************************************/
2/* java_godot_io_wrapper.h */
3/**************************************************************************/
4/* This file is part of: */
5/* GODOT ENGINE */
6/* https://godotengine.org */
7/**************************************************************************/
8/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10/* */
11/* Permission is hereby granted, free of charge, to any person obtaining */
12/* a copy of this software and associated documentation files (the */
13/* "Software"), to deal in the Software without restriction, including */
14/* without limitation the rights to use, copy, modify, merge, publish, */
15/* distribute, sublicense, and/or sell copies of the Software, and to */
16/* permit persons to whom the Software is furnished to do so, subject to */
17/* the following conditions: */
18/* */
19/* The above copyright notice and this permission notice shall be */
20/* included in all copies or substantial portions of the Software. */
21/* */
22/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29/**************************************************************************/
30
31#pragma once
32
33#include "core/math/rect2i.h"
34#include "core/variant/typed_array.h"
35
36#include <android/log.h>
37#include <jni.h>
38
39// Class that makes functions in java/src/org/godotengine/godot/GodotIO.java callable from C++
40class GodotIOJavaWrapper {
41private:
42 jobject godot_io_instance;
43 jclass cls;
44
45 jmethodID _open_URI = nullptr;
46 jmethodID _get_cache_dir = nullptr;
47 jmethodID _get_data_dir = nullptr;
48 jmethodID _get_temp_dir = nullptr;
49 jmethodID _get_display_cutouts = nullptr;
50 jmethodID _get_display_rotation = nullptr;
51 jmethodID _get_display_safe_area = nullptr;
52 jmethodID _get_locale = nullptr;
53 jmethodID _get_model = nullptr;
54 jmethodID _get_screen_DPI = nullptr;
55 jmethodID _get_scaled_density = nullptr;
56 jmethodID _get_screen_refresh_rate = nullptr;
57 jmethodID _get_unique_id = nullptr;
58 jmethodID _show_keyboard = nullptr;
59 jmethodID _hide_keyboard = nullptr;
60 jmethodID _has_hardware_keyboard = nullptr;
61 jmethodID _set_screen_orientation = nullptr;
62 jmethodID _get_screen_orientation = nullptr;
63 jmethodID _get_system_dir = nullptr;
64
65public:
66 GodotIOJavaWrapper(JNIEnv *p_env, jobject p_godot_io_instance);
67 ~GodotIOJavaWrapper();
68
69 jobject get_instance();
70
71 Error open_uri(const String &p_uri);
72 String get_cache_dir();
73 String get_temp_dir();
74 String get_user_data_dir(const String &p_user_dir);
75 String get_locale();
76 String get_model();
77 int get_screen_dpi();
78 float get_scaled_density();
79 float get_screen_refresh_rate(float fallback);
80 TypedArray<Rect2> get_display_cutouts();
81 Rect2i get_display_safe_area();
82 String get_unique_id();
83 bool has_vk();
84 bool has_hardware_keyboard();
85 void show_vk(const String &p_existing, int p_type, int p_max_input_length, int p_cursor_start, int p_cursor_end);
86 void hide_vk();
87 int get_vk_height();
88 void set_vk_height(int p_height);
89 void set_screen_orientation(int p_orient);
90 int get_screen_orientation();
91 String get_system_dir(int p_dir, bool p_shared_storage);
92 int get_display_rotation();
93};